documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572
  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: DeepImmutable<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. /**
  2412. * Defines the first coordinates (on X axis)
  2413. */
  2414. x: number;
  2415. /**
  2416. * Defines the second coordinates (on Y axis)
  2417. */
  2418. y: number;
  2419. /**
  2420. * Defines the third coordinates (on Z axis)
  2421. */
  2422. z: number;
  2423. private static _UpReadOnly;
  2424. private static _ZeroReadOnly;
  2425. /**
  2426. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2427. * @param x defines the first coordinates (on X axis)
  2428. * @param y defines the second coordinates (on Y axis)
  2429. * @param z defines the third coordinates (on Z axis)
  2430. */
  2431. constructor(
  2432. /**
  2433. * Defines the first coordinates (on X axis)
  2434. */
  2435. x?: number,
  2436. /**
  2437. * Defines the second coordinates (on Y axis)
  2438. */
  2439. y?: number,
  2440. /**
  2441. * Defines the third coordinates (on Z axis)
  2442. */
  2443. z?: number);
  2444. /**
  2445. * Creates a string representation of the Vector3
  2446. * @returns a string with the Vector3 coordinates.
  2447. */
  2448. toString(): string;
  2449. /**
  2450. * Gets the class name
  2451. * @returns the string "Vector3"
  2452. */
  2453. getClassName(): string;
  2454. /**
  2455. * Creates the Vector3 hash code
  2456. * @returns a number which tends to be unique between Vector3 instances
  2457. */
  2458. getHashCode(): number;
  2459. /**
  2460. * Creates an array containing three elements : the coordinates of the Vector3
  2461. * @returns a new array of numbers
  2462. */
  2463. asArray(): number[];
  2464. /**
  2465. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2466. * @param array defines the destination array
  2467. * @param index defines the offset in the destination array
  2468. * @returns the current Vector3
  2469. */
  2470. toArray(array: FloatArray, index?: number): Vector3;
  2471. /**
  2472. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2473. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2474. */
  2475. toQuaternion(): Quaternion;
  2476. /**
  2477. * Adds the given vector to the current Vector3
  2478. * @param otherVector defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Adds the given coordinates to the current Vector3
  2484. * @param x defines the x coordinate of the operand
  2485. * @param y defines the y coordinate of the operand
  2486. * @param z defines the z coordinate of the operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2490. /**
  2491. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the resulting Vector3
  2494. */
  2495. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Subtract the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2511. * @param otherVector defines the second operand
  2512. * @returns the resulting Vector3
  2513. */
  2514. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the resulting Vector3
  2528. */
  2529. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2532. * @param x defines the x coordinate of the operand
  2533. * @param y defines the y coordinate of the operand
  2534. * @param z defines the z coordinate of the operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2539. /**
  2540. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2541. * @returns a new Vector3
  2542. */
  2543. negate(): Vector3;
  2544. /**
  2545. * Negate this vector in place
  2546. * @returns this
  2547. */
  2548. negateInPlace(): Vector3;
  2549. /**
  2550. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2551. * @param result defines the Vector3 object where to store the result
  2552. * @returns the current Vector3
  2553. */
  2554. negateToRef(result: Vector3): Vector3;
  2555. /**
  2556. * Multiplies the Vector3 coordinates by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns the current updated Vector3
  2559. */
  2560. scaleInPlace(scale: number): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2563. * @param scale defines the multiplier factor
  2564. * @returns a new Vector3
  2565. */
  2566. scale(scale: number): Vector3;
  2567. /**
  2568. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2569. * @param scale defines the multiplier factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the current Vector3
  2572. */
  2573. scaleToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2576. * @param scale defines the scale factor
  2577. * @param result defines the Vector3 object where to store the result
  2578. * @returns the unmodified current Vector3
  2579. */
  2580. scaleAndAddToRef(scale: number, result: 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. * @returns the projected vector3
  2586. */
  2587. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2588. /**
  2589. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2590. * @param origin defines the origin of the projection ray
  2591. * @param plane defines the plane to project to
  2592. * @param result defines the Vector3 where to store the result
  2593. */
  2594. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2597. * @param otherVector defines the second operand
  2598. * @returns true if both vectors are equals
  2599. */
  2600. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2603. * @param otherVector defines the second operand
  2604. * @param epsilon defines the minimal distance to define values as equals
  2605. * @returns true if both vectors are distant less than epsilon
  2606. */
  2607. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2608. /**
  2609. * Returns true if the current Vector3 coordinates equals the given floats
  2610. * @param x defines the x coordinate of the operand
  2611. * @param y defines the y coordinate of the operand
  2612. * @param z defines the z coordinate of the operand
  2613. * @returns true if both vectors are equals
  2614. */
  2615. equalsToFloats(x: number, y: number, z: number): boolean;
  2616. /**
  2617. * Multiplies the current Vector3 coordinates by the given ones
  2618. * @param otherVector defines the second operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2624. * @param otherVector defines the second operand
  2625. * @returns the new Vector3
  2626. */
  2627. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2630. * @param otherVector defines the second operand
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the new Vector3
  2641. */
  2642. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2645. * @param otherVector defines the second operand
  2646. * @returns the new Vector3
  2647. */
  2648. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2651. * @param otherVector defines the second operand
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the current Vector3
  2654. */
  2655. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2656. /**
  2657. * Divides the current Vector3 coordinates by the given ones.
  2658. * @param otherVector defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. divideInPlace(otherVector: Vector3): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2670. * @param other defines the second operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2692. * Check if is non uniform within a certain amount of decimal places to account for this
  2693. * @param epsilon the amount the values can differ
  2694. * @returns if the the vector is non uniform to a certain number of decimal places
  2695. */
  2696. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2697. /**
  2698. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2699. */
  2700. get isNonUniform(): boolean;
  2701. /**
  2702. * Gets a new Vector3 from current Vector3 floored values
  2703. * @returns a new Vector3
  2704. */
  2705. floor(): Vector3;
  2706. /**
  2707. * Gets a new Vector3 from current Vector3 floored values
  2708. * @returns a new Vector3
  2709. */
  2710. fract(): Vector3;
  2711. /**
  2712. * Gets the length of the Vector3
  2713. * @returns the length of the Vector3
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Gets the squared length of the Vector3
  2718. * @returns squared length of the Vector3
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalize the current Vector3.
  2723. * Please note that this is an in place operation.
  2724. * @returns the current updated Vector3
  2725. */
  2726. normalize(): Vector3;
  2727. /**
  2728. * Reorders the x y z properties of the vector in place
  2729. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2730. * @returns the current updated vector
  2731. */
  2732. reorderInPlace(order: string): this;
  2733. /**
  2734. * Rotates the vector around 0,0,0 by a quaternion
  2735. * @param quaternion the rotation quaternion
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2740. /**
  2741. * Rotates a vector around a given point
  2742. * @param quaternion the rotation quaternion
  2743. * @param point the point to rotate around
  2744. * @param result vector to store the result
  2745. * @returns the resulting vector
  2746. */
  2747. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2748. /**
  2749. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2750. * The cross product is then orthogonal to both current and "other"
  2751. * @param other defines the right operand
  2752. * @returns the cross product
  2753. */
  2754. cross(other: Vector3): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 with the given input length.
  2757. * Please note that this is an in place operation.
  2758. * @param len the length of the vector
  2759. * @returns the current updated Vector3
  2760. */
  2761. normalizeFromLength(len: number): Vector3;
  2762. /**
  2763. * Normalize the current Vector3 to a new vector
  2764. * @returns the new Vector3
  2765. */
  2766. normalizeToNew(): Vector3;
  2767. /**
  2768. * Normalize the current Vector3 to the reference
  2769. * @param reference define the Vector3 to update
  2770. * @returns the updated Vector3
  2771. */
  2772. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2773. /**
  2774. * Creates a new Vector3 copied from the current Vector3
  2775. * @returns the new Vector3
  2776. */
  2777. clone(): Vector3;
  2778. /**
  2779. * Copies the given vector coordinates to the current Vector3 ones
  2780. * @param source defines the source Vector3
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. copyFromFloats(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given floats to the current Vector3 coordinates
  2794. * @param x defines the x coordinate of the operand
  2795. * @param y defines the y coordinate of the operand
  2796. * @param z defines the z coordinate of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. set(x: number, y: number, z: number): Vector3;
  2800. /**
  2801. * Copies the given float to the current Vector3 coordinates
  2802. * @param v defines the x, y and z coordinates of the operand
  2803. * @returns the current updated Vector3
  2804. */
  2805. setAll(v: number): Vector3;
  2806. /**
  2807. * Get the clip factor between two vectors
  2808. * @param vector0 defines the first operand
  2809. * @param vector1 defines the second operand
  2810. * @param axis defines the axis to use
  2811. * @param size defines the size along the axis
  2812. * @returns the clip factor
  2813. */
  2814. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2815. /**
  2816. * Get angle between two vectors
  2817. * @param vector0 angle between vector0 and vector1
  2818. * @param vector1 angle between vector0 and vector1
  2819. * @param normal direction of the normal
  2820. * @return the angle between vector0 and vector1
  2821. */
  2822. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. */
  2829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2830. /**
  2831. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @returns the new Vector3
  2835. * @deprecated Please use FromArray instead.
  2836. */
  2837. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given array
  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. */
  2844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2847. * @param array defines the source array
  2848. * @param offset defines the offset in the source array
  2849. * @param result defines the Vector3 where to store the result
  2850. * @deprecated Please use FromArrayToRef instead.
  2851. */
  2852. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2853. /**
  2854. * Sets the given vector "result" with the given floats.
  2855. * @param x defines the x coordinate of the source
  2856. * @param y defines the y coordinate of the source
  2857. * @param z defines the z coordinate of the source
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2863. * @returns a new empty Vector3
  2864. */
  2865. static Zero(): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2868. * @returns a new unit Vector3
  2869. */
  2870. static One(): Vector3;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2873. * @returns a new up Vector3
  2874. */
  2875. static Up(): Vector3;
  2876. /**
  2877. * Gets a up Vector3 that must not be updated
  2878. */
  2879. static get UpReadOnly(): DeepImmutable<Vector3>;
  2880. /**
  2881. * Gets a zero Vector3 that must not be updated
  2882. */
  2883. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2884. /**
  2885. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2886. * @returns a new down Vector3
  2887. */
  2888. static Down(): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Forward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2897. * @param rightHandedSystem is the scene right-handed (negative-z)
  2898. * @returns a new forward Vector3
  2899. */
  2900. static Backward(rightHandedSystem?: boolean): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2903. * @returns a new right Vector3
  2904. */
  2905. static Right(): Vector3;
  2906. /**
  2907. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2908. * @returns a new left Vector3
  2909. */
  2910. static Left(): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @returns the transformed Vector3
  2917. */
  2918. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2921. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2922. * @param vector defines the Vector3 to transform
  2923. * @param transformation defines the transformation matrix
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2929. * This method computes tranformed coordinates only, not transformed direction vectors
  2930. * @param x define the x coordinate of the source vector
  2931. * @param y define the y coordinate of the source vector
  2932. * @param z define the z coordinate of the source vector
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @returns the new Vector3
  2943. */
  2944. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param vector defines the Vector3 to transform
  2949. * @param transformation defines the transformation matrix
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2955. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2956. * @param x define the x coordinate of the source vector
  2957. * @param y define the y coordinate of the source vector
  2958. * @param z define the z coordinate of the source vector
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2965. * @param value1 defines the first control point
  2966. * @param value2 defines the second control point
  2967. * @param value3 defines the third control point
  2968. * @param value4 defines the fourth control point
  2969. * @param amount defines the amount on the spline to use
  2970. * @returns the new Vector3
  2971. */
  2972. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2973. /**
  2974. * 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"
  2975. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2976. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2977. * @param value defines the current value
  2978. * @param min defines the lower range value
  2979. * @param max defines the upper range value
  2980. * @returns the new Vector3
  2981. */
  2982. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * 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"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2993. /**
  2994. * Checks if a given vector is inside a specific range
  2995. * @param v defines the vector to test
  2996. * @param min defines the minimum range
  2997. * @param max defines the maximum range
  2998. */
  2999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3000. /**
  3001. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3002. * @param value1 defines the first control point
  3003. * @param tangent1 defines the first tangent vector
  3004. * @param value2 defines the second control point
  3005. * @param tangent2 defines the second tangent vector
  3006. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @returns the new Vector3
  3016. */
  3017. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3018. /**
  3019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3020. * @param start defines the start value
  3021. * @param end defines the end value
  3022. * @param amount max defines amount between both (between 0 and 1)
  3023. * @param result defines the Vector3 where to store the result
  3024. */
  3025. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3026. /**
  3027. * Returns the dot product (float) between the vectors "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the dot product
  3031. */
  3032. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3033. /**
  3034. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @returns the cross product
  3039. */
  3040. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Sets the given vector "result" with the cross product of "left" and "right"
  3043. * The cross product is then orthogonal to both "left" and "right"
  3044. * @param left defines the left operand
  3045. * @param right defines the right operand
  3046. * @param result defines the Vector3 where to store the result
  3047. */
  3048. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3049. /**
  3050. * Returns a new Vector3 as the normalization of the given vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @returns the new Vector3
  3053. */
  3054. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Sets the given vector "result" with the normalization of the given first vector
  3057. * @param vector defines the Vector3 to normalize
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Project a Vector3 onto screen space
  3063. * @param vector defines the Vector3 to project
  3064. * @param world defines the world matrix to use
  3065. * @param transform defines the transform (view x projection) matrix to use
  3066. * @param viewport defines the screen viewport to use
  3067. * @returns the new Vector3
  3068. */
  3069. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3070. /** @hidden */
  3071. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3072. /**
  3073. * Unproject from screen space to object space
  3074. * @param source defines the screen space Vector3 to use
  3075. * @param viewportWidth defines the current width of the viewport
  3076. * @param viewportHeight defines the current height of the viewport
  3077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3078. * @param transform defines the transform (view x projection) matrix to use
  3079. * @returns the new Vector3
  3080. */
  3081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param view defines the view matrix to use
  3089. * @param projection defines the projection matrix to use
  3090. * @returns the new Vector3
  3091. */
  3092. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3093. /**
  3094. * Unproject from screen space to object space
  3095. * @param source defines the screen space Vector3 to use
  3096. * @param viewportWidth defines the current width of the viewport
  3097. * @param viewportHeight defines the current height of the viewport
  3098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3099. * @param view defines the view matrix to use
  3100. * @param projection defines the projection matrix to use
  3101. * @param result defines the Vector3 where to store the result
  3102. */
  3103. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3104. /**
  3105. * Unproject from screen space to object space
  3106. * @param sourceX defines the screen space x coordinate to use
  3107. * @param sourceY defines the screen space y coordinate to use
  3108. * @param sourceZ defines the screen space z coordinate to use
  3109. * @param viewportWidth defines the current width of the viewport
  3110. * @param viewportHeight defines the current height of the viewport
  3111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3112. * @param view defines the view matrix to use
  3113. * @param projection defines the projection matrix to use
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3117. /**
  3118. * Gets the minimal 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 Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Gets the maximal coordinate values between two Vector3
  3126. * @param left defines the first operand
  3127. * @param right defines the second operand
  3128. * @returns the new Vector3
  3129. */
  3130. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3131. /**
  3132. * Returns the distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the distance
  3136. */
  3137. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns the squared distance between the vectors "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the squared distance
  3143. */
  3144. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3145. /**
  3146. * Returns a new Vector3 located at the center between "value1" and "value2"
  3147. * @param value1 defines the first operand
  3148. * @param value2 defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3155. * to something in order to rotate it from its local system to the given target system
  3156. * Note: axis1, axis2 and axis3 are normalized during this operation
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @returns a new Vector3
  3161. */
  3162. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3165. * @param axis1 defines the first axis
  3166. * @param axis2 defines the second axis
  3167. * @param axis3 defines the third axis
  3168. * @param ref defines the Vector3 where to store the result
  3169. */
  3170. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3171. }
  3172. /**
  3173. * Vector4 class created for EulerAngle class conversion to Quaternion
  3174. */
  3175. export class Vector4 {
  3176. /** x value of the vector */
  3177. x: number;
  3178. /** y value of the vector */
  3179. y: number;
  3180. /** z value of the vector */
  3181. z: number;
  3182. /** w value of the vector */
  3183. w: number;
  3184. /**
  3185. * Creates a Vector4 object from the given floats.
  3186. * @param x x value of the vector
  3187. * @param y y value of the vector
  3188. * @param z z value of the vector
  3189. * @param w w value of the vector
  3190. */
  3191. constructor(
  3192. /** x value of the vector */
  3193. x: number,
  3194. /** y value of the vector */
  3195. y: number,
  3196. /** z value of the vector */
  3197. z: number,
  3198. /** w value of the vector */
  3199. w: number);
  3200. /**
  3201. * Returns the string with the Vector4 coordinates.
  3202. * @returns a string containing all the vector values
  3203. */
  3204. toString(): string;
  3205. /**
  3206. * Returns the string "Vector4".
  3207. * @returns "Vector4"
  3208. */
  3209. getClassName(): string;
  3210. /**
  3211. * Returns the Vector4 hash code.
  3212. * @returns a unique hash code
  3213. */
  3214. getHashCode(): number;
  3215. /**
  3216. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3217. * @returns the resulting array
  3218. */
  3219. asArray(): number[];
  3220. /**
  3221. * Populates the given array from the given index with the Vector4 coordinates.
  3222. * @param array array to populate
  3223. * @param index index of the array to start at (default: 0)
  3224. * @returns the Vector4.
  3225. */
  3226. toArray(array: FloatArray, index?: number): Vector4;
  3227. /**
  3228. * Adds the given vector to the current Vector4.
  3229. * @param otherVector the vector to add
  3230. * @returns the updated Vector4.
  3231. */
  3232. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @returns the resulting vector
  3237. */
  3238. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3239. /**
  3240. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3241. * @param otherVector the vector to add
  3242. * @param result the vector to store the result
  3243. * @returns the current Vector4.
  3244. */
  3245. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3246. /**
  3247. * Subtract in place the given vector from the current Vector4.
  3248. * @param otherVector the vector to subtract
  3249. * @returns the updated Vector4.
  3250. */
  3251. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the new vector with the result
  3256. */
  3257. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3260. * @param otherVector the vector to subtract
  3261. * @param result the vector to store the result
  3262. * @returns the current Vector4.
  3263. */
  3264. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3265. /**
  3266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3267. */
  3268. /**
  3269. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3270. * @param x value to subtract
  3271. * @param y value to subtract
  3272. * @param z value to subtract
  3273. * @param w value to subtract
  3274. * @returns new vector containing the result
  3275. */
  3276. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3277. /**
  3278. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3279. * @param x value to subtract
  3280. * @param y value to subtract
  3281. * @param z value to subtract
  3282. * @param w value to subtract
  3283. * @param result the vector to store the result in
  3284. * @returns the current Vector4.
  3285. */
  3286. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3287. /**
  3288. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3289. * @returns a new vector with the negated values
  3290. */
  3291. negate(): Vector4;
  3292. /**
  3293. * Negate this vector in place
  3294. * @returns this
  3295. */
  3296. negateInPlace(): Vector4;
  3297. /**
  3298. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3299. * @param result defines the Vector3 object where to store the result
  3300. * @returns the current Vector4
  3301. */
  3302. negateToRef(result: Vector4): Vector4;
  3303. /**
  3304. * Multiplies the current Vector4 coordinates by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns the updated Vector4.
  3307. */
  3308. scaleInPlace(scale: number): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @returns a new vector with the result
  3313. */
  3314. scale(scale: number): Vector4;
  3315. /**
  3316. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3317. * @param scale the number to scale with
  3318. * @param result a vector to store the result in
  3319. * @returns the current Vector4.
  3320. */
  3321. scaleToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3324. * @param scale defines the scale factor
  3325. * @param result defines the Vector4 object where to store the result
  3326. * @returns the unmodified current Vector4
  3327. */
  3328. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3331. * @param otherVector the vector to compare against
  3332. * @returns true if they are equal
  3333. */
  3334. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3335. /**
  3336. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3337. * @param otherVector vector to compare against
  3338. * @param epsilon (Default: very small number)
  3339. * @returns true if they are equal
  3340. */
  3341. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3342. /**
  3343. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3344. * @param x x value to compare against
  3345. * @param y y value to compare against
  3346. * @param z z value to compare against
  3347. * @param w w value to compare against
  3348. * @returns true if equal
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3351. /**
  3352. * Multiplies in place the current Vector4 by the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns the updated Vector4.
  3355. */
  3356. multiplyInPlace(otherVector: Vector4): Vector4;
  3357. /**
  3358. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @returns resulting new vector
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3365. * @param otherVector vector to multiple with
  3366. * @param result vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3372. * @param x x value multiply with
  3373. * @param y y value multiply with
  3374. * @param z z value multiply with
  3375. * @param w w value multiply with
  3376. * @returns resulting new vector
  3377. */
  3378. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3379. /**
  3380. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @returns resulting new vector
  3383. */
  3384. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3387. * @param otherVector vector to devide with
  3388. * @param result vector to store the result
  3389. * @returns the current Vector4.
  3390. */
  3391. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3392. /**
  3393. * Divides the current Vector3 coordinates by the given ones.
  3394. * @param otherVector vector to devide with
  3395. * @returns the updated Vector3.
  3396. */
  3397. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3406. * @param other defines the second operand
  3407. * @returns the current updated Vector4
  3408. */
  3409. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Gets a new Vector4 from current Vector4 floored values
  3412. * @returns a new Vector4
  3413. */
  3414. floor(): Vector4;
  3415. /**
  3416. * Gets a new Vector4 from current Vector3 floored values
  3417. * @returns a new Vector4
  3418. */
  3419. fract(): Vector4;
  3420. /**
  3421. * Returns the Vector4 length (float).
  3422. * @returns the length
  3423. */
  3424. length(): number;
  3425. /**
  3426. * Returns the Vector4 squared length (float).
  3427. * @returns the length squared
  3428. */
  3429. lengthSquared(): number;
  3430. /**
  3431. * Normalizes in place the Vector4.
  3432. * @returns the updated Vector4.
  3433. */
  3434. normalize(): Vector4;
  3435. /**
  3436. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3437. * @returns this converted to a new vector3
  3438. */
  3439. toVector3(): Vector3;
  3440. /**
  3441. * Returns a new Vector4 copied from the current one.
  3442. * @returns the new cloned vector
  3443. */
  3444. clone(): Vector4;
  3445. /**
  3446. * Updates the current Vector4 with the given one coordinates.
  3447. * @param source the source vector to copy from
  3448. * @returns the updated Vector4.
  3449. */
  3450. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3451. /**
  3452. * Updates the current Vector4 coordinates with the given floats.
  3453. * @param x float to copy from
  3454. * @param y float to copy from
  3455. * @param z float to copy from
  3456. * @param w float to copy from
  3457. * @returns the updated Vector4.
  3458. */
  3459. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3460. /**
  3461. * Updates the current Vector4 coordinates with the given floats.
  3462. * @param x float to set from
  3463. * @param y float to set from
  3464. * @param z float to set from
  3465. * @param w float to set from
  3466. * @returns the updated Vector4.
  3467. */
  3468. set(x: number, y: number, z: number, w: number): Vector4;
  3469. /**
  3470. * Copies the given float to the current Vector3 coordinates
  3471. * @param v defines the x, y, z and w coordinates of the operand
  3472. * @returns the current updated Vector3
  3473. */
  3474. setAll(v: number): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set 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. * @returns the new vector
  3480. */
  3481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given array.
  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 FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" from the starting index of the given Float32Array.
  3491. * @param array the array to pull values from
  3492. * @param offset the offset into the array to start at
  3493. * @param result the vector to store the result in
  3494. */
  3495. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3496. /**
  3497. * Updates the given vector "result" coordinates from the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @param result the vector to the floats in
  3503. */
  3504. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3505. /**
  3506. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3507. * @returns the new vector
  3508. */
  3509. static Zero(): Vector4;
  3510. /**
  3511. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3512. * @returns the new vector
  3513. */
  3514. static One(): Vector4;
  3515. /**
  3516. * Returns a new normalized Vector4 from the given one.
  3517. * @param vector the vector to normalize
  3518. * @returns the vector
  3519. */
  3520. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the given vector "result" from the normalization of the given one.
  3523. * @param vector the vector to normalize
  3524. * @param result the vector to store the result in
  3525. */
  3526. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3527. /**
  3528. * Returns a vector with the minimum values from the left and right vectors
  3529. * @param left left vector to minimize
  3530. * @param right right vector to minimize
  3531. * @returns a new vector with the minimum of the left and right vector values
  3532. */
  3533. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns a vector with the maximum values from the left and right vectors
  3536. * @param left left vector to maximize
  3537. * @param right right vector to maximize
  3538. * @returns a new vector with the maximum of the left and right vector values
  3539. */
  3540. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3541. /**
  3542. * Returns the 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
  3546. */
  3547. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the distance between
  3551. * @param value2 value to calulate the distance between
  3552. * @return the distance between the two vectors squared
  3553. */
  3554. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3555. /**
  3556. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3557. * @param value1 value to calulate the center between
  3558. * @param value2 value to calulate the center between
  3559. * @return the center between the two vectors
  3560. */
  3561. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @returns the new vector
  3568. */
  3569. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param vector the vector to transform
  3574. * @param transformation the transformation matrix to apply
  3575. * @param result the vector to store the result in
  3576. */
  3577. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3578. /**
  3579. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3580. * This methods computes transformed normalized direction vectors only.
  3581. * @param x value to transform
  3582. * @param y value to transform
  3583. * @param z value to transform
  3584. * @param w value to transform
  3585. * @param transformation the transformation matrix to apply
  3586. * @param result the vector to store the results in
  3587. */
  3588. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3589. /**
  3590. * Creates a new Vector4 from a Vector3
  3591. * @param source defines the source data
  3592. * @param w defines the 4th component (default is 0)
  3593. * @returns a new Vector4
  3594. */
  3595. static FromVector3(source: Vector3, w?: number): Vector4;
  3596. }
  3597. /**
  3598. * Class used to store quaternion data
  3599. * @see https://en.wikipedia.org/wiki/Quaternion
  3600. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3601. */
  3602. export class Quaternion {
  3603. /** defines the first component (0 by default) */
  3604. x: number;
  3605. /** defines the second component (0 by default) */
  3606. y: number;
  3607. /** defines the third component (0 by default) */
  3608. z: number;
  3609. /** defines the fourth component (1.0 by default) */
  3610. w: number;
  3611. /**
  3612. * Creates a new Quaternion from the given floats
  3613. * @param x defines the first component (0 by default)
  3614. * @param y defines the second component (0 by default)
  3615. * @param z defines the third component (0 by default)
  3616. * @param w defines the fourth component (1.0 by default)
  3617. */
  3618. constructor(
  3619. /** defines the first component (0 by default) */
  3620. x?: number,
  3621. /** defines the second component (0 by default) */
  3622. y?: number,
  3623. /** defines the third component (0 by default) */
  3624. z?: number,
  3625. /** defines the fourth component (1.0 by default) */
  3626. w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5064. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /**
  7757. * Creates a cube texture from an array of image urls
  7758. * @param files defines an array of image urls
  7759. * @param scene defines the hosting scene
  7760. * @param noMipmap specifies if mip maps are not used
  7761. * @returns a cube texture
  7762. */
  7763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7764. /**
  7765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7766. * @param url defines the url of the prefiltered texture
  7767. * @param scene defines the scene the texture is attached to
  7768. * @param forcedExtension defines the extension of the file if different from the url
  7769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7770. * @return the prefiltered texture
  7771. */
  7772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7773. /**
  7774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7775. * as prefiltered data.
  7776. * @param rootUrl defines the url of the texture or the root name of the six images
  7777. * @param null defines the scene or engine the texture is attached to
  7778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7779. * @param noMipmap defines if mipmaps should be created or not
  7780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7782. * @param onError defines a callback triggered in case of error during load
  7783. * @param format defines the internal format to use for the texture once loaded
  7784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @return the cube texture
  7790. */
  7791. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7803. */
  7804. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7805. /**
  7806. * Delays loading of the cube texture
  7807. * @param forcedExtension defines the extension to use
  7808. */
  7809. delayLoad(forcedExtension?: string): void;
  7810. /**
  7811. * Returns the reflection texture matrix
  7812. * @returns the reflection texture matrix
  7813. */
  7814. getReflectionTextureMatrix(): Matrix;
  7815. /**
  7816. * Sets the reflection texture matrix
  7817. * @param value Reflection texture matrix
  7818. */
  7819. setReflectionTextureMatrix(value: Matrix): void;
  7820. /**
  7821. * Parses text to create a cube texture
  7822. * @param parsedTexture define the serialized text to read from
  7823. * @param scene defines the hosting scene
  7824. * @param rootUrl defines the root url of the cube texture
  7825. * @returns a cube texture
  7826. */
  7827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7828. /**
  7829. * Makes a clone, or deep copy, of the cube texture
  7830. * @returns a new cube texture
  7831. */
  7832. clone(): CubeTexture;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets the global Density value.
  7973. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets the highlights Density value.
  8019. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets the midtones Density value.
  8065. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets the shadows Density value.
  8111. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /**
  8519. * Defines the kind of connection point for node based material
  8520. */
  8521. export enum NodeMaterialBlockConnectionPointTypes {
  8522. /** Float */
  8523. Float = 1,
  8524. /** Int */
  8525. Int = 2,
  8526. /** Vector2 */
  8527. Vector2 = 4,
  8528. /** Vector3 */
  8529. Vector3 = 8,
  8530. /** Vector4 */
  8531. Vector4 = 16,
  8532. /** Color3 */
  8533. Color3 = 32,
  8534. /** Color4 */
  8535. Color4 = 64,
  8536. /** Matrix */
  8537. Matrix = 128,
  8538. /** Custom object */
  8539. Object = 256,
  8540. /** Detect type based on connection */
  8541. AutoDetect = 1024,
  8542. /** Output type that will be defined by input type */
  8543. BasedOnInput = 2048
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * Enum used to define the target of a block
  8549. */
  8550. export enum NodeMaterialBlockTargets {
  8551. /** Vertex shader */
  8552. Vertex = 1,
  8553. /** Fragment shader */
  8554. Fragment = 2,
  8555. /** Neutral */
  8556. Neutral = 4,
  8557. /** Vertex and Fragment */
  8558. VertexAndFragment = 3
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8564. */
  8565. export enum NodeMaterialBlockConnectionPointMode {
  8566. /** Value is an uniform */
  8567. Uniform = 0,
  8568. /** Value is a mesh attribute */
  8569. Attribute = 1,
  8570. /** Value is a varying between vertex and fragment shaders */
  8571. Varying = 2,
  8572. /** Mode is undefined */
  8573. Undefined = 3
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Enum used to define system values e.g. values automatically provided by the system
  8579. */
  8580. export enum NodeMaterialSystemValues {
  8581. /** World */
  8582. World = 1,
  8583. /** View */
  8584. View = 2,
  8585. /** Projection */
  8586. Projection = 3,
  8587. /** ViewProjection */
  8588. ViewProjection = 4,
  8589. /** WorldView */
  8590. WorldView = 5,
  8591. /** WorldViewProjection */
  8592. WorldViewProjection = 6,
  8593. /** CameraPosition */
  8594. CameraPosition = 7,
  8595. /** Fog Color */
  8596. FogColor = 8,
  8597. /** Delta time */
  8598. DeltaTime = 9
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Represents a camera frustum
  8624. */
  8625. export class Frustum {
  8626. /**
  8627. * Gets the planes representing the frustum
  8628. * @param transform matrix to be applied to the returned planes
  8629. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8630. */
  8631. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8632. /**
  8633. * Gets the near frustum plane transformed by the transform matrix
  8634. * @param transform transformation matrix to be applied to the resulting frustum plane
  8635. * @param frustumPlane the resuling frustum plane
  8636. */
  8637. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8638. /**
  8639. * Gets the far frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the left frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the right frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the top frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the bottom frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8670. * @param transform transformation matrix to be applied to the resulting frustum planes
  8671. * @param frustumPlanes the resuling frustum planes
  8672. */
  8673. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Interface for the size containing width and height
  8679. */
  8680. export interface ISize {
  8681. /**
  8682. * Width
  8683. */
  8684. width: number;
  8685. /**
  8686. * Heighht
  8687. */
  8688. height: number;
  8689. }
  8690. /**
  8691. * Size containing widht and height
  8692. */
  8693. export class Size implements ISize {
  8694. /**
  8695. * Width
  8696. */
  8697. width: number;
  8698. /**
  8699. * Height
  8700. */
  8701. height: number;
  8702. /**
  8703. * Creates a Size object from the given width and height (floats).
  8704. * @param width width of the new size
  8705. * @param height height of the new size
  8706. */
  8707. constructor(width: number, height: number);
  8708. /**
  8709. * Returns a string with the Size width and height
  8710. * @returns a string with the Size width and height
  8711. */
  8712. toString(): string;
  8713. /**
  8714. * "Size"
  8715. * @returns the string "Size"
  8716. */
  8717. getClassName(): string;
  8718. /**
  8719. * Returns the Size hash code.
  8720. * @returns a hash code for a unique width and height
  8721. */
  8722. getHashCode(): number;
  8723. /**
  8724. * Updates the current size from the given one.
  8725. * @param src the given size
  8726. */
  8727. copyFrom(src: Size): void;
  8728. /**
  8729. * Updates in place the current Size from the given floats.
  8730. * @param width width of the new size
  8731. * @param height height of the new size
  8732. * @returns the updated Size.
  8733. */
  8734. copyFromFloats(width: number, height: number): Size;
  8735. /**
  8736. * Updates in place the current Size from the given floats.
  8737. * @param width width to set
  8738. * @param height height to set
  8739. * @returns the updated Size.
  8740. */
  8741. set(width: number, height: number): Size;
  8742. /**
  8743. * Multiplies the width and height by numbers
  8744. * @param w factor to multiple the width by
  8745. * @param h factor to multiple the height by
  8746. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8747. */
  8748. multiplyByFloats(w: number, h: number): Size;
  8749. /**
  8750. * Clones the size
  8751. * @returns a new Size copied from the given one.
  8752. */
  8753. clone(): Size;
  8754. /**
  8755. * True if the current Size and the given one width and height are strictly equal.
  8756. * @param other the other size to compare against
  8757. * @returns True if the current Size and the given one width and height are strictly equal.
  8758. */
  8759. equals(other: Size): boolean;
  8760. /**
  8761. * The surface of the Size : width * height (float).
  8762. */
  8763. get surface(): number;
  8764. /**
  8765. * Create a new size of zero
  8766. * @returns a new Size set to (0.0, 0.0)
  8767. */
  8768. static Zero(): Size;
  8769. /**
  8770. * Sums the width and height of two sizes
  8771. * @param otherSize size to add to this size
  8772. * @returns a new Size set as the addition result of the current Size and the given one.
  8773. */
  8774. add(otherSize: Size): Size;
  8775. /**
  8776. * Subtracts the width and height of two
  8777. * @param otherSize size to subtract to this size
  8778. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8779. */
  8780. subtract(otherSize: Size): Size;
  8781. /**
  8782. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8783. * @param start starting size to lerp between
  8784. * @param end end size to lerp between
  8785. * @param amount amount to lerp between the start and end values
  8786. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8787. */
  8788. static Lerp(start: Size, end: Size, amount: number): Size;
  8789. }
  8790. }
  8791. declare module BABYLON {
  8792. /**
  8793. * Contains position and normal vectors for a vertex
  8794. */
  8795. export class PositionNormalVertex {
  8796. /** the position of the vertex (defaut: 0,0,0) */
  8797. position: Vector3;
  8798. /** the normal of the vertex (defaut: 0,1,0) */
  8799. normal: Vector3;
  8800. /**
  8801. * Creates a PositionNormalVertex
  8802. * @param position the position of the vertex (defaut: 0,0,0)
  8803. * @param normal the normal of the vertex (defaut: 0,1,0)
  8804. */
  8805. constructor(
  8806. /** the position of the vertex (defaut: 0,0,0) */
  8807. position?: Vector3,
  8808. /** the normal of the vertex (defaut: 0,1,0) */
  8809. normal?: Vector3);
  8810. /**
  8811. * Clones the PositionNormalVertex
  8812. * @returns the cloned PositionNormalVertex
  8813. */
  8814. clone(): PositionNormalVertex;
  8815. }
  8816. /**
  8817. * Contains position, normal and uv vectors for a vertex
  8818. */
  8819. export class PositionNormalTextureVertex {
  8820. /** the position of the vertex (defaut: 0,0,0) */
  8821. position: Vector3;
  8822. /** the normal of the vertex (defaut: 0,1,0) */
  8823. normal: Vector3;
  8824. /** the uv of the vertex (default: 0,0) */
  8825. uv: Vector2;
  8826. /**
  8827. * Creates a PositionNormalTextureVertex
  8828. * @param position the position of the vertex (defaut: 0,0,0)
  8829. * @param normal the normal of the vertex (defaut: 0,1,0)
  8830. * @param uv the uv of the vertex (default: 0,0)
  8831. */
  8832. constructor(
  8833. /** the position of the vertex (defaut: 0,0,0) */
  8834. position?: Vector3,
  8835. /** the normal of the vertex (defaut: 0,1,0) */
  8836. normal?: Vector3,
  8837. /** the uv of the vertex (default: 0,0) */
  8838. uv?: Vector2);
  8839. /**
  8840. * Clones the PositionNormalTextureVertex
  8841. * @returns the cloned PositionNormalTextureVertex
  8842. */
  8843. clone(): PositionNormalTextureVertex;
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Enum defining the type of animations supported by InputBlock
  8849. */
  8850. export enum AnimatedInputBlockTypes {
  8851. /** No animation */
  8852. None = 0,
  8853. /** Time based animation. Will only work for floats */
  8854. Time = 1
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * Interface describing all the common properties and methods a shadow light needs to implement.
  8860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8861. * as well as binding the different shadow properties to the effects.
  8862. */
  8863. export interface IShadowLight extends Light {
  8864. /**
  8865. * The light id in the scene (used in scene.findLighById for instance)
  8866. */
  8867. id: string;
  8868. /**
  8869. * The position the shdow will be casted from.
  8870. */
  8871. position: Vector3;
  8872. /**
  8873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8874. */
  8875. direction: Vector3;
  8876. /**
  8877. * The transformed position. Position of the light in world space taking parenting in account.
  8878. */
  8879. transformedPosition: Vector3;
  8880. /**
  8881. * The transformed direction. Direction of the light in world space taking parenting in account.
  8882. */
  8883. transformedDirection: Vector3;
  8884. /**
  8885. * The friendly name of the light in the scene.
  8886. */
  8887. name: string;
  8888. /**
  8889. * Defines the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. /**
  8893. * Defines the shadow projection clipping maximum z value.
  8894. */
  8895. shadowMaxZ: number;
  8896. /**
  8897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8899. */
  8900. computeTransformedInformation(): boolean;
  8901. /**
  8902. * Gets the scene the light belongs to.
  8903. * @returns The scene
  8904. */
  8905. getScene(): Scene;
  8906. /**
  8907. * Callback defining a custom Projection Matrix Builder.
  8908. * This can be used to override the default projection matrix computation.
  8909. */
  8910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. /**
  8920. * Gets the current depth scale used in ESM.
  8921. * @returns The scale
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /**
  8939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8942. */
  8943. getShadowDirection(faceIndex?: number): Vector3;
  8944. /**
  8945. * Gets the minZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the min for
  8947. * @returns the depth min z
  8948. */
  8949. getDepthMinZ(activeCamera: Camera): number;
  8950. /**
  8951. * Gets the maxZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the max for
  8953. * @returns the depth max z
  8954. */
  8955. getDepthMaxZ(activeCamera: Camera): number;
  8956. }
  8957. /**
  8958. * Base implementation IShadowLight
  8959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8960. */
  8961. export abstract class ShadowLight extends Light implements IShadowLight {
  8962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8963. protected _position: Vector3;
  8964. protected _setPosition(value: Vector3): void;
  8965. /**
  8966. * Sets the position the shadow will be casted from. Also use as the light position for both
  8967. * point and spot lights.
  8968. */
  8969. get position(): Vector3;
  8970. /**
  8971. * Sets the position the shadow will be casted from. Also use as the light position for both
  8972. * point and spot lights.
  8973. */
  8974. set position(value: Vector3);
  8975. protected _direction: Vector3;
  8976. protected _setDirection(value: Vector3): void;
  8977. /**
  8978. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8979. * Also use as the light direction on spot and directional lights.
  8980. */
  8981. get direction(): Vector3;
  8982. /**
  8983. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8984. * Also use as the light direction on spot and directional lights.
  8985. */
  8986. set direction(value: Vector3);
  8987. protected _shadowMinZ: number;
  8988. /**
  8989. * Gets the shadow projection clipping minimum z value.
  8990. */
  8991. get shadowMinZ(): number;
  8992. /**
  8993. * Sets the shadow projection clipping minimum z value.
  8994. */
  8995. set shadowMinZ(value: number);
  8996. protected _shadowMaxZ: number;
  8997. /**
  8998. * Sets the shadow projection clipping maximum z value.
  8999. */
  9000. get shadowMaxZ(): number;
  9001. /**
  9002. * Gets the shadow projection clipping maximum z value.
  9003. */
  9004. set shadowMaxZ(value: number);
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * The transformed position. Position of the light in world space taking parenting in account.
  9012. */
  9013. transformedPosition: Vector3;
  9014. /**
  9015. * The transformed direction. Direction of the light in world space taking parenting in account.
  9016. */
  9017. transformedDirection: Vector3;
  9018. private _needProjectionMatrixCompute;
  9019. /**
  9020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9022. */
  9023. computeTransformedInformation(): boolean;
  9024. /**
  9025. * Return the depth scale used for the shadow map.
  9026. * @returns the depth scale.
  9027. */
  9028. getDepthScale(): number;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Returns the ShadowLight absolute position in the World.
  9037. * @returns the position vector in world space
  9038. */
  9039. getAbsolutePosition(): Vector3;
  9040. /**
  9041. * Sets the ShadowLight direction toward the passed target.
  9042. * @param target The point to target in local space
  9043. * @returns the updated ShadowLight direction
  9044. */
  9045. setDirectionToTarget(target: Vector3): Vector3;
  9046. /**
  9047. * Returns the light rotation in euler definition.
  9048. * @returns the x y z rotation in local space.
  9049. */
  9050. getRotation(): Vector3;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /** @hidden */
  9066. _initCache(): void;
  9067. /** @hidden */
  9068. _isSynchronized(): boolean;
  9069. /**
  9070. * Computes the world matrix of the node
  9071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9072. * @returns the world matrix
  9073. */
  9074. computeWorldMatrix(force?: boolean): Matrix;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. /**
  9088. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9089. * @param matrix The materix to updated with the projection information
  9090. * @param viewMatrix The transform matrix of the light
  9091. * @param renderList The list of mesh to render in the map
  9092. * @returns The current light
  9093. */
  9094. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var packingFunctions: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var bayerDitherFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var shadowMapFragmentDeclaration: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var clipPlaneFragmentDeclaration: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var clipPlaneFragment: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapFragment: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var shadowMapVertexDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var clipPlaneVertexDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexNormalBias: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapVertexMetric: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var clipPlaneVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var shadowMapVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var depthBoxBlurPixelShader: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapFragmentSoftTransparentShadow: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /**
  9260. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9261. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9262. */
  9263. export class EffectFallbacks implements IEffectFallbacks {
  9264. private _defines;
  9265. private _currentRank;
  9266. private _maxRank;
  9267. private _mesh;
  9268. /**
  9269. * Removes the fallback from the bound mesh.
  9270. */
  9271. unBindMesh(): void;
  9272. /**
  9273. * Adds a fallback on the specified property.
  9274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9275. * @param define The name of the define in the shader
  9276. */
  9277. addFallback(rank: number, define: string): void;
  9278. /**
  9279. * Sets the mesh to use CPU skinning when needing to fallback.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param mesh The mesh to use the fallbacks.
  9282. */
  9283. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9284. /**
  9285. * Checks to see if more fallbacks are still availible.
  9286. */
  9287. get hasMoreFallbacks(): boolean;
  9288. /**
  9289. * Removes the defines that should be removed when falling back.
  9290. * @param currentDefines defines the current define statements for the shader.
  9291. * @param effect defines the current effect we try to compile
  9292. * @returns The resulting defines with defines of the current rank removed.
  9293. */
  9294. reduce(currentDefines: string, effect: Effect): string;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /**
  9299. * Interface used to define Action
  9300. */
  9301. export interface IAction {
  9302. /**
  9303. * Trigger for the action
  9304. */
  9305. trigger: number;
  9306. /** Options of the trigger */
  9307. triggerOptions: any;
  9308. /**
  9309. * Gets the trigger parameters
  9310. * @returns the trigger parameters
  9311. */
  9312. getTriggerParameter(): any;
  9313. /**
  9314. * Internal only - executes current action event
  9315. * @hidden
  9316. */
  9317. _executeCurrent(evt?: ActionEvent): void;
  9318. /**
  9319. * Serialize placeholder for child classes
  9320. * @param parent of child
  9321. * @returns the serialized object
  9322. */
  9323. serialize(parent: any): any;
  9324. /**
  9325. * Internal only
  9326. * @hidden
  9327. */
  9328. _prepare(): void;
  9329. /**
  9330. * Internal only - manager for action
  9331. * @hidden
  9332. */
  9333. _actionManager: AbstractActionManager;
  9334. /**
  9335. * Adds action to chain of actions, may be a DoNothingAction
  9336. * @param action defines the next action to execute
  9337. * @returns The action passed in
  9338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9339. */
  9340. then(action: IAction): IAction;
  9341. }
  9342. /**
  9343. * The action to be carried out following a trigger
  9344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9345. */
  9346. export class Action implements IAction {
  9347. /** the trigger, with or without parameters, for the action */
  9348. triggerOptions: any;
  9349. /**
  9350. * Trigger for the action
  9351. */
  9352. trigger: number;
  9353. /**
  9354. * Internal only - manager for action
  9355. * @hidden
  9356. */
  9357. _actionManager: ActionManager;
  9358. private _nextActiveAction;
  9359. private _child;
  9360. private _condition?;
  9361. private _triggerParameter;
  9362. /**
  9363. * An event triggered prior to action being executed.
  9364. */
  9365. onBeforeExecuteObservable: Observable<Action>;
  9366. /**
  9367. * Creates a new Action
  9368. * @param triggerOptions the trigger, with or without parameters, for the action
  9369. * @param condition an optional determinant of action
  9370. */
  9371. constructor(
  9372. /** the trigger, with or without parameters, for the action */
  9373. triggerOptions: any, condition?: Condition);
  9374. /**
  9375. * Internal only
  9376. * @hidden
  9377. */
  9378. _prepare(): void;
  9379. /**
  9380. * Gets the trigger parameters
  9381. * @returns the trigger parameters
  9382. */
  9383. getTriggerParameter(): any;
  9384. /**
  9385. * Internal only - executes current action event
  9386. * @hidden
  9387. */
  9388. _executeCurrent(evt?: ActionEvent): void;
  9389. /**
  9390. * Execute placeholder for child classes
  9391. * @param evt optional action event
  9392. */
  9393. execute(evt?: ActionEvent): void;
  9394. /**
  9395. * Skips to next active action
  9396. */
  9397. skipToNextActiveAction(): void;
  9398. /**
  9399. * Adds action to chain of actions, may be a DoNothingAction
  9400. * @param action defines the next action to execute
  9401. * @returns The action passed in
  9402. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9403. */
  9404. then(action: Action): Action;
  9405. /**
  9406. * Internal only
  9407. * @hidden
  9408. */
  9409. _getProperty(propertyPath: string): string;
  9410. /**
  9411. * Internal only
  9412. * @hidden
  9413. */
  9414. _getEffectiveTarget(target: any, propertyPath: string): any;
  9415. /**
  9416. * Serialize placeholder for child classes
  9417. * @param parent of child
  9418. * @returns the serialized object
  9419. */
  9420. serialize(parent: any): any;
  9421. /**
  9422. * Internal only called by serialize
  9423. * @hidden
  9424. */
  9425. protected _serialize(serializedAction: any, parent?: any): any;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. static _SerializeValueAsString: (value: any) => string;
  9431. /**
  9432. * Internal only
  9433. * @hidden
  9434. */
  9435. static _GetTargetProperty: (target: Node | Scene) => {
  9436. name: string;
  9437. targetType: string;
  9438. value: string;
  9439. };
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * A Condition applied to an Action
  9445. */
  9446. export class Condition {
  9447. /**
  9448. * Internal only - manager for action
  9449. * @hidden
  9450. */
  9451. _actionManager: ActionManager;
  9452. /**
  9453. * Internal only
  9454. * @hidden
  9455. */
  9456. _evaluationId: number;
  9457. /**
  9458. * Internal only
  9459. * @hidden
  9460. */
  9461. _currentResult: boolean;
  9462. /**
  9463. * Creates a new Condition
  9464. * @param actionManager the manager of the action the condition is applied to
  9465. */
  9466. constructor(actionManager: ActionManager);
  9467. /**
  9468. * Check if the current condition is valid
  9469. * @returns a boolean
  9470. */
  9471. isValid(): boolean;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _getProperty(propertyPath: string): string;
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _getEffectiveTarget(target: any, propertyPath: string): any;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @returns the serialized object
  9485. */
  9486. serialize(): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. protected _serialize(serializedCondition: any): any;
  9492. }
  9493. /**
  9494. * Defines specific conditional operators as extensions of Condition
  9495. */
  9496. export class ValueCondition extends Condition {
  9497. /** path to specify the property of the target the conditional operator uses */
  9498. propertyPath: string;
  9499. /** the value compared by the conditional operator against the current value of the property */
  9500. value: any;
  9501. /** the conditional operator, default ValueCondition.IsEqual */
  9502. operator: number;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. private static _IsEqual;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. private static _IsDifferent;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. private static _IsGreater;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. private static _IsLesser;
  9523. /**
  9524. * returns the number for IsEqual
  9525. */
  9526. static get IsEqual(): number;
  9527. /**
  9528. * Returns the number for IsDifferent
  9529. */
  9530. static get IsDifferent(): number;
  9531. /**
  9532. * Returns the number for IsGreater
  9533. */
  9534. static get IsGreater(): number;
  9535. /**
  9536. * Returns the number for IsLesser
  9537. */
  9538. static get IsLesser(): number;
  9539. /**
  9540. * Internal only The action manager for the condition
  9541. * @hidden
  9542. */
  9543. _actionManager: ActionManager;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. private _target;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. private _effectiveTarget;
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. private _property;
  9559. /**
  9560. * Creates a new ValueCondition
  9561. * @param actionManager manager for the action the condition applies to
  9562. * @param target for the action
  9563. * @param propertyPath path to specify the property of the target the conditional operator uses
  9564. * @param value the value compared by the conditional operator against the current value of the property
  9565. * @param operator the conditional operator, default ValueCondition.IsEqual
  9566. */
  9567. constructor(actionManager: ActionManager, target: any,
  9568. /** path to specify the property of the target the conditional operator uses */
  9569. propertyPath: string,
  9570. /** the value compared by the conditional operator against the current value of the property */
  9571. value: any,
  9572. /** the conditional operator, default ValueCondition.IsEqual */
  9573. operator?: number);
  9574. /**
  9575. * Compares the given value with the property value for the specified conditional operator
  9576. * @returns the result of the comparison
  9577. */
  9578. isValid(): boolean;
  9579. /**
  9580. * Serialize the ValueCondition into a JSON compatible object
  9581. * @returns serialization object
  9582. */
  9583. serialize(): any;
  9584. /**
  9585. * Gets the name of the conditional operator for the ValueCondition
  9586. * @param operator the conditional operator
  9587. * @returns the name
  9588. */
  9589. static GetOperatorName(operator: number): string;
  9590. }
  9591. /**
  9592. * Defines a predicate condition as an extension of Condition
  9593. */
  9594. export class PredicateCondition extends Condition {
  9595. /** defines the predicate function used to validate the condition */
  9596. predicate: () => boolean;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. /**
  9603. * Creates a new PredicateCondition
  9604. * @param actionManager manager for the action the condition applies to
  9605. * @param predicate defines the predicate function used to validate the condition
  9606. */
  9607. constructor(actionManager: ActionManager,
  9608. /** defines the predicate function used to validate the condition */
  9609. predicate: () => boolean);
  9610. /**
  9611. * @returns the validity of the predicate condition
  9612. */
  9613. isValid(): boolean;
  9614. }
  9615. /**
  9616. * Defines a state condition as an extension of Condition
  9617. */
  9618. export class StateCondition extends Condition {
  9619. /** Value to compare with target state */
  9620. value: string;
  9621. /**
  9622. * Internal only - manager for action
  9623. * @hidden
  9624. */
  9625. _actionManager: ActionManager;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. private _target;
  9631. /**
  9632. * Creates a new StateCondition
  9633. * @param actionManager manager for the action the condition applies to
  9634. * @param target of the condition
  9635. * @param value to compare with target state
  9636. */
  9637. constructor(actionManager: ActionManager, target: any,
  9638. /** Value to compare with target state */
  9639. value: string);
  9640. /**
  9641. * Gets a boolean indicating if the current condition is met
  9642. * @returns the validity of the state
  9643. */
  9644. isValid(): boolean;
  9645. /**
  9646. * Serialize the StateCondition into a JSON compatible object
  9647. * @returns serialization object
  9648. */
  9649. serialize(): any;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. /**
  9654. * This defines an action responsible to toggle a boolean once triggered.
  9655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9656. */
  9657. export class SwitchBooleanAction extends Action {
  9658. /**
  9659. * The path to the boolean property in the target object
  9660. */
  9661. propertyPath: string;
  9662. private _target;
  9663. private _effectiveTarget;
  9664. private _property;
  9665. /**
  9666. * Instantiate the action
  9667. * @param triggerOptions defines the trigger options
  9668. * @param target defines the object containing the boolean
  9669. * @param propertyPath defines the path to the boolean property in the target object
  9670. * @param condition defines the trigger related conditions
  9671. */
  9672. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9673. /** @hidden */
  9674. _prepare(): void;
  9675. /**
  9676. * Execute the action toggle the boolean value.
  9677. */
  9678. execute(): void;
  9679. /**
  9680. * Serializes the actions and its related information.
  9681. * @param parent defines the object to serialize in
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. }
  9686. /**
  9687. * This defines an action responsible to set a the state field of the target
  9688. * to a desired value once triggered.
  9689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9690. */
  9691. export class SetStateAction extends Action {
  9692. /**
  9693. * The value to store in the state field.
  9694. */
  9695. value: string;
  9696. private _target;
  9697. /**
  9698. * Instantiate the action
  9699. * @param triggerOptions defines the trigger options
  9700. * @param target defines the object containing the state property
  9701. * @param value defines the value to store in the state field
  9702. * @param condition defines the trigger related conditions
  9703. */
  9704. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9705. /**
  9706. * Execute the action and store the value on the target state property.
  9707. */
  9708. execute(): void;
  9709. /**
  9710. * Serializes the actions and its related information.
  9711. * @param parent defines the object to serialize in
  9712. * @returns the serialized object
  9713. */
  9714. serialize(parent: any): any;
  9715. }
  9716. /**
  9717. * This defines an action responsible to set a property of the target
  9718. * to a desired value once triggered.
  9719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9720. */
  9721. export class SetValueAction extends Action {
  9722. /**
  9723. * The path of the property to set in the target.
  9724. */
  9725. propertyPath: string;
  9726. /**
  9727. * The value to set in the property
  9728. */
  9729. value: any;
  9730. private _target;
  9731. private _effectiveTarget;
  9732. private _property;
  9733. /**
  9734. * Instantiate the action
  9735. * @param triggerOptions defines the trigger options
  9736. * @param target defines the object containing the property
  9737. * @param propertyPath defines the path of the property to set in the target
  9738. * @param value defines the value to set in the property
  9739. * @param condition defines the trigger related conditions
  9740. */
  9741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9742. /** @hidden */
  9743. _prepare(): void;
  9744. /**
  9745. * Execute the action and set the targetted property to the desired value.
  9746. */
  9747. execute(): void;
  9748. /**
  9749. * Serializes the actions and its related information.
  9750. * @param parent defines the object to serialize in
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. }
  9755. /**
  9756. * This defines an action responsible to increment the target value
  9757. * to a desired value once triggered.
  9758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class IncrementValueAction extends Action {
  9761. /**
  9762. * The path of the property to increment in the target.
  9763. */
  9764. propertyPath: string;
  9765. /**
  9766. * The value we should increment the property by.
  9767. */
  9768. value: any;
  9769. private _target;
  9770. private _effectiveTarget;
  9771. private _property;
  9772. /**
  9773. * Instantiate the action
  9774. * @param triggerOptions defines the trigger options
  9775. * @param target defines the object containing the property
  9776. * @param propertyPath defines the path of the property to increment in the target
  9777. * @param value defines the value value we should increment the property by
  9778. * @param condition defines the trigger related conditions
  9779. */
  9780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9781. /** @hidden */
  9782. _prepare(): void;
  9783. /**
  9784. * Execute the action and increment the target of the value amount.
  9785. */
  9786. execute(): void;
  9787. /**
  9788. * Serializes the actions and its related information.
  9789. * @param parent defines the object to serialize in
  9790. * @returns the serialized object
  9791. */
  9792. serialize(parent: any): any;
  9793. }
  9794. /**
  9795. * This defines an action responsible to start an animation once triggered.
  9796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9797. */
  9798. export class PlayAnimationAction extends Action {
  9799. /**
  9800. * Where the animation should start (animation frame)
  9801. */
  9802. from: number;
  9803. /**
  9804. * Where the animation should stop (animation frame)
  9805. */
  9806. to: number;
  9807. /**
  9808. * Define if the animation should loop or stop after the first play.
  9809. */
  9810. loop?: boolean;
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param from defines from where the animation should start (animation frame)
  9817. * @param end defines where the animation should stop (animation frame)
  9818. * @param loop defines if the animation should loop or stop after the first play
  9819. * @param condition defines the trigger related conditions
  9820. */
  9821. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9822. /** @hidden */
  9823. _prepare(): void;
  9824. /**
  9825. * Execute the action and play the animation.
  9826. */
  9827. execute(): void;
  9828. /**
  9829. * Serializes the actions and its related information.
  9830. * @param parent defines the object to serialize in
  9831. * @returns the serialized object
  9832. */
  9833. serialize(parent: any): any;
  9834. }
  9835. /**
  9836. * This defines an action responsible to stop an animation once triggered.
  9837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class StopAnimationAction extends Action {
  9840. private _target;
  9841. /**
  9842. * Instantiate the action
  9843. * @param triggerOptions defines the trigger options
  9844. * @param target defines the target animation or animation name
  9845. * @param condition defines the trigger related conditions
  9846. */
  9847. constructor(triggerOptions: any, target: any, condition?: Condition);
  9848. /** @hidden */
  9849. _prepare(): void;
  9850. /**
  9851. * Execute the action and stop the animation.
  9852. */
  9853. execute(): void;
  9854. /**
  9855. * Serializes the actions and its related information.
  9856. * @param parent defines the object to serialize in
  9857. * @returns the serialized object
  9858. */
  9859. serialize(parent: any): any;
  9860. }
  9861. /**
  9862. * This defines an action responsible that does nothing once triggered.
  9863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9864. */
  9865. export class DoNothingAction extends Action {
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions?: any, condition?: Condition);
  9872. /**
  9873. * Execute the action and do nothing.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to trigger several actions once triggered.
  9885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class CombineAction extends Action {
  9888. /**
  9889. * The list of aggregated animations to run.
  9890. */
  9891. children: Action[];
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param children defines the list of aggregated animations to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9899. /** @hidden */
  9900. _prepare(): void;
  9901. /**
  9902. * Execute the action and executes all the aggregated actions.
  9903. */
  9904. execute(evt: ActionEvent): void;
  9905. /**
  9906. * Serializes the actions and its related information.
  9907. * @param parent defines the object to serialize in
  9908. * @returns the serialized object
  9909. */
  9910. serialize(parent: any): any;
  9911. }
  9912. /**
  9913. * This defines an action responsible to run code (external event) once triggered.
  9914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9915. */
  9916. export class ExecuteCodeAction extends Action {
  9917. /**
  9918. * The callback function to run.
  9919. */
  9920. func: (evt: ActionEvent) => void;
  9921. /**
  9922. * Instantiate the action
  9923. * @param triggerOptions defines the trigger options
  9924. * @param func defines the callback function to run
  9925. * @param condition defines the trigger related conditions
  9926. */
  9927. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9928. /**
  9929. * Execute the action and run the attached code.
  9930. */
  9931. execute(evt: ActionEvent): void;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set the parent property of the target once triggered.
  9935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class SetParentAction extends Action {
  9938. private _parent;
  9939. private _target;
  9940. /**
  9941. * Instantiate the action
  9942. * @param triggerOptions defines the trigger options
  9943. * @param target defines the target containing the parent property
  9944. * @param parent defines from where the animation should start (animation frame)
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and set the parent property.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9965. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class ActionManager extends AbstractActionManager {
  9969. /**
  9970. * Nothing
  9971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9972. */
  9973. static readonly NothingTrigger: number;
  9974. /**
  9975. * On pick
  9976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9977. */
  9978. static readonly OnPickTrigger: number;
  9979. /**
  9980. * On left pick
  9981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9982. */
  9983. static readonly OnLeftPickTrigger: number;
  9984. /**
  9985. * On right pick
  9986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9987. */
  9988. static readonly OnRightPickTrigger: number;
  9989. /**
  9990. * On center pick
  9991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9992. */
  9993. static readonly OnCenterPickTrigger: number;
  9994. /**
  9995. * On pick down
  9996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9997. */
  9998. static readonly OnPickDownTrigger: number;
  9999. /**
  10000. * On double pick
  10001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10002. */
  10003. static readonly OnDoublePickTrigger: number;
  10004. /**
  10005. * On pick up
  10006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly OnPickUpTrigger: number;
  10009. /**
  10010. * On pick out.
  10011. * This trigger will only be raised if you also declared a OnPickDown
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickOutTrigger: number;
  10015. /**
  10016. * On long press
  10017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnLongPressTrigger: number;
  10020. /**
  10021. * On pointer over
  10022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPointerOverTrigger: number;
  10025. /**
  10026. * On pointer out
  10027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10028. */
  10029. static readonly OnPointerOutTrigger: number;
  10030. /**
  10031. * On every frame
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10033. */
  10034. static readonly OnEveryFrameTrigger: number;
  10035. /**
  10036. * On intersection enter
  10037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10038. */
  10039. static readonly OnIntersectionEnterTrigger: number;
  10040. /**
  10041. * On intersection exit
  10042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10043. */
  10044. static readonly OnIntersectionExitTrigger: number;
  10045. /**
  10046. * On key down
  10047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnKeyDownTrigger: number;
  10050. /**
  10051. * On key up
  10052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnKeyUpTrigger: number;
  10055. private _scene;
  10056. /**
  10057. * Creates a new action manager
  10058. * @param scene defines the hosting scene
  10059. */
  10060. constructor(scene: Scene);
  10061. /**
  10062. * Releases all associated resources
  10063. */
  10064. dispose(): void;
  10065. /**
  10066. * Gets hosting scene
  10067. * @returns the hosting scene
  10068. */
  10069. getScene(): Scene;
  10070. /**
  10071. * Does this action manager handles actions of any of the given triggers
  10072. * @param triggers defines the triggers to be tested
  10073. * @return a boolean indicating whether one (or more) of the triggers is handled
  10074. */
  10075. hasSpecificTriggers(triggers: number[]): boolean;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10078. * speed.
  10079. * @param triggerA defines the trigger to be tested
  10080. * @param triggerB defines the trigger to be tested
  10081. * @return a boolean indicating whether one (or more) of the triggers is handled
  10082. */
  10083. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10084. /**
  10085. * Does this action manager handles actions of a given trigger
  10086. * @param trigger defines the trigger to be tested
  10087. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10088. * @return whether the trigger is handled
  10089. */
  10090. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10091. /**
  10092. * Does this action manager has pointer triggers
  10093. */
  10094. get hasPointerTriggers(): boolean;
  10095. /**
  10096. * Does this action manager has pick triggers
  10097. */
  10098. get hasPickTriggers(): boolean;
  10099. /**
  10100. * Registers an action to this action manager
  10101. * @param action defines the action to be registered
  10102. * @return the action amended (prepared) after registration
  10103. */
  10104. registerAction(action: IAction): Nullable<IAction>;
  10105. /**
  10106. * Unregisters an action to this action manager
  10107. * @param action defines the action to be unregistered
  10108. * @return a boolean indicating whether the action has been unregistered
  10109. */
  10110. unregisterAction(action: IAction): Boolean;
  10111. /**
  10112. * Process a specific trigger
  10113. * @param trigger defines the trigger to process
  10114. * @param evt defines the event details to be processed
  10115. */
  10116. processTrigger(trigger: number, evt?: IActionEvent): void;
  10117. /** @hidden */
  10118. _getEffectiveTarget(target: any, propertyPath: string): any;
  10119. /** @hidden */
  10120. _getProperty(propertyPath: string): string;
  10121. /**
  10122. * Serialize this manager to a JSON object
  10123. * @param name defines the property name to store this manager
  10124. * @returns a JSON representation of this manager
  10125. */
  10126. serialize(name: string): any;
  10127. /**
  10128. * Creates a new ActionManager from a JSON data
  10129. * @param parsedActions defines the JSON data to read from
  10130. * @param object defines the hosting mesh
  10131. * @param scene defines the hosting scene
  10132. */
  10133. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10134. /**
  10135. * Get a trigger name by index
  10136. * @param trigger defines the trigger index
  10137. * @returns a trigger name
  10138. */
  10139. static GetTriggerName(trigger: number): string;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Class used to represent a sprite
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class Sprite implements IAnimatable {
  10148. /** defines the name */
  10149. name: string;
  10150. /** Gets or sets the current world position */
  10151. position: Vector3;
  10152. /** Gets or sets the main color */
  10153. color: Color4;
  10154. /** Gets or sets the width */
  10155. width: number;
  10156. /** Gets or sets the height */
  10157. height: number;
  10158. /** Gets or sets rotation angle */
  10159. angle: number;
  10160. /** Gets or sets the cell index in the sprite sheet */
  10161. cellIndex: number;
  10162. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10163. cellRef: string;
  10164. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10165. invertU: boolean;
  10166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10167. invertV: boolean;
  10168. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10169. disposeWhenFinishedAnimating: boolean;
  10170. /** Gets the list of attached animations */
  10171. animations: Nullable<Array<Animation>>;
  10172. /** Gets or sets a boolean indicating if the sprite can be picked */
  10173. isPickable: boolean;
  10174. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10175. useAlphaForPicking: boolean;
  10176. /** @hidden */
  10177. _xOffset: number;
  10178. /** @hidden */
  10179. _yOffset: number;
  10180. /** @hidden */
  10181. _xSize: number;
  10182. /** @hidden */
  10183. _ySize: number;
  10184. /**
  10185. * Gets or sets the associated action manager
  10186. */
  10187. actionManager: Nullable<ActionManager>;
  10188. /**
  10189. * An event triggered when the control has been disposed
  10190. */
  10191. onDisposeObservable: Observable<Sprite>;
  10192. private _animationStarted;
  10193. private _loopAnimation;
  10194. private _fromIndex;
  10195. private _toIndex;
  10196. private _delay;
  10197. private _direction;
  10198. private _manager;
  10199. private _time;
  10200. private _onAnimationEnd;
  10201. /**
  10202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10203. */
  10204. isVisible: boolean;
  10205. /**
  10206. * Gets or sets the sprite size
  10207. */
  10208. get size(): number;
  10209. set size(value: number);
  10210. /**
  10211. * Returns a boolean indicating if the animation is started
  10212. */
  10213. get animationStarted(): boolean;
  10214. /**
  10215. * Gets or sets the unique id of the sprite
  10216. */
  10217. uniqueId: number;
  10218. /**
  10219. * Gets the manager of this sprite
  10220. */
  10221. get manager(): ISpriteManager;
  10222. /**
  10223. * Creates a new Sprite
  10224. * @param name defines the name
  10225. * @param manager defines the manager
  10226. */
  10227. constructor(
  10228. /** defines the name */
  10229. name: string, manager: ISpriteManager);
  10230. /**
  10231. * Returns the string "Sprite"
  10232. * @returns "Sprite"
  10233. */
  10234. getClassName(): string;
  10235. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10236. get fromIndex(): number;
  10237. set fromIndex(value: number);
  10238. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10239. get toIndex(): number;
  10240. set toIndex(value: number);
  10241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10242. get loopAnimation(): boolean;
  10243. set loopAnimation(value: boolean);
  10244. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10245. get delay(): number;
  10246. set delay(value: number);
  10247. /**
  10248. * Starts an animation
  10249. * @param from defines the initial key
  10250. * @param to defines the end key
  10251. * @param loop defines if the animation must loop
  10252. * @param delay defines the start delay (in ms)
  10253. * @param onAnimationEnd defines a callback to call when animation ends
  10254. */
  10255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10256. /** Stops current animation (if any) */
  10257. stopAnimation(): void;
  10258. /** @hidden */
  10259. _animate(deltaTime: number): void;
  10260. /** Release associated resources */
  10261. dispose(): void;
  10262. /**
  10263. * Serializes the sprite to a JSON object
  10264. * @returns the JSON object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Parses a JSON object to create a new sprite
  10269. * @param parsedSprite The JSON object to parse
  10270. * @param manager defines the hosting manager
  10271. * @returns the new sprite
  10272. */
  10273. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Information about the result of picking within a scene
  10279. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10280. */
  10281. export class PickingInfo {
  10282. /** @hidden */
  10283. _pickingUnavailable: boolean;
  10284. /**
  10285. * If the pick collided with an object
  10286. */
  10287. hit: boolean;
  10288. /**
  10289. * Distance away where the pick collided
  10290. */
  10291. distance: number;
  10292. /**
  10293. * The location of pick collision
  10294. */
  10295. pickedPoint: Nullable<Vector3>;
  10296. /**
  10297. * The mesh corresponding the the pick collision
  10298. */
  10299. pickedMesh: Nullable<AbstractMesh>;
  10300. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10301. bu: number;
  10302. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10303. bv: number;
  10304. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10305. faceId: number;
  10306. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10307. subMeshFaceId: number;
  10308. /** Id of the the submesh that was picked */
  10309. subMeshId: number;
  10310. /** If a sprite was picked, this will be the sprite the pick collided with */
  10311. pickedSprite: Nullable<Sprite>;
  10312. /**
  10313. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10314. */
  10315. originMesh: Nullable<AbstractMesh>;
  10316. /**
  10317. * The ray that was used to perform the picking.
  10318. */
  10319. ray: Nullable<Ray>;
  10320. /**
  10321. * Gets the normal correspodning to the face the pick collided with
  10322. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10323. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10324. * @returns The normal correspodning to the face the pick collided with
  10325. */
  10326. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10327. /**
  10328. * Gets the texture coordinates of where the pick occured
  10329. * @returns the vector containing the coordnates of the texture
  10330. */
  10331. getTextureCoordinates(): Nullable<Vector2>;
  10332. }
  10333. }
  10334. declare module BABYLON {
  10335. /**
  10336. * Class representing a ray with position and direction
  10337. */
  10338. export class Ray {
  10339. /** origin point */
  10340. origin: Vector3;
  10341. /** direction */
  10342. direction: Vector3;
  10343. /** length of the ray */
  10344. length: number;
  10345. private static readonly TmpVector3;
  10346. private _tmpRay;
  10347. /**
  10348. * Creates a new ray
  10349. * @param origin origin point
  10350. * @param direction direction
  10351. * @param length length of the ray
  10352. */
  10353. constructor(
  10354. /** origin point */
  10355. origin: Vector3,
  10356. /** direction */
  10357. direction: Vector3,
  10358. /** length of the ray */
  10359. length?: number);
  10360. /**
  10361. * Checks if the ray intersects a box
  10362. * This does not account for the ray lenght by design to improve perfs.
  10363. * @param minimum bound of the box
  10364. * @param maximum bound of the box
  10365. * @param intersectionTreshold extra extend to be added to the box in all direction
  10366. * @returns if the box was hit
  10367. */
  10368. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10369. /**
  10370. * Checks if the ray intersects a box
  10371. * This does not account for the ray lenght by design to improve perfs.
  10372. * @param box the bounding box to check
  10373. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10374. * @returns if the box was hit
  10375. */
  10376. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10377. /**
  10378. * If the ray hits a sphere
  10379. * @param sphere the bounding sphere to check
  10380. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10381. * @returns true if it hits the sphere
  10382. */
  10383. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10384. /**
  10385. * If the ray hits a triange
  10386. * @param vertex0 triangle vertex
  10387. * @param vertex1 triangle vertex
  10388. * @param vertex2 triangle vertex
  10389. * @returns intersection information if hit
  10390. */
  10391. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10392. /**
  10393. * Checks if ray intersects a plane
  10394. * @param plane the plane to check
  10395. * @returns the distance away it was hit
  10396. */
  10397. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10398. /**
  10399. * Calculate the intercept of a ray on a given axis
  10400. * @param axis to check 'x' | 'y' | 'z'
  10401. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10402. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10403. */
  10404. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10405. /**
  10406. * Checks if ray intersects a mesh
  10407. * @param mesh the mesh to check
  10408. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10409. * @returns picking info of the intersecton
  10410. */
  10411. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10412. /**
  10413. * Checks if ray intersects a mesh
  10414. * @param meshes the meshes to check
  10415. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10416. * @param results array to store result in
  10417. * @returns Array of picking infos
  10418. */
  10419. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10420. private _comparePickingInfo;
  10421. private static smallnum;
  10422. private static rayl;
  10423. /**
  10424. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10425. * @param sega the first point of the segment to test the intersection against
  10426. * @param segb the second point of the segment to test the intersection against
  10427. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10428. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10429. */
  10430. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10431. /**
  10432. * Update the ray from viewport position
  10433. * @param x position
  10434. * @param y y position
  10435. * @param viewportWidth viewport width
  10436. * @param viewportHeight viewport height
  10437. * @param world world matrix
  10438. * @param view view matrix
  10439. * @param projection projection matrix
  10440. * @returns this ray updated
  10441. */
  10442. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10443. /**
  10444. * Creates a ray with origin and direction of 0,0,0
  10445. * @returns the new ray
  10446. */
  10447. static Zero(): Ray;
  10448. /**
  10449. * Creates a new ray from screen space and viewport
  10450. * @param x position
  10451. * @param y y position
  10452. * @param viewportWidth viewport width
  10453. * @param viewportHeight viewport height
  10454. * @param world world matrix
  10455. * @param view view matrix
  10456. * @param projection projection matrix
  10457. * @returns new ray
  10458. */
  10459. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10460. /**
  10461. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10462. * transformed to the given world matrix.
  10463. * @param origin The origin point
  10464. * @param end The end point
  10465. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10466. * @returns the new ray
  10467. */
  10468. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10469. /**
  10470. * Transforms a ray by a matrix
  10471. * @param ray ray to transform
  10472. * @param matrix matrix to apply
  10473. * @returns the resulting new ray
  10474. */
  10475. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10476. /**
  10477. * Transforms a ray by a matrix
  10478. * @param ray ray to transform
  10479. * @param matrix matrix to apply
  10480. * @param result ray to store result in
  10481. */
  10482. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10483. /**
  10484. * Unproject a ray from screen space to object space
  10485. * @param sourceX defines the screen space x coordinate to use
  10486. * @param sourceY defines the screen space y coordinate to use
  10487. * @param viewportWidth defines the current width of the viewport
  10488. * @param viewportHeight defines the current height of the viewport
  10489. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10490. * @param view defines the view matrix to use
  10491. * @param projection defines the projection matrix to use
  10492. */
  10493. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10494. }
  10495. /**
  10496. * Type used to define predicate used to select faces when a mesh intersection is detected
  10497. */
  10498. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10499. interface Scene {
  10500. /** @hidden */
  10501. _tempPickingRay: Nullable<Ray>;
  10502. /** @hidden */
  10503. _cachedRayForTransform: Ray;
  10504. /** @hidden */
  10505. _pickWithRayInverseMatrix: Matrix;
  10506. /** @hidden */
  10507. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10508. /** @hidden */
  10509. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10510. }
  10511. }
  10512. declare module BABYLON {
  10513. /**
  10514. * Groups all the scene component constants in one place to ease maintenance.
  10515. * @hidden
  10516. */
  10517. export class SceneComponentConstants {
  10518. static readonly NAME_EFFECTLAYER: string;
  10519. static readonly NAME_LAYER: string;
  10520. static readonly NAME_LENSFLARESYSTEM: string;
  10521. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10522. static readonly NAME_PARTICLESYSTEM: string;
  10523. static readonly NAME_GAMEPAD: string;
  10524. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10525. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10526. static readonly NAME_DEPTHRENDERER: string;
  10527. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10528. static readonly NAME_SPRITE: string;
  10529. static readonly NAME_OUTLINERENDERER: string;
  10530. static readonly NAME_PROCEDURALTEXTURE: string;
  10531. static readonly NAME_SHADOWGENERATOR: string;
  10532. static readonly NAME_OCTREE: string;
  10533. static readonly NAME_PHYSICSENGINE: string;
  10534. static readonly NAME_AUDIO: string;
  10535. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10536. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10539. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10541. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10543. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10546. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10548. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10549. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10550. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10553. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10554. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10555. static readonly STEP_AFTERRENDER_AUDIO: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10559. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10560. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10561. static readonly STEP_POINTERMOVE_SPRITE: number;
  10562. static readonly STEP_POINTERDOWN_SPRITE: number;
  10563. static readonly STEP_POINTERUP_SPRITE: number;
  10564. }
  10565. /**
  10566. * This represents a scene component.
  10567. *
  10568. * This is used to decouple the dependency the scene is having on the different workloads like
  10569. * layers, post processes...
  10570. */
  10571. export interface ISceneComponent {
  10572. /**
  10573. * The name of the component. Each component must have a unique name.
  10574. */
  10575. name: string;
  10576. /**
  10577. * The scene the component belongs to.
  10578. */
  10579. scene: Scene;
  10580. /**
  10581. * Register the component to one instance of a scene.
  10582. */
  10583. register(): void;
  10584. /**
  10585. * Rebuilds the elements related to this component in case of
  10586. * context lost for instance.
  10587. */
  10588. rebuild(): void;
  10589. /**
  10590. * Disposes the component and the associated ressources.
  10591. */
  10592. dispose(): void;
  10593. }
  10594. /**
  10595. * This represents a SERIALIZABLE scene component.
  10596. *
  10597. * This extends Scene Component to add Serialization methods on top.
  10598. */
  10599. export interface ISceneSerializableComponent extends ISceneComponent {
  10600. /**
  10601. * Adds all the elements from the container to the scene
  10602. * @param container the container holding the elements
  10603. */
  10604. addFromContainer(container: AbstractScene): void;
  10605. /**
  10606. * Removes all the elements in the container from the scene
  10607. * @param container contains the elements to remove
  10608. * @param dispose if the removed element should be disposed (default: false)
  10609. */
  10610. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10611. /**
  10612. * Serializes the component data to the specified json object
  10613. * @param serializationObject The object to serialize to
  10614. */
  10615. serialize(serializationObject: any): void;
  10616. }
  10617. /**
  10618. * Strong typing of a Mesh related stage step action
  10619. */
  10620. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10621. /**
  10622. * Strong typing of a Evaluate Sub Mesh related stage step action
  10623. */
  10624. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10625. /**
  10626. * Strong typing of a Active Mesh related stage step action
  10627. */
  10628. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10629. /**
  10630. * Strong typing of a Camera related stage step action
  10631. */
  10632. export type CameraStageAction = (camera: Camera) => void;
  10633. /**
  10634. * Strong typing of a Camera Frame buffer related stage step action
  10635. */
  10636. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10637. /**
  10638. * Strong typing of a Render Target related stage step action
  10639. */
  10640. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10641. /**
  10642. * Strong typing of a RenderingGroup related stage step action
  10643. */
  10644. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10645. /**
  10646. * Strong typing of a Mesh Render related stage step action
  10647. */
  10648. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10649. /**
  10650. * Strong typing of a simple stage step action
  10651. */
  10652. export type SimpleStageAction = () => void;
  10653. /**
  10654. * Strong typing of a render target action.
  10655. */
  10656. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10657. /**
  10658. * Strong typing of a pointer move action.
  10659. */
  10660. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10661. /**
  10662. * Strong typing of a pointer up/down action.
  10663. */
  10664. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10665. /**
  10666. * Representation of a stage in the scene (Basically a list of ordered steps)
  10667. * @hidden
  10668. */
  10669. export class Stage<T extends Function> extends Array<{
  10670. index: number;
  10671. component: ISceneComponent;
  10672. action: T;
  10673. }> {
  10674. /**
  10675. * Hide ctor from the rest of the world.
  10676. * @param items The items to add.
  10677. */
  10678. private constructor();
  10679. /**
  10680. * Creates a new Stage.
  10681. * @returns A new instance of a Stage
  10682. */
  10683. static Create<T extends Function>(): Stage<T>;
  10684. /**
  10685. * Registers a step in an ordered way in the targeted stage.
  10686. * @param index Defines the position to register the step in
  10687. * @param component Defines the component attached to the step
  10688. * @param action Defines the action to launch during the step
  10689. */
  10690. registerStep(index: number, component: ISceneComponent, action: T): void;
  10691. /**
  10692. * Clears all the steps from the stage.
  10693. */
  10694. clear(): void;
  10695. }
  10696. }
  10697. declare module BABYLON {
  10698. interface Scene {
  10699. /** @hidden */
  10700. _pointerOverSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _pickedDownSprite: Nullable<Sprite>;
  10703. /** @hidden */
  10704. _tempSpritePickingRay: Nullable<Ray>;
  10705. /**
  10706. * All of the sprite managers added to this scene
  10707. * @see http://doc.babylonjs.com/babylon101/sprites
  10708. */
  10709. spriteManagers: Array<ISpriteManager>;
  10710. /**
  10711. * An event triggered when sprites rendering is about to start
  10712. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10713. */
  10714. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10715. /**
  10716. * An event triggered when sprites rendering is done
  10717. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10718. */
  10719. onAfterSpritesRenderingObservable: Observable<Scene>;
  10720. /** @hidden */
  10721. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10722. /** Launch a ray to try to pick a sprite in the scene
  10723. * @param x position on screen
  10724. * @param y position on screen
  10725. * @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
  10726. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10727. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10728. * @returns a PickingInfo
  10729. */
  10730. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10731. /** Use the given ray to pick a sprite in the scene
  10732. * @param ray The ray (in world space) to use to pick meshes
  10733. * @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
  10734. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10735. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10736. * @returns a PickingInfo
  10737. */
  10738. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10739. /** @hidden */
  10740. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10741. /** Launch a ray to try to pick sprites in the scene
  10742. * @param x position on screen
  10743. * @param y position on screen
  10744. * @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
  10745. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10746. * @returns a PickingInfo array
  10747. */
  10748. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10749. /** Use the given ray to pick sprites in the scene
  10750. * @param ray The ray (in world space) to use to pick meshes
  10751. * @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
  10752. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10753. * @returns a PickingInfo array
  10754. */
  10755. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10756. /**
  10757. * Force the sprite under the pointer
  10758. * @param sprite defines the sprite to use
  10759. */
  10760. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10761. /**
  10762. * Gets the sprite under the pointer
  10763. * @returns a Sprite or null if no sprite is under the pointer
  10764. */
  10765. getPointerOverSprite(): Nullable<Sprite>;
  10766. }
  10767. /**
  10768. * Defines the sprite scene component responsible to manage sprites
  10769. * in a given scene.
  10770. */
  10771. export class SpriteSceneComponent implements ISceneComponent {
  10772. /**
  10773. * The component name helpfull to identify the component in the list of scene components.
  10774. */
  10775. readonly name: string;
  10776. /**
  10777. * The scene the component belongs to.
  10778. */
  10779. scene: Scene;
  10780. /** @hidden */
  10781. private _spritePredicate;
  10782. /**
  10783. * Creates a new instance of the component for the given scene
  10784. * @param scene Defines the scene to register the component in
  10785. */
  10786. constructor(scene: Scene);
  10787. /**
  10788. * Registers the component in a given scene
  10789. */
  10790. register(): void;
  10791. /**
  10792. * Rebuilds the elements related to this component in case of
  10793. * context lost for instance.
  10794. */
  10795. rebuild(): void;
  10796. /**
  10797. * Disposes the component and the associated ressources.
  10798. */
  10799. dispose(): void;
  10800. private _pickSpriteButKeepRay;
  10801. private _pointerMove;
  10802. private _pointerDown;
  10803. private _pointerUp;
  10804. }
  10805. }
  10806. declare module BABYLON {
  10807. /** @hidden */
  10808. export var fogFragmentDeclaration: {
  10809. name: string;
  10810. shader: string;
  10811. };
  10812. }
  10813. declare module BABYLON {
  10814. /** @hidden */
  10815. export var fogFragment: {
  10816. name: string;
  10817. shader: string;
  10818. };
  10819. }
  10820. declare module BABYLON {
  10821. /** @hidden */
  10822. export var spritesPixelShader: {
  10823. name: string;
  10824. shader: string;
  10825. };
  10826. }
  10827. declare module BABYLON {
  10828. /** @hidden */
  10829. export var fogVertexDeclaration: {
  10830. name: string;
  10831. shader: string;
  10832. };
  10833. }
  10834. declare module BABYLON {
  10835. /** @hidden */
  10836. export var spritesVertexShader: {
  10837. name: string;
  10838. shader: string;
  10839. };
  10840. }
  10841. declare module BABYLON {
  10842. /**
  10843. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10844. */
  10845. export interface ISpriteManager extends IDisposable {
  10846. /**
  10847. * Gets manager's name
  10848. */
  10849. name: string;
  10850. /**
  10851. * Restricts the camera to viewing objects with the same layerMask.
  10852. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10853. */
  10854. layerMask: number;
  10855. /**
  10856. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10857. */
  10858. isPickable: boolean;
  10859. /**
  10860. * Gets the hosting scene
  10861. */
  10862. scene: Scene;
  10863. /**
  10864. * Specifies the rendering group id for this mesh (0 by default)
  10865. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10866. */
  10867. renderingGroupId: number;
  10868. /**
  10869. * Defines the list of sprites managed by the manager.
  10870. */
  10871. sprites: Array<Sprite>;
  10872. /**
  10873. * Gets or sets the spritesheet texture
  10874. */
  10875. texture: Texture;
  10876. /** Defines the default width of a cell in the spritesheet */
  10877. cellWidth: number;
  10878. /** Defines the default height of a cell in the spritesheet */
  10879. cellHeight: number;
  10880. /**
  10881. * Tests the intersection of a sprite with a specific ray.
  10882. * @param ray The ray we are sending to test the collision
  10883. * @param camera The camera space we are sending rays in
  10884. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10885. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10886. * @returns picking info or null.
  10887. */
  10888. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10889. /**
  10890. * Intersects the sprites with a ray
  10891. * @param ray defines the ray to intersect with
  10892. * @param camera defines the current active camera
  10893. * @param predicate defines a predicate used to select candidate sprites
  10894. * @returns null if no hit or a PickingInfo array
  10895. */
  10896. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10897. /**
  10898. * Renders the list of sprites on screen.
  10899. */
  10900. render(): void;
  10901. }
  10902. /**
  10903. * Class used to manage multiple sprites on the same spritesheet
  10904. * @see http://doc.babylonjs.com/babylon101/sprites
  10905. */
  10906. export class SpriteManager implements ISpriteManager {
  10907. /** defines the manager's name */
  10908. name: string;
  10909. /** Define the Url to load snippets */
  10910. static SnippetUrl: string;
  10911. /** Snippet ID if the manager was created from the snippet server */
  10912. snippetId: string;
  10913. /** Gets the list of sprites */
  10914. sprites: Sprite[];
  10915. /** Gets or sets the rendering group id (0 by default) */
  10916. renderingGroupId: number;
  10917. /** Gets or sets camera layer mask */
  10918. layerMask: number;
  10919. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10920. fogEnabled: boolean;
  10921. /** Gets or sets a boolean indicating if the sprites are pickable */
  10922. isPickable: boolean;
  10923. /** Defines the default width of a cell in the spritesheet */
  10924. cellWidth: number;
  10925. /** Defines the default height of a cell in the spritesheet */
  10926. cellHeight: number;
  10927. /** Associative array from JSON sprite data file */
  10928. private _cellData;
  10929. /** Array of sprite names from JSON sprite data file */
  10930. private _spriteMap;
  10931. /** True when packed cell data from JSON file is ready*/
  10932. private _packedAndReady;
  10933. private _textureContent;
  10934. /**
  10935. * An event triggered when the manager is disposed.
  10936. */
  10937. onDisposeObservable: Observable<SpriteManager>;
  10938. private _onDisposeObserver;
  10939. /**
  10940. * Callback called when the manager is disposed
  10941. */
  10942. set onDispose(callback: () => void);
  10943. private _capacity;
  10944. private _fromPacked;
  10945. private _spriteTexture;
  10946. private _epsilon;
  10947. private _scene;
  10948. private _vertexData;
  10949. private _buffer;
  10950. private _vertexBuffers;
  10951. private _indexBuffer;
  10952. private _effectBase;
  10953. private _effectFog;
  10954. /**
  10955. * Gets or sets the unique id of the sprite
  10956. */
  10957. uniqueId: number;
  10958. /**
  10959. * Gets the array of sprites
  10960. */
  10961. get children(): Sprite[];
  10962. /**
  10963. * Gets the hosting scene
  10964. */
  10965. get scene(): Scene;
  10966. /**
  10967. * Gets the capacity of the manager
  10968. */
  10969. get capacity(): number;
  10970. /**
  10971. * Gets or sets the spritesheet texture
  10972. */
  10973. get texture(): Texture;
  10974. set texture(value: Texture);
  10975. private _blendMode;
  10976. /**
  10977. * Blend mode use to render the particle, it can be any of
  10978. * the static Constants.ALPHA_x properties provided in this class.
  10979. * Default value is Constants.ALPHA_COMBINE
  10980. */
  10981. get blendMode(): number;
  10982. set blendMode(blendMode: number);
  10983. /** Disables writing to the depth buffer when rendering the sprites.
  10984. * It can be handy to disable depth writing when using textures without alpha channel
  10985. * and setting some specific blend modes.
  10986. */
  10987. disableDepthWrite: boolean;
  10988. /**
  10989. * Creates a new sprite manager
  10990. * @param name defines the manager's name
  10991. * @param imgUrl defines the sprite sheet url
  10992. * @param capacity defines the maximum allowed number of sprites
  10993. * @param cellSize defines the size of a sprite cell
  10994. * @param scene defines the hosting scene
  10995. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10996. * @param samplingMode defines the smapling mode to use with spritesheet
  10997. * @param fromPacked set to false; do not alter
  10998. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10999. */
  11000. constructor(
  11001. /** defines the manager's name */
  11002. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11003. /**
  11004. * Returns the string "SpriteManager"
  11005. * @returns "SpriteManager"
  11006. */
  11007. getClassName(): string;
  11008. private _makePacked;
  11009. private _appendSpriteVertex;
  11010. private _checkTextureAlpha;
  11011. /**
  11012. * Intersects the sprites with a ray
  11013. * @param ray defines the ray to intersect with
  11014. * @param camera defines the current active camera
  11015. * @param predicate defines a predicate used to select candidate sprites
  11016. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11017. * @returns null if no hit or a PickingInfo
  11018. */
  11019. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11020. /**
  11021. * Intersects the sprites with a ray
  11022. * @param ray defines the ray to intersect with
  11023. * @param camera defines the current active camera
  11024. * @param predicate defines a predicate used to select candidate sprites
  11025. * @returns null if no hit or a PickingInfo array
  11026. */
  11027. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11028. /**
  11029. * Render all child sprites
  11030. */
  11031. render(): void;
  11032. /**
  11033. * Release associated resources
  11034. */
  11035. dispose(): void;
  11036. /**
  11037. * Serializes the sprite manager to a JSON object
  11038. * @param serializeTexture defines if the texture must be serialized as well
  11039. * @returns the JSON object
  11040. */
  11041. serialize(serializeTexture?: boolean): any;
  11042. /**
  11043. * Parses a JSON object to create a new sprite manager.
  11044. * @param parsedManager The JSON object to parse
  11045. * @param scene The scene to create the sprite managerin
  11046. * @param rootUrl The root url to use to load external dependencies like texture
  11047. * @returns the new sprite manager
  11048. */
  11049. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11050. /**
  11051. * Creates a sprite manager from a snippet saved in a remote file
  11052. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11053. * @param url defines the url to load from
  11054. * @param scene defines the hosting scene
  11055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11056. * @returns a promise that will resolve to the new sprite manager
  11057. */
  11058. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11059. /**
  11060. * Creates a sprite manager from a snippet saved by the sprite editor
  11061. * @param snippetId defines the snippet to load
  11062. * @param scene defines the hosting scene
  11063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11064. * @returns a promise that will resolve to the new sprite manager
  11065. */
  11066. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11067. }
  11068. }
  11069. declare module BABYLON {
  11070. /** Interface used by value gradients (color, factor, ...) */
  11071. export interface IValueGradient {
  11072. /**
  11073. * Gets or sets the gradient value (between 0 and 1)
  11074. */
  11075. gradient: number;
  11076. }
  11077. /** Class used to store color4 gradient */
  11078. export class ColorGradient implements IValueGradient {
  11079. /**
  11080. * Gets or sets the gradient value (between 0 and 1)
  11081. */
  11082. gradient: number;
  11083. /**
  11084. * Gets or sets first associated color
  11085. */
  11086. color1: Color4;
  11087. /**
  11088. * Gets or sets second associated color
  11089. */
  11090. color2?: Color4 | undefined;
  11091. /**
  11092. * Creates a new color4 gradient
  11093. * @param gradient gets or sets the gradient value (between 0 and 1)
  11094. * @param color1 gets or sets first associated color
  11095. * @param color2 gets or sets first second color
  11096. */
  11097. constructor(
  11098. /**
  11099. * Gets or sets the gradient value (between 0 and 1)
  11100. */
  11101. gradient: number,
  11102. /**
  11103. * Gets or sets first associated color
  11104. */
  11105. color1: Color4,
  11106. /**
  11107. * Gets or sets second associated color
  11108. */
  11109. color2?: Color4 | undefined);
  11110. /**
  11111. * Will get a color picked randomly between color1 and color2.
  11112. * If color2 is undefined then color1 will be used
  11113. * @param result defines the target Color4 to store the result in
  11114. */
  11115. getColorToRef(result: Color4): void;
  11116. }
  11117. /** Class used to store color 3 gradient */
  11118. export class Color3Gradient implements IValueGradient {
  11119. /**
  11120. * Gets or sets the gradient value (between 0 and 1)
  11121. */
  11122. gradient: number;
  11123. /**
  11124. * Gets or sets the associated color
  11125. */
  11126. color: Color3;
  11127. /**
  11128. * Creates a new color3 gradient
  11129. * @param gradient gets or sets the gradient value (between 0 and 1)
  11130. * @param color gets or sets associated color
  11131. */
  11132. constructor(
  11133. /**
  11134. * Gets or sets the gradient value (between 0 and 1)
  11135. */
  11136. gradient: number,
  11137. /**
  11138. * Gets or sets the associated color
  11139. */
  11140. color: Color3);
  11141. }
  11142. /** Class used to store factor gradient */
  11143. export class FactorGradient implements IValueGradient {
  11144. /**
  11145. * Gets or sets the gradient value (between 0 and 1)
  11146. */
  11147. gradient: number;
  11148. /**
  11149. * Gets or sets first associated factor
  11150. */
  11151. factor1: number;
  11152. /**
  11153. * Gets or sets second associated factor
  11154. */
  11155. factor2?: number | undefined;
  11156. /**
  11157. * Creates a new factor gradient
  11158. * @param gradient gets or sets the gradient value (between 0 and 1)
  11159. * @param factor1 gets or sets first associated factor
  11160. * @param factor2 gets or sets second associated factor
  11161. */
  11162. constructor(
  11163. /**
  11164. * Gets or sets the gradient value (between 0 and 1)
  11165. */
  11166. gradient: number,
  11167. /**
  11168. * Gets or sets first associated factor
  11169. */
  11170. factor1: number,
  11171. /**
  11172. * Gets or sets second associated factor
  11173. */
  11174. factor2?: number | undefined);
  11175. /**
  11176. * Will get a number picked randomly between factor1 and factor2.
  11177. * If factor2 is undefined then factor1 will be used
  11178. * @returns the picked number
  11179. */
  11180. getFactor(): number;
  11181. }
  11182. /**
  11183. * Helper used to simplify some generic gradient tasks
  11184. */
  11185. export class GradientHelper {
  11186. /**
  11187. * Gets the current gradient from an array of IValueGradient
  11188. * @param ratio defines the current ratio to get
  11189. * @param gradients defines the array of IValueGradient
  11190. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11191. */
  11192. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11193. }
  11194. }
  11195. declare module BABYLON {
  11196. interface ThinEngine {
  11197. /**
  11198. * Creates a dynamic texture
  11199. * @param width defines the width of the texture
  11200. * @param height defines the height of the texture
  11201. * @param generateMipMaps defines if the engine should generate the mip levels
  11202. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11203. * @returns the dynamic texture inside an InternalTexture
  11204. */
  11205. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11206. /**
  11207. * Update the content of a dynamic texture
  11208. * @param texture defines the texture to update
  11209. * @param canvas defines the canvas containing the source
  11210. * @param invertY defines if data must be stored with Y axis inverted
  11211. * @param premulAlpha defines if alpha is stored as premultiplied
  11212. * @param format defines the format of the data
  11213. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11214. */
  11215. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11216. }
  11217. }
  11218. declare module BABYLON {
  11219. /**
  11220. * Helper class used to generate a canvas to manipulate images
  11221. */
  11222. export class CanvasGenerator {
  11223. /**
  11224. * Create a new canvas (or offscreen canvas depending on the context)
  11225. * @param width defines the expected width
  11226. * @param height defines the expected height
  11227. * @return a new canvas or offscreen canvas
  11228. */
  11229. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11230. }
  11231. }
  11232. declare module BABYLON {
  11233. /**
  11234. * A class extending Texture allowing drawing on a texture
  11235. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11236. */
  11237. export class DynamicTexture extends Texture {
  11238. private _generateMipMaps;
  11239. private _canvas;
  11240. private _context;
  11241. /**
  11242. * Creates a DynamicTexture
  11243. * @param name defines the name of the texture
  11244. * @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
  11245. * @param scene defines the scene where you want the texture
  11246. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11247. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11248. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11249. */
  11250. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11251. /**
  11252. * Get the current class name of the texture useful for serialization or dynamic coding.
  11253. * @returns "DynamicTexture"
  11254. */
  11255. getClassName(): string;
  11256. /**
  11257. * Gets the current state of canRescale
  11258. */
  11259. get canRescale(): boolean;
  11260. private _recreate;
  11261. /**
  11262. * Scales the texture
  11263. * @param ratio the scale factor to apply to both width and height
  11264. */
  11265. scale(ratio: number): void;
  11266. /**
  11267. * Resizes the texture
  11268. * @param width the new width
  11269. * @param height the new height
  11270. */
  11271. scaleTo(width: number, height: number): void;
  11272. /**
  11273. * Gets the context of the canvas used by the texture
  11274. * @returns the canvas context of the dynamic texture
  11275. */
  11276. getContext(): CanvasRenderingContext2D;
  11277. /**
  11278. * Clears the texture
  11279. */
  11280. clear(): void;
  11281. /**
  11282. * Updates the texture
  11283. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11284. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11285. */
  11286. update(invertY?: boolean, premulAlpha?: boolean): void;
  11287. /**
  11288. * Draws text onto the texture
  11289. * @param text defines the text to be drawn
  11290. * @param x defines the placement of the text from the left
  11291. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11292. * @param font defines the font to be used with font-style, font-size, font-name
  11293. * @param color defines the color used for the text
  11294. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11295. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11296. * @param update defines whether texture is immediately update (default is true)
  11297. */
  11298. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11299. /**
  11300. * Clones the texture
  11301. * @returns the clone of the texture.
  11302. */
  11303. clone(): DynamicTexture;
  11304. /**
  11305. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11306. * @returns a serialized dynamic texture object
  11307. */
  11308. serialize(): any;
  11309. /** @hidden */
  11310. _rebuild(): void;
  11311. }
  11312. }
  11313. declare module BABYLON {
  11314. interface ThinEngine {
  11315. /**
  11316. * Creates a raw texture
  11317. * @param data defines the data to store in the texture
  11318. * @param width defines the width of the texture
  11319. * @param height defines the height of the texture
  11320. * @param format defines the format of the data
  11321. * @param generateMipMaps defines if the engine should generate the mip levels
  11322. * @param invertY defines if data must be stored with Y axis inverted
  11323. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11324. * @param compression defines the compression used (null by default)
  11325. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11326. * @returns the raw texture inside an InternalTexture
  11327. */
  11328. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11329. /**
  11330. * Update a raw texture
  11331. * @param texture defines the texture to update
  11332. * @param data defines the data to store in the texture
  11333. * @param format defines the format of the data
  11334. * @param invertY defines if data must be stored with Y axis inverted
  11335. */
  11336. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11337. /**
  11338. * Update a raw texture
  11339. * @param texture defines the texture to update
  11340. * @param data defines the data to store in the texture
  11341. * @param format defines the format of the data
  11342. * @param invertY defines if data must be stored with Y axis inverted
  11343. * @param compression defines the compression used (null by default)
  11344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11345. */
  11346. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11347. /**
  11348. * Creates a new raw cube texture
  11349. * @param data defines the array of data to use to create each face
  11350. * @param size defines the size of the textures
  11351. * @param format defines the format of the data
  11352. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11353. * @param generateMipMaps defines if the engine should generate the mip levels
  11354. * @param invertY defines if data must be stored with Y axis inverted
  11355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11356. * @param compression defines the compression used (null by default)
  11357. * @returns the cube texture as an InternalTexture
  11358. */
  11359. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11360. /**
  11361. * Update a raw cube texture
  11362. * @param texture defines the texture to udpdate
  11363. * @param data defines the data to store
  11364. * @param format defines the data format
  11365. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11366. * @param invertY defines if data must be stored with Y axis inverted
  11367. */
  11368. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11369. /**
  11370. * Update a raw cube texture
  11371. * @param texture defines the texture to udpdate
  11372. * @param data defines the data to store
  11373. * @param format defines the data format
  11374. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11375. * @param invertY defines if data must be stored with Y axis inverted
  11376. * @param compression defines the compression used (null by default)
  11377. */
  11378. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11379. /**
  11380. * Update a raw cube texture
  11381. * @param texture defines the texture to udpdate
  11382. * @param data defines the data to store
  11383. * @param format defines the data format
  11384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11385. * @param invertY defines if data must be stored with Y axis inverted
  11386. * @param compression defines the compression used (null by default)
  11387. * @param level defines which level of the texture to update
  11388. */
  11389. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11390. /**
  11391. * Creates a new raw cube texture from a specified url
  11392. * @param url defines the url where the data is located
  11393. * @param scene defines the current scene
  11394. * @param size defines the size of the textures
  11395. * @param format defines the format of the data
  11396. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11397. * @param noMipmap defines if the engine should avoid generating the mip levels
  11398. * @param callback defines a callback used to extract texture data from loaded data
  11399. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11400. * @param onLoad defines a callback called when texture is loaded
  11401. * @param onError defines a callback called if there is an error
  11402. * @returns the cube texture as an InternalTexture
  11403. */
  11404. 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;
  11405. /**
  11406. * Creates a new raw cube texture from a specified url
  11407. * @param url defines the url where the data is located
  11408. * @param scene defines the current scene
  11409. * @param size defines the size of the textures
  11410. * @param format defines the format of the data
  11411. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11412. * @param noMipmap defines if the engine should avoid generating the mip levels
  11413. * @param callback defines a callback used to extract texture data from loaded data
  11414. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11415. * @param onLoad defines a callback called when texture is loaded
  11416. * @param onError defines a callback called if there is an error
  11417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11418. * @param invertY defines if data must be stored with Y axis inverted
  11419. * @returns the cube texture as an InternalTexture
  11420. */
  11421. 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;
  11422. /**
  11423. * Creates a new raw 3D texture
  11424. * @param data defines the data used to create the texture
  11425. * @param width defines the width of the texture
  11426. * @param height defines the height of the texture
  11427. * @param depth defines the depth of the texture
  11428. * @param format defines the format of the texture
  11429. * @param generateMipMaps defines if the engine must generate mip levels
  11430. * @param invertY defines if data must be stored with Y axis inverted
  11431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11432. * @param compression defines the compressed used (can be null)
  11433. * @param textureType defines the compressed used (can be null)
  11434. * @returns a new raw 3D texture (stored in an InternalTexture)
  11435. */
  11436. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11437. /**
  11438. * Update a raw 3D texture
  11439. * @param texture defines the texture to update
  11440. * @param data defines the data to store
  11441. * @param format defines the data format
  11442. * @param invertY defines if data must be stored with Y axis inverted
  11443. */
  11444. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11445. /**
  11446. * Update a raw 3D texture
  11447. * @param texture defines the texture to update
  11448. * @param data defines the data to store
  11449. * @param format defines the data format
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @param compression defines the used compression (can be null)
  11452. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11453. */
  11454. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11455. /**
  11456. * Creates a new raw 2D array texture
  11457. * @param data defines the data used to create the texture
  11458. * @param width defines the width of the texture
  11459. * @param height defines the height of the texture
  11460. * @param depth defines the number of layers of the texture
  11461. * @param format defines the format of the texture
  11462. * @param generateMipMaps defines if the engine must generate mip levels
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11465. * @param compression defines the compressed used (can be null)
  11466. * @param textureType defines the compressed used (can be null)
  11467. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11468. */
  11469. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11470. /**
  11471. * Update a raw 2D array texture
  11472. * @param texture defines the texture to update
  11473. * @param data defines the data to store
  11474. * @param format defines the data format
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. */
  11477. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11478. /**
  11479. * Update a raw 2D array texture
  11480. * @param texture defines the texture to update
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @param compression defines the used compression (can be null)
  11485. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11486. */
  11487. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11488. }
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Raw texture can help creating a texture directly from an array of data.
  11493. * This can be super useful if you either get the data from an uncompressed source or
  11494. * if you wish to create your texture pixel by pixel.
  11495. */
  11496. export class RawTexture extends Texture {
  11497. /**
  11498. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11499. */
  11500. format: number;
  11501. /**
  11502. * Instantiates a new RawTexture.
  11503. * Raw texture can help creating a texture directly from an array of data.
  11504. * This can be super useful if you either get the data from an uncompressed source or
  11505. * if you wish to create your texture pixel by pixel.
  11506. * @param data define the array of data to use to create the texture
  11507. * @param width define the width of the texture
  11508. * @param height define the height of the texture
  11509. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11510. * @param scene define the scene the texture belongs to
  11511. * @param generateMipMaps define whether mip maps should be generated or not
  11512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11514. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11515. */
  11516. constructor(data: ArrayBufferView, width: number, height: number,
  11517. /**
  11518. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11519. */
  11520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11521. /**
  11522. * Updates the texture underlying data.
  11523. * @param data Define the new data of the texture
  11524. */
  11525. update(data: ArrayBufferView): void;
  11526. /**
  11527. * Creates a luminance texture from some data.
  11528. * @param data Define the texture data
  11529. * @param width Define the width of the texture
  11530. * @param height Define the height of the texture
  11531. * @param scene Define the scene the texture belongs to
  11532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11535. * @returns the luminance texture
  11536. */
  11537. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11538. /**
  11539. * Creates a luminance alpha texture from some data.
  11540. * @param data Define the texture data
  11541. * @param width Define the width of the texture
  11542. * @param height Define the height of the texture
  11543. * @param scene Define the scene the texture belongs to
  11544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11547. * @returns the luminance alpha texture
  11548. */
  11549. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11550. /**
  11551. * Creates an alpha texture from some data.
  11552. * @param data Define the texture data
  11553. * @param width Define the width of the texture
  11554. * @param height Define the height of the texture
  11555. * @param scene Define the scene the texture belongs to
  11556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11559. * @returns the alpha texture
  11560. */
  11561. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11562. /**
  11563. * Creates a RGB texture from some data.
  11564. * @param data Define the texture data
  11565. * @param width Define the width of the texture
  11566. * @param height Define the height of the texture
  11567. * @param scene Define the scene the texture belongs to
  11568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11572. * @returns the RGB alpha texture
  11573. */
  11574. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11575. /**
  11576. * Creates a RGBA texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param scene Define the scene the texture belongs to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. * @returns the RGBA texture
  11586. */
  11587. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11588. /**
  11589. * Creates a R texture from some data.
  11590. * @param data Define the texture data
  11591. * @param width Define the width of the texture
  11592. * @param height Define the height of the texture
  11593. * @param scene Define the scene the texture belongs to
  11594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11598. * @returns the R texture
  11599. */
  11600. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11601. }
  11602. }
  11603. declare module BABYLON {
  11604. interface AbstractScene {
  11605. /**
  11606. * The list of procedural textures added to the scene
  11607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11608. */
  11609. proceduralTextures: Array<ProceduralTexture>;
  11610. }
  11611. /**
  11612. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11613. * in a given scene.
  11614. */
  11615. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11616. /**
  11617. * The component name helpfull to identify the component in the list of scene components.
  11618. */
  11619. readonly name: string;
  11620. /**
  11621. * The scene the component belongs to.
  11622. */
  11623. scene: Scene;
  11624. /**
  11625. * Creates a new instance of the component for the given scene
  11626. * @param scene Defines the scene to register the component in
  11627. */
  11628. constructor(scene: Scene);
  11629. /**
  11630. * Registers the component in a given scene
  11631. */
  11632. register(): void;
  11633. /**
  11634. * Rebuilds the elements related to this component in case of
  11635. * context lost for instance.
  11636. */
  11637. rebuild(): void;
  11638. /**
  11639. * Disposes the component and the associated ressources.
  11640. */
  11641. dispose(): void;
  11642. private _beforeClear;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. interface ThinEngine {
  11647. /**
  11648. * Creates a new render target cube texture
  11649. * @param size defines the size of the texture
  11650. * @param options defines the options used to create the texture
  11651. * @returns a new render target cube texture stored in an InternalTexture
  11652. */
  11653. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11654. }
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var proceduralVertexShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /**
  11665. * 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.
  11666. * This is the base class of any Procedural texture and contains most of the shareable code.
  11667. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11668. */
  11669. export class ProceduralTexture extends Texture {
  11670. isCube: boolean;
  11671. /**
  11672. * Define if the texture is enabled or not (disabled texture will not render)
  11673. */
  11674. isEnabled: boolean;
  11675. /**
  11676. * Define if the texture must be cleared before rendering (default is true)
  11677. */
  11678. autoClear: boolean;
  11679. /**
  11680. * Callback called when the texture is generated
  11681. */
  11682. onGenerated: () => void;
  11683. /**
  11684. * Event raised when the texture is generated
  11685. */
  11686. onGeneratedObservable: Observable<ProceduralTexture>;
  11687. /** @hidden */
  11688. _generateMipMaps: boolean;
  11689. /** @hidden **/
  11690. _effect: Effect;
  11691. /** @hidden */
  11692. _textures: {
  11693. [key: string]: Texture;
  11694. };
  11695. /** @hidden */
  11696. protected _fallbackTexture: Nullable<Texture>;
  11697. private _size;
  11698. private _currentRefreshId;
  11699. private _frameId;
  11700. private _refreshRate;
  11701. private _vertexBuffers;
  11702. private _indexBuffer;
  11703. private _uniforms;
  11704. private _samplers;
  11705. private _fragment;
  11706. private _floats;
  11707. private _ints;
  11708. private _floatsArrays;
  11709. private _colors3;
  11710. private _colors4;
  11711. private _vectors2;
  11712. private _vectors3;
  11713. private _matrices;
  11714. private _fallbackTextureUsed;
  11715. private _fullEngine;
  11716. private _cachedDefines;
  11717. private _contentUpdateId;
  11718. private _contentData;
  11719. /**
  11720. * Instantiates a new procedural texture.
  11721. * 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.
  11722. * This is the base class of any Procedural texture and contains most of the shareable code.
  11723. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11724. * @param name Define the name of the texture
  11725. * @param size Define the size of the texture to create
  11726. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11727. * @param scene Define the scene the texture belongs to
  11728. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11729. * @param generateMipMaps Define if the texture should creates mip maps or not
  11730. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11731. */
  11732. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11733. /**
  11734. * The effect that is created when initializing the post process.
  11735. * @returns The created effect corresponding the the postprocess.
  11736. */
  11737. getEffect(): Effect;
  11738. /**
  11739. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11740. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11741. */
  11742. getContent(): Nullable<ArrayBufferView>;
  11743. private _createIndexBuffer;
  11744. /** @hidden */
  11745. _rebuild(): void;
  11746. /**
  11747. * Resets the texture in order to recreate its associated resources.
  11748. * This can be called in case of context loss
  11749. */
  11750. reset(): void;
  11751. protected _getDefines(): string;
  11752. /**
  11753. * Is the texture ready to be used ? (rendered at least once)
  11754. * @returns true if ready, otherwise, false.
  11755. */
  11756. isReady(): boolean;
  11757. /**
  11758. * Resets the refresh counter of the texture and start bak from scratch.
  11759. * Could be useful to regenerate the texture if it is setup to render only once.
  11760. */
  11761. resetRefreshCounter(): void;
  11762. /**
  11763. * Set the fragment shader to use in order to render the texture.
  11764. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11765. */
  11766. setFragment(fragment: any): void;
  11767. /**
  11768. * Define the refresh rate of the texture or the rendering frequency.
  11769. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11770. */
  11771. get refreshRate(): number;
  11772. set refreshRate(value: number);
  11773. /** @hidden */
  11774. _shouldRender(): boolean;
  11775. /**
  11776. * Get the size the texture is rendering at.
  11777. * @returns the size (texture is always squared)
  11778. */
  11779. getRenderSize(): number;
  11780. /**
  11781. * Resize the texture to new value.
  11782. * @param size Define the new size the texture should have
  11783. * @param generateMipMaps Define whether the new texture should create mip maps
  11784. */
  11785. resize(size: number, generateMipMaps: boolean): void;
  11786. private _checkUniform;
  11787. /**
  11788. * Set a texture in the shader program used to render.
  11789. * @param name Define the name of the uniform samplers as defined in the shader
  11790. * @param texture Define the texture to bind to this sampler
  11791. * @return the texture itself allowing "fluent" like uniform updates
  11792. */
  11793. setTexture(name: string, texture: Texture): ProceduralTexture;
  11794. /**
  11795. * Set a float in the shader.
  11796. * @param name Define the name of the uniform as defined in the shader
  11797. * @param value Define the value to give to the uniform
  11798. * @return the texture itself allowing "fluent" like uniform updates
  11799. */
  11800. setFloat(name: string, value: number): ProceduralTexture;
  11801. /**
  11802. * Set a int in the shader.
  11803. * @param name Define the name of the uniform as defined in the shader
  11804. * @param value Define the value to give to the uniform
  11805. * @return the texture itself allowing "fluent" like uniform updates
  11806. */
  11807. setInt(name: string, value: number): ProceduralTexture;
  11808. /**
  11809. * Set an array of floats in the shader.
  11810. * @param name Define the name of the uniform as defined in the shader
  11811. * @param value Define the value to give to the uniform
  11812. * @return the texture itself allowing "fluent" like uniform updates
  11813. */
  11814. setFloats(name: string, value: number[]): ProceduralTexture;
  11815. /**
  11816. * Set a vec3 in the shader from a Color3.
  11817. * @param name Define the name of the uniform as defined in the shader
  11818. * @param value Define the value to give to the uniform
  11819. * @return the texture itself allowing "fluent" like uniform updates
  11820. */
  11821. setColor3(name: string, value: Color3): ProceduralTexture;
  11822. /**
  11823. * Set a vec4 in the shader from a Color4.
  11824. * @param name Define the name of the uniform as defined in the shader
  11825. * @param value Define the value to give to the uniform
  11826. * @return the texture itself allowing "fluent" like uniform updates
  11827. */
  11828. setColor4(name: string, value: Color4): ProceduralTexture;
  11829. /**
  11830. * Set a vec2 in the shader from a Vector2.
  11831. * @param name Define the name of the uniform as defined in the shader
  11832. * @param value Define the value to give to the uniform
  11833. * @return the texture itself allowing "fluent" like uniform updates
  11834. */
  11835. setVector2(name: string, value: Vector2): ProceduralTexture;
  11836. /**
  11837. * Set a vec3 in the shader from a Vector3.
  11838. * @param name Define the name of the uniform as defined in the shader
  11839. * @param value Define the value to give to the uniform
  11840. * @return the texture itself allowing "fluent" like uniform updates
  11841. */
  11842. setVector3(name: string, value: Vector3): ProceduralTexture;
  11843. /**
  11844. * Set a mat4 in the shader from a MAtrix.
  11845. * @param name Define the name of the uniform as defined in the shader
  11846. * @param value Define the value to give to the uniform
  11847. * @return the texture itself allowing "fluent" like uniform updates
  11848. */
  11849. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11850. /**
  11851. * Render the texture to its associated render target.
  11852. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11853. */
  11854. render(useCameraPostProcess?: boolean): void;
  11855. /**
  11856. * Clone the texture.
  11857. * @returns the cloned texture
  11858. */
  11859. clone(): ProceduralTexture;
  11860. /**
  11861. * Dispose the texture and release its asoociated resources.
  11862. */
  11863. dispose(): void;
  11864. }
  11865. }
  11866. declare module BABYLON {
  11867. /**
  11868. * This represents the base class for particle system in Babylon.
  11869. * 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.
  11870. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11871. * @example https://doc.babylonjs.com/babylon101/particles
  11872. */
  11873. export class BaseParticleSystem {
  11874. /**
  11875. * Source color is added to the destination color without alpha affecting the result
  11876. */
  11877. static BLENDMODE_ONEONE: number;
  11878. /**
  11879. * Blend current color and particle color using particle’s alpha
  11880. */
  11881. static BLENDMODE_STANDARD: number;
  11882. /**
  11883. * Add current color and particle color multiplied by particle’s alpha
  11884. */
  11885. static BLENDMODE_ADD: number;
  11886. /**
  11887. * Multiply current color with particle color
  11888. */
  11889. static BLENDMODE_MULTIPLY: number;
  11890. /**
  11891. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11892. */
  11893. static BLENDMODE_MULTIPLYADD: number;
  11894. /**
  11895. * List of animations used by the particle system.
  11896. */
  11897. animations: Animation[];
  11898. /**
  11899. * Gets or sets the unique id of the particle system
  11900. */
  11901. uniqueId: number;
  11902. /**
  11903. * The id of the Particle system.
  11904. */
  11905. id: string;
  11906. /**
  11907. * The friendly name of the Particle system.
  11908. */
  11909. name: string;
  11910. /**
  11911. * Snippet ID if the particle system was created from the snippet server
  11912. */
  11913. snippetId: string;
  11914. /**
  11915. * The rendering group used by the Particle system to chose when to render.
  11916. */
  11917. renderingGroupId: number;
  11918. /**
  11919. * The emitter represents the Mesh or position we are attaching the particle system to.
  11920. */
  11921. emitter: Nullable<AbstractMesh | Vector3>;
  11922. /**
  11923. * The maximum number of particles to emit per frame
  11924. */
  11925. emitRate: number;
  11926. /**
  11927. * If you want to launch only a few particles at once, that can be done, as well.
  11928. */
  11929. manualEmitCount: number;
  11930. /**
  11931. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11932. */
  11933. updateSpeed: number;
  11934. /**
  11935. * The amount of time the particle system is running (depends of the overall update speed).
  11936. */
  11937. targetStopDuration: number;
  11938. /**
  11939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11940. */
  11941. disposeOnStop: boolean;
  11942. /**
  11943. * Minimum power of emitting particles.
  11944. */
  11945. minEmitPower: number;
  11946. /**
  11947. * Maximum power of emitting particles.
  11948. */
  11949. maxEmitPower: number;
  11950. /**
  11951. * Minimum life time of emitting particles.
  11952. */
  11953. minLifeTime: number;
  11954. /**
  11955. * Maximum life time of emitting particles.
  11956. */
  11957. maxLifeTime: number;
  11958. /**
  11959. * Minimum Size of emitting particles.
  11960. */
  11961. minSize: number;
  11962. /**
  11963. * Maximum Size of emitting particles.
  11964. */
  11965. maxSize: number;
  11966. /**
  11967. * Minimum scale of emitting particles on X axis.
  11968. */
  11969. minScaleX: number;
  11970. /**
  11971. * Maximum scale of emitting particles on X axis.
  11972. */
  11973. maxScaleX: number;
  11974. /**
  11975. * Minimum scale of emitting particles on Y axis.
  11976. */
  11977. minScaleY: number;
  11978. /**
  11979. * Maximum scale of emitting particles on Y axis.
  11980. */
  11981. maxScaleY: number;
  11982. /**
  11983. * Gets or sets the minimal initial rotation in radians.
  11984. */
  11985. minInitialRotation: number;
  11986. /**
  11987. * Gets or sets the maximal initial rotation in radians.
  11988. */
  11989. maxInitialRotation: number;
  11990. /**
  11991. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11992. */
  11993. minAngularSpeed: number;
  11994. /**
  11995. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11996. */
  11997. maxAngularSpeed: number;
  11998. /**
  11999. * The texture used to render each particle. (this can be a spritesheet)
  12000. */
  12001. particleTexture: Nullable<Texture>;
  12002. /**
  12003. * The layer mask we are rendering the particles through.
  12004. */
  12005. layerMask: number;
  12006. /**
  12007. * This can help using your own shader to render the particle system.
  12008. * The according effect will be created
  12009. */
  12010. customShader: any;
  12011. /**
  12012. * By default particle system starts as soon as they are created. This prevents the
  12013. * automatic start to happen and let you decide when to start emitting particles.
  12014. */
  12015. preventAutoStart: boolean;
  12016. private _noiseTexture;
  12017. /**
  12018. * Gets or sets a texture used to add random noise to particle positions
  12019. */
  12020. get noiseTexture(): Nullable<ProceduralTexture>;
  12021. set noiseTexture(value: Nullable<ProceduralTexture>);
  12022. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12023. noiseStrength: Vector3;
  12024. /**
  12025. * Callback triggered when the particle animation is ending.
  12026. */
  12027. onAnimationEnd: Nullable<() => void>;
  12028. /**
  12029. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12030. */
  12031. blendMode: number;
  12032. /**
  12033. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12034. * to override the particles.
  12035. */
  12036. forceDepthWrite: boolean;
  12037. /** 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 */
  12038. preWarmCycles: number;
  12039. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12040. preWarmStepOffset: number;
  12041. /**
  12042. * 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)
  12043. */
  12044. spriteCellChangeSpeed: number;
  12045. /**
  12046. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12047. */
  12048. startSpriteCellID: number;
  12049. /**
  12050. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12051. */
  12052. endSpriteCellID: number;
  12053. /**
  12054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12055. */
  12056. spriteCellWidth: number;
  12057. /**
  12058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12059. */
  12060. spriteCellHeight: number;
  12061. /**
  12062. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12063. */
  12064. spriteRandomStartCell: boolean;
  12065. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12066. translationPivot: Vector2;
  12067. /** @hidden */
  12068. protected _isAnimationSheetEnabled: boolean;
  12069. /**
  12070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12071. */
  12072. beginAnimationOnStart: boolean;
  12073. /**
  12074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12075. */
  12076. beginAnimationFrom: number;
  12077. /**
  12078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12079. */
  12080. beginAnimationTo: number;
  12081. /**
  12082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12083. */
  12084. beginAnimationLoop: boolean;
  12085. /**
  12086. * Gets or sets a world offset applied to all particles
  12087. */
  12088. worldOffset: Vector3;
  12089. /**
  12090. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12091. */
  12092. get isAnimationSheetEnabled(): boolean;
  12093. set isAnimationSheetEnabled(value: boolean);
  12094. /**
  12095. * Get hosting scene
  12096. * @returns the scene
  12097. */
  12098. getScene(): Scene;
  12099. /**
  12100. * You can use gravity if you want to give an orientation to your particles.
  12101. */
  12102. gravity: Vector3;
  12103. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12104. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12105. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12106. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12107. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12108. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12109. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12110. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12111. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12112. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12113. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12114. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12115. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12116. /**
  12117. * Defines the delay in milliseconds before starting the system (0 by default)
  12118. */
  12119. startDelay: number;
  12120. /**
  12121. * Gets the current list of drag gradients.
  12122. * You must use addDragGradient and removeDragGradient to udpate this list
  12123. * @returns the list of drag gradients
  12124. */
  12125. getDragGradients(): Nullable<Array<FactorGradient>>;
  12126. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12127. limitVelocityDamping: number;
  12128. /**
  12129. * Gets the current list of limit velocity gradients.
  12130. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12131. * @returns the list of limit velocity gradients
  12132. */
  12133. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of color gradients.
  12136. * You must use addColorGradient and removeColorGradient to udpate this list
  12137. * @returns the list of color gradients
  12138. */
  12139. getColorGradients(): Nullable<Array<ColorGradient>>;
  12140. /**
  12141. * Gets the current list of size gradients.
  12142. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12143. * @returns the list of size gradients
  12144. */
  12145. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Gets the current list of color remap gradients.
  12148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12149. * @returns the list of color remap gradients
  12150. */
  12151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12152. /**
  12153. * Gets the current list of alpha remap gradients.
  12154. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12155. * @returns the list of alpha remap gradients
  12156. */
  12157. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12158. /**
  12159. * Gets the current list of life time gradients.
  12160. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12161. * @returns the list of life time gradients
  12162. */
  12163. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12164. /**
  12165. * Gets the current list of angular speed gradients.
  12166. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12167. * @returns the list of angular speed gradients
  12168. */
  12169. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12170. /**
  12171. * Gets the current list of velocity gradients.
  12172. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12173. * @returns the list of velocity gradients
  12174. */
  12175. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12176. /**
  12177. * Gets the current list of start size gradients.
  12178. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12179. * @returns the list of start size gradients
  12180. */
  12181. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12182. /**
  12183. * Gets the current list of emit rate gradients.
  12184. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12185. * @returns the list of emit rate gradients
  12186. */
  12187. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12188. /**
  12189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12190. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12191. */
  12192. get direction1(): Vector3;
  12193. set direction1(value: Vector3);
  12194. /**
  12195. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12196. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12197. */
  12198. get direction2(): Vector3;
  12199. set direction2(value: Vector3);
  12200. /**
  12201. * 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.
  12202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12203. */
  12204. get minEmitBox(): Vector3;
  12205. set minEmitBox(value: Vector3);
  12206. /**
  12207. * 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.
  12208. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12209. */
  12210. get maxEmitBox(): Vector3;
  12211. set maxEmitBox(value: Vector3);
  12212. /**
  12213. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12214. */
  12215. color1: Color4;
  12216. /**
  12217. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12218. */
  12219. color2: Color4;
  12220. /**
  12221. * Color the particle will have at the end of its lifetime
  12222. */
  12223. colorDead: Color4;
  12224. /**
  12225. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12226. */
  12227. textureMask: Color4;
  12228. /**
  12229. * The particle emitter type defines the emitter used by the particle system.
  12230. * It can be for example box, sphere, or cone...
  12231. */
  12232. particleEmitterType: IParticleEmitterType;
  12233. /** @hidden */
  12234. _isSubEmitter: boolean;
  12235. /**
  12236. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12237. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12238. */
  12239. billboardMode: number;
  12240. protected _isBillboardBased: boolean;
  12241. /**
  12242. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12243. */
  12244. get isBillboardBased(): boolean;
  12245. set isBillboardBased(value: boolean);
  12246. /**
  12247. * The scene the particle system belongs to.
  12248. */
  12249. protected _scene: Scene;
  12250. /**
  12251. * Local cache of defines for image processing.
  12252. */
  12253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12254. /**
  12255. * Default configuration related to image processing available in the standard Material.
  12256. */
  12257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12258. /**
  12259. * Gets the image processing configuration used either in this material.
  12260. */
  12261. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12262. /**
  12263. * Sets the Default image processing configuration used either in the this material.
  12264. *
  12265. * If sets to null, the scene one is in use.
  12266. */
  12267. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12268. /**
  12269. * Attaches a new image processing configuration to the Standard Material.
  12270. * @param configuration
  12271. */
  12272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12273. /** @hidden */
  12274. protected _reset(): void;
  12275. /** @hidden */
  12276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12277. /**
  12278. * Instantiates a particle system.
  12279. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12280. * @param name The name of the particle system
  12281. */
  12282. constructor(name: string);
  12283. /**
  12284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12287. * @returns the emitter
  12288. */
  12289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12290. /**
  12291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12292. * @param radius The radius of the hemisphere to emit from
  12293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12294. * @returns the emitter
  12295. */
  12296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12297. /**
  12298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12299. * @param radius The radius of the sphere to emit from
  12300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12301. * @returns the emitter
  12302. */
  12303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12304. /**
  12305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12306. * @param radius The radius of the sphere to emit from
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12309. * @returns the emitter
  12310. */
  12311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12314. * @param radius The radius of the emission cylinder
  12315. * @param height The height of the emission cylinder
  12316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12318. * @returns the emitter
  12319. */
  12320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12321. /**
  12322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12323. * @param radius The radius of the cylinder to emit from
  12324. * @param height The height of the emission cylinder
  12325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12328. * @returns the emitter
  12329. */
  12330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12331. /**
  12332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12333. * @param radius The radius of the cone to emit from
  12334. * @param angle The base angle of the cone
  12335. * @returns the emitter
  12336. */
  12337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12338. /**
  12339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12344. * @returns the emitter
  12345. */
  12346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12347. }
  12348. }
  12349. declare module BABYLON {
  12350. /**
  12351. * Type of sub emitter
  12352. */
  12353. export enum SubEmitterType {
  12354. /**
  12355. * Attached to the particle over it's lifetime
  12356. */
  12357. ATTACHED = 0,
  12358. /**
  12359. * Created when the particle dies
  12360. */
  12361. END = 1
  12362. }
  12363. /**
  12364. * Sub emitter class used to emit particles from an existing particle
  12365. */
  12366. export class SubEmitter {
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem;
  12371. /**
  12372. * Type of the submitter (Default: END)
  12373. */
  12374. type: SubEmitterType;
  12375. /**
  12376. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12377. * Note: This only is supported when using an emitter of type Mesh
  12378. */
  12379. inheritDirection: boolean;
  12380. /**
  12381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12382. */
  12383. inheritedVelocityAmount: number;
  12384. /**
  12385. * Creates a sub emitter
  12386. * @param particleSystem the particle system to be used by the sub emitter
  12387. */
  12388. constructor(
  12389. /**
  12390. * the particle system to be used by the sub emitter
  12391. */
  12392. particleSystem: ParticleSystem);
  12393. /**
  12394. * Clones the sub emitter
  12395. * @returns the cloned sub emitter
  12396. */
  12397. clone(): SubEmitter;
  12398. /**
  12399. * Serialize current object to a JSON object
  12400. * @returns the serialized object
  12401. */
  12402. serialize(): any;
  12403. /** @hidden */
  12404. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12405. /**
  12406. * Creates a new SubEmitter from a serialized JSON version
  12407. * @param serializationObject defines the JSON object to read from
  12408. * @param scene defines the hosting scene
  12409. * @param rootUrl defines the rootUrl for data loading
  12410. * @returns a new SubEmitter
  12411. */
  12412. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12413. /** Release associated resources */
  12414. dispose(): void;
  12415. }
  12416. }
  12417. declare module BABYLON {
  12418. /** @hidden */
  12419. export var imageProcessingDeclaration: {
  12420. name: string;
  12421. shader: string;
  12422. };
  12423. }
  12424. declare module BABYLON {
  12425. /** @hidden */
  12426. export var imageProcessingFunctions: {
  12427. name: string;
  12428. shader: string;
  12429. };
  12430. }
  12431. declare module BABYLON {
  12432. /** @hidden */
  12433. export var particlesPixelShader: {
  12434. name: string;
  12435. shader: string;
  12436. };
  12437. }
  12438. declare module BABYLON {
  12439. /** @hidden */
  12440. export var particlesVertexShader: {
  12441. name: string;
  12442. shader: string;
  12443. };
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * This represents a particle system in Babylon.
  12448. * 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.
  12449. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12450. * @example https://doc.babylonjs.com/babylon101/particles
  12451. */
  12452. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12453. /**
  12454. * Billboard mode will only apply to Y axis
  12455. */
  12456. static readonly BILLBOARDMODE_Y: number;
  12457. /**
  12458. * Billboard mode will apply to all axes
  12459. */
  12460. static readonly BILLBOARDMODE_ALL: number;
  12461. /**
  12462. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12463. */
  12464. static readonly BILLBOARDMODE_STRETCHED: number;
  12465. /**
  12466. * This function can be defined to provide custom update for active particles.
  12467. * This function will be called instead of regular update (age, position, color, etc.).
  12468. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12469. */
  12470. updateFunction: (particles: Particle[]) => void;
  12471. private _emitterWorldMatrix;
  12472. /**
  12473. * This function can be defined to specify initial direction for every new particle.
  12474. * It by default use the emitterType defined function
  12475. */
  12476. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12477. /**
  12478. * This function can be defined to specify initial position for every new particle.
  12479. * It by default use the emitterType defined function
  12480. */
  12481. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12482. /**
  12483. * @hidden
  12484. */
  12485. _inheritedVelocityOffset: Vector3;
  12486. /**
  12487. * An event triggered when the system is disposed
  12488. */
  12489. onDisposeObservable: Observable<IParticleSystem>;
  12490. private _onDisposeObserver;
  12491. /**
  12492. * Sets a callback that will be triggered when the system is disposed
  12493. */
  12494. set onDispose(callback: () => void);
  12495. private _particles;
  12496. private _epsilon;
  12497. private _capacity;
  12498. private _stockParticles;
  12499. private _newPartsExcess;
  12500. private _vertexData;
  12501. private _vertexBuffer;
  12502. private _vertexBuffers;
  12503. private _spriteBuffer;
  12504. private _indexBuffer;
  12505. private _effect;
  12506. private _customEffect;
  12507. private _cachedDefines;
  12508. private _scaledColorStep;
  12509. private _colorDiff;
  12510. private _scaledDirection;
  12511. private _scaledGravity;
  12512. private _currentRenderId;
  12513. private _alive;
  12514. private _useInstancing;
  12515. private _started;
  12516. private _stopped;
  12517. private _actualFrame;
  12518. private _scaledUpdateSpeed;
  12519. private _vertexBufferSize;
  12520. /** @hidden */
  12521. _currentEmitRateGradient: Nullable<FactorGradient>;
  12522. /** @hidden */
  12523. _currentEmitRate1: number;
  12524. /** @hidden */
  12525. _currentEmitRate2: number;
  12526. /** @hidden */
  12527. _currentStartSizeGradient: Nullable<FactorGradient>;
  12528. /** @hidden */
  12529. _currentStartSize1: number;
  12530. /** @hidden */
  12531. _currentStartSize2: number;
  12532. private readonly _rawTextureWidth;
  12533. private _rampGradientsTexture;
  12534. private _useRampGradients;
  12535. /** Gets or sets a boolean indicating that ramp gradients must be used
  12536. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12537. */
  12538. get useRampGradients(): boolean;
  12539. set useRampGradients(value: boolean);
  12540. /**
  12541. * 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.
  12542. * 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: [])
  12543. */
  12544. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12545. private _subEmitters;
  12546. /**
  12547. * @hidden
  12548. * If the particle systems emitter should be disposed when the particle system is disposed
  12549. */
  12550. _disposeEmitterOnDispose: boolean;
  12551. /**
  12552. * The current active Sub-systems, this property is used by the root particle system only.
  12553. */
  12554. activeSubSystems: Array<ParticleSystem>;
  12555. /**
  12556. * Specifies if the particles are updated in emitter local space or world space
  12557. */
  12558. isLocal: boolean;
  12559. private _rootParticleSystem;
  12560. /**
  12561. * Gets the current list of active particles
  12562. */
  12563. get particles(): Particle[];
  12564. /**
  12565. * Gets the number of particles active at the same time.
  12566. * @returns The number of active particles.
  12567. */
  12568. getActiveCount(): number;
  12569. /**
  12570. * Returns the string "ParticleSystem"
  12571. * @returns a string containing the class name
  12572. */
  12573. getClassName(): string;
  12574. /**
  12575. * Gets a boolean indicating that the system is stopping
  12576. * @returns true if the system is currently stopping
  12577. */
  12578. isStopping(): boolean;
  12579. /**
  12580. * Gets the custom effect used to render the particles
  12581. * @param blendMode Blend mode for which the effect should be retrieved
  12582. * @returns The effect
  12583. */
  12584. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12585. /**
  12586. * Sets the custom effect used to render the particles
  12587. * @param effect The effect to set
  12588. * @param blendMode Blend mode for which the effect should be set
  12589. */
  12590. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12591. /** @hidden */
  12592. private _onBeforeDrawParticlesObservable;
  12593. /**
  12594. * Observable that will be called just before the particles are drawn
  12595. */
  12596. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12597. /**
  12598. * Gets the name of the particle vertex shader
  12599. */
  12600. get vertexShaderName(): string;
  12601. /**
  12602. * Instantiates a particle system.
  12603. * 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.
  12604. * @param name The name of the particle system
  12605. * @param capacity The max number of particles alive at the same time
  12606. * @param scene The scene the particle system belongs to
  12607. * @param customEffect a custom effect used to change the way particles are rendered by default
  12608. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12609. * @param epsilon Offset used to render the particles
  12610. */
  12611. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12612. private _addFactorGradient;
  12613. private _removeFactorGradient;
  12614. /**
  12615. * Adds a new life time gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param factor defines the life time factor to affect to the specified gradient
  12618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12619. * @returns the current particle system
  12620. */
  12621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific life time gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new size gradient
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the size factor to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific size gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeSizeGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new color remap gradient
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param min defines the color remap minimal range
  12646. * @param max defines the color remap maximal range
  12647. * @returns the current particle system
  12648. */
  12649. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific color remap gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeColorRemapGradient(gradient: number): IParticleSystem;
  12656. /**
  12657. * Adds a new alpha remap gradient
  12658. * @param gradient defines the gradient to use (between 0 and 1)
  12659. * @param min defines the alpha remap minimal range
  12660. * @param max defines the alpha remap maximal range
  12661. * @returns the current particle system
  12662. */
  12663. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12664. /**
  12665. * Remove a specific alpha remap gradient
  12666. * @param gradient defines the gradient to remove
  12667. * @returns the current particle system
  12668. */
  12669. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12670. /**
  12671. * Adds a new angular speed gradient
  12672. * @param gradient defines the gradient to use (between 0 and 1)
  12673. * @param factor defines the angular speed to affect to the specified gradient
  12674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12675. * @returns the current particle system
  12676. */
  12677. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12678. /**
  12679. * Remove a specific angular speed gradient
  12680. * @param gradient defines the gradient to remove
  12681. * @returns the current particle system
  12682. */
  12683. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12684. /**
  12685. * Adds a new velocity gradient
  12686. * @param gradient defines the gradient to use (between 0 and 1)
  12687. * @param factor defines the velocity to affect to the specified gradient
  12688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12689. * @returns the current particle system
  12690. */
  12691. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12692. /**
  12693. * Remove a specific velocity gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeVelocityGradient(gradient: number): IParticleSystem;
  12698. /**
  12699. * Adds a new limit velocity gradient
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param factor defines the limit velocity value to affect to the specified gradient
  12702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12703. * @returns the current particle system
  12704. */
  12705. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12706. /**
  12707. * Remove a specific limit velocity gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns the current particle system
  12710. */
  12711. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12712. /**
  12713. * Adds a new drag gradient
  12714. * @param gradient defines the gradient to use (between 0 and 1)
  12715. * @param factor defines the drag value to affect to the specified gradient
  12716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12717. * @returns the current particle system
  12718. */
  12719. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12720. /**
  12721. * Remove a specific drag gradient
  12722. * @param gradient defines the gradient to remove
  12723. * @returns the current particle system
  12724. */
  12725. removeDragGradient(gradient: number): IParticleSystem;
  12726. /**
  12727. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12728. * @param gradient defines the gradient to use (between 0 and 1)
  12729. * @param factor defines the emit rate value to affect to the specified gradient
  12730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12731. * @returns the current particle system
  12732. */
  12733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12734. /**
  12735. * Remove a specific emit rate gradient
  12736. * @param gradient defines the gradient to remove
  12737. * @returns the current particle system
  12738. */
  12739. removeEmitRateGradient(gradient: number): IParticleSystem;
  12740. /**
  12741. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12742. * @param gradient defines the gradient to use (between 0 and 1)
  12743. * @param factor defines the start size value to affect to the specified gradient
  12744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12745. * @returns the current particle system
  12746. */
  12747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12748. /**
  12749. * Remove a specific start size gradient
  12750. * @param gradient defines the gradient to remove
  12751. * @returns the current particle system
  12752. */
  12753. removeStartSizeGradient(gradient: number): IParticleSystem;
  12754. private _createRampGradientTexture;
  12755. /**
  12756. * Gets the current list of ramp gradients.
  12757. * You must use addRampGradient and removeRampGradient to udpate this list
  12758. * @returns the list of ramp gradients
  12759. */
  12760. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12761. /** Force the system to rebuild all gradients that need to be resync */
  12762. forceRefreshGradients(): void;
  12763. private _syncRampGradientTexture;
  12764. /**
  12765. * Adds a new ramp gradient used to remap particle colors
  12766. * @param gradient defines the gradient to use (between 0 and 1)
  12767. * @param color defines the color to affect to the specified gradient
  12768. * @returns the current particle system
  12769. */
  12770. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12771. /**
  12772. * Remove a specific ramp gradient
  12773. * @param gradient defines the gradient to remove
  12774. * @returns the current particle system
  12775. */
  12776. removeRampGradient(gradient: number): ParticleSystem;
  12777. /**
  12778. * Adds a new color gradient
  12779. * @param gradient defines the gradient to use (between 0 and 1)
  12780. * @param color1 defines the color to affect to the specified gradient
  12781. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12782. * @returns this particle system
  12783. */
  12784. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12785. /**
  12786. * Remove a specific color gradient
  12787. * @param gradient defines the gradient to remove
  12788. * @returns this particle system
  12789. */
  12790. removeColorGradient(gradient: number): IParticleSystem;
  12791. private _fetchR;
  12792. protected _reset(): void;
  12793. private _resetEffect;
  12794. private _createVertexBuffers;
  12795. private _createIndexBuffer;
  12796. /**
  12797. * Gets the maximum number of particles active at the same time.
  12798. * @returns The max number of active particles.
  12799. */
  12800. getCapacity(): number;
  12801. /**
  12802. * Gets whether there are still active particles in the system.
  12803. * @returns True if it is alive, otherwise false.
  12804. */
  12805. isAlive(): boolean;
  12806. /**
  12807. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12808. * @returns True if it has been started, otherwise false.
  12809. */
  12810. isStarted(): boolean;
  12811. private _prepareSubEmitterInternalArray;
  12812. /**
  12813. * Starts the particle system and begins to emit
  12814. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12815. */
  12816. start(delay?: number): void;
  12817. /**
  12818. * Stops the particle system.
  12819. * @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.
  12820. */
  12821. stop(stopSubEmitters?: boolean): void;
  12822. /**
  12823. * Remove all active particles
  12824. */
  12825. reset(): void;
  12826. /**
  12827. * @hidden (for internal use only)
  12828. */
  12829. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12830. /**
  12831. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12832. * Its lifetime will start back at 0.
  12833. */
  12834. recycleParticle: (particle: Particle) => void;
  12835. private _stopSubEmitters;
  12836. private _createParticle;
  12837. private _removeFromRoot;
  12838. private _emitFromParticle;
  12839. private _update;
  12840. /** @hidden */
  12841. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12842. /** @hidden */
  12843. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12844. /**
  12845. * Fill the defines array according to the current settings of the particle system
  12846. * @param defines Array to be updated
  12847. * @param blendMode blend mode to take into account when updating the array
  12848. */
  12849. fillDefines(defines: Array<string>, blendMode: number): void;
  12850. /**
  12851. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12852. * @param uniforms Uniforms array to fill
  12853. * @param attributes Attributes array to fill
  12854. * @param samplers Samplers array to fill
  12855. */
  12856. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12857. /** @hidden */
  12858. private _getEffect;
  12859. /**
  12860. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12861. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12862. */
  12863. animate(preWarmOnly?: boolean): void;
  12864. private _appendParticleVertices;
  12865. /**
  12866. * Rebuilds the particle system.
  12867. */
  12868. rebuild(): void;
  12869. /**
  12870. * Is this system ready to be used/rendered
  12871. * @return true if the system is ready
  12872. */
  12873. isReady(): boolean;
  12874. private _render;
  12875. /**
  12876. * Renders the particle system in its current state.
  12877. * @returns the current number of particles
  12878. */
  12879. render(): number;
  12880. /**
  12881. * Disposes the particle system and free the associated resources
  12882. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12883. */
  12884. dispose(disposeTexture?: boolean): void;
  12885. /**
  12886. * Clones the particle system.
  12887. * @param name The name of the cloned object
  12888. * @param newEmitter The new emitter to use
  12889. * @returns the cloned particle system
  12890. */
  12891. clone(name: string, newEmitter: any): ParticleSystem;
  12892. /**
  12893. * Serializes the particle system to a JSON object
  12894. * @param serializeTexture defines if the texture must be serialized as well
  12895. * @returns the JSON object
  12896. */
  12897. serialize(serializeTexture?: boolean): any;
  12898. /** @hidden */
  12899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12900. /** @hidden */
  12901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12902. /**
  12903. * Parses a JSON object to create a particle system.
  12904. * @param parsedParticleSystem The JSON object to parse
  12905. * @param scene The scene to create the particle system in
  12906. * @param rootUrl The root url to use to load external dependencies like texture
  12907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12908. * @returns the Parsed particle system
  12909. */
  12910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12911. }
  12912. }
  12913. declare module BABYLON {
  12914. /**
  12915. * A particle represents one of the element emitted by a particle system.
  12916. * This is mainly define by its coordinates, direction, velocity and age.
  12917. */
  12918. export class Particle {
  12919. /**
  12920. * The particle system the particle belongs to.
  12921. */
  12922. particleSystem: ParticleSystem;
  12923. private static _Count;
  12924. /**
  12925. * Unique ID of the particle
  12926. */
  12927. id: number;
  12928. /**
  12929. * The world position of the particle in the scene.
  12930. */
  12931. position: Vector3;
  12932. /**
  12933. * The world direction of the particle in the scene.
  12934. */
  12935. direction: Vector3;
  12936. /**
  12937. * The color of the particle.
  12938. */
  12939. color: Color4;
  12940. /**
  12941. * The color change of the particle per step.
  12942. */
  12943. colorStep: Color4;
  12944. /**
  12945. * Defines how long will the life of the particle be.
  12946. */
  12947. lifeTime: number;
  12948. /**
  12949. * The current age of the particle.
  12950. */
  12951. age: number;
  12952. /**
  12953. * The current size of the particle.
  12954. */
  12955. size: number;
  12956. /**
  12957. * The current scale of the particle.
  12958. */
  12959. scale: Vector2;
  12960. /**
  12961. * The current angle of the particle.
  12962. */
  12963. angle: number;
  12964. /**
  12965. * Defines how fast is the angle changing.
  12966. */
  12967. angularSpeed: number;
  12968. /**
  12969. * Defines the cell index used by the particle to be rendered from a sprite.
  12970. */
  12971. cellIndex: number;
  12972. /**
  12973. * The information required to support color remapping
  12974. */
  12975. remapData: Vector4;
  12976. /** @hidden */
  12977. _randomCellOffset?: number;
  12978. /** @hidden */
  12979. _initialDirection: Nullable<Vector3>;
  12980. /** @hidden */
  12981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12982. /** @hidden */
  12983. _initialStartSpriteCellID: number;
  12984. /** @hidden */
  12985. _initialEndSpriteCellID: number;
  12986. /** @hidden */
  12987. _currentColorGradient: Nullable<ColorGradient>;
  12988. /** @hidden */
  12989. _currentColor1: Color4;
  12990. /** @hidden */
  12991. _currentColor2: Color4;
  12992. /** @hidden */
  12993. _currentSizeGradient: Nullable<FactorGradient>;
  12994. /** @hidden */
  12995. _currentSize1: number;
  12996. /** @hidden */
  12997. _currentSize2: number;
  12998. /** @hidden */
  12999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13000. /** @hidden */
  13001. _currentAngularSpeed1: number;
  13002. /** @hidden */
  13003. _currentAngularSpeed2: number;
  13004. /** @hidden */
  13005. _currentVelocityGradient: Nullable<FactorGradient>;
  13006. /** @hidden */
  13007. _currentVelocity1: number;
  13008. /** @hidden */
  13009. _currentVelocity2: number;
  13010. /** @hidden */
  13011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13012. /** @hidden */
  13013. _currentLimitVelocity1: number;
  13014. /** @hidden */
  13015. _currentLimitVelocity2: number;
  13016. /** @hidden */
  13017. _currentDragGradient: Nullable<FactorGradient>;
  13018. /** @hidden */
  13019. _currentDrag1: number;
  13020. /** @hidden */
  13021. _currentDrag2: number;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates1: Vector3;
  13024. /** @hidden */
  13025. _randomNoiseCoordinates2: Vector3;
  13026. /** @hidden */
  13027. _localPosition?: Vector3;
  13028. /**
  13029. * Creates a new instance Particle
  13030. * @param particleSystem the particle system the particle belongs to
  13031. */
  13032. constructor(
  13033. /**
  13034. * The particle system the particle belongs to.
  13035. */
  13036. particleSystem: ParticleSystem);
  13037. private updateCellInfoFromSystem;
  13038. /**
  13039. * Defines how the sprite cell index is updated for the particle
  13040. */
  13041. updateCellIndex(): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13044. /** @hidden */
  13045. _inheritParticleInfoToSubEmitters(): void;
  13046. /** @hidden */
  13047. _reset(): void;
  13048. /**
  13049. * Copy the properties of particle to another one.
  13050. * @param other the particle to copy the information to.
  13051. */
  13052. copyTo(other: Particle): void;
  13053. }
  13054. }
  13055. declare module BABYLON {
  13056. /**
  13057. * Particle emitter represents a volume emitting particles.
  13058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13059. */
  13060. export interface IParticleEmitterType {
  13061. /**
  13062. * Called by the particle System when the direction is computed for the created particle.
  13063. * @param worldMatrix is the world matrix of the particle system
  13064. * @param directionToUpdate is the direction vector to update with the result
  13065. * @param particle is the particle we are computed the direction for
  13066. * @param isLocal defines if the direction should be set in local space
  13067. */
  13068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13069. /**
  13070. * Called by the particle System when the position is computed for the created particle.
  13071. * @param worldMatrix is the world matrix of the particle system
  13072. * @param positionToUpdate is the position vector to update with the result
  13073. * @param particle is the particle we are computed the position for
  13074. * @param isLocal defines if the position should be set in local space
  13075. */
  13076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13077. /**
  13078. * Clones the current emitter and returns a copy of it
  13079. * @returns the new emitter
  13080. */
  13081. clone(): IParticleEmitterType;
  13082. /**
  13083. * Called by the GPUParticleSystem to setup the update shader
  13084. * @param effect defines the update shader
  13085. */
  13086. applyToShader(effect: Effect): void;
  13087. /**
  13088. * Returns a string to use to update the GPU particles update shader
  13089. * @returns the effect defines string
  13090. */
  13091. getEffectDefines(): string;
  13092. /**
  13093. * Returns a string representing the class name
  13094. * @returns a string containing the class name
  13095. */
  13096. getClassName(): string;
  13097. /**
  13098. * Serializes the particle system to a JSON object.
  13099. * @returns the JSON object
  13100. */
  13101. serialize(): any;
  13102. /**
  13103. * Parse properties from a JSON object
  13104. * @param serializationObject defines the JSON object
  13105. * @param scene defines the hosting scene
  13106. */
  13107. parse(serializationObject: any, scene: Scene): void;
  13108. }
  13109. }
  13110. declare module BABYLON {
  13111. /**
  13112. * Particle emitter emitting particles from the inside of a box.
  13113. * It emits the particles randomly between 2 given directions.
  13114. */
  13115. export class BoxParticleEmitter implements IParticleEmitterType {
  13116. /**
  13117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13118. */
  13119. direction1: Vector3;
  13120. /**
  13121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13122. */
  13123. direction2: Vector3;
  13124. /**
  13125. * 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.
  13126. */
  13127. minEmitBox: Vector3;
  13128. /**
  13129. * 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.
  13130. */
  13131. maxEmitBox: Vector3;
  13132. /**
  13133. * Creates a new instance BoxParticleEmitter
  13134. */
  13135. constructor();
  13136. /**
  13137. * Called by the particle System when the direction is computed for the created particle.
  13138. * @param worldMatrix is the world matrix of the particle system
  13139. * @param directionToUpdate is the direction vector to update with the result
  13140. * @param particle is the particle we are computed the direction for
  13141. * @param isLocal defines if the direction should be set in local space
  13142. */
  13143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13144. /**
  13145. * Called by the particle System when the position is computed for the created particle.
  13146. * @param worldMatrix is the world matrix of the particle system
  13147. * @param positionToUpdate is the position vector to update with the result
  13148. * @param particle is the particle we are computed the position for
  13149. * @param isLocal defines if the position should be set in local space
  13150. */
  13151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13152. /**
  13153. * Clones the current emitter and returns a copy of it
  13154. * @returns the new emitter
  13155. */
  13156. clone(): BoxParticleEmitter;
  13157. /**
  13158. * Called by the GPUParticleSystem to setup the update shader
  13159. * @param effect defines the update shader
  13160. */
  13161. applyToShader(effect: Effect): void;
  13162. /**
  13163. * Returns a string to use to update the GPU particles update shader
  13164. * @returns a string containng the defines string
  13165. */
  13166. getEffectDefines(): string;
  13167. /**
  13168. * Returns the string "BoxParticleEmitter"
  13169. * @returns a string containing the class name
  13170. */
  13171. getClassName(): string;
  13172. /**
  13173. * Serializes the particle system to a JSON object.
  13174. * @returns the JSON object
  13175. */
  13176. serialize(): any;
  13177. /**
  13178. * Parse properties from a JSON object
  13179. * @param serializationObject defines the JSON object
  13180. */
  13181. parse(serializationObject: any): void;
  13182. }
  13183. }
  13184. declare module BABYLON {
  13185. /**
  13186. * Particle emitter emitting particles from the inside of a cone.
  13187. * It emits the particles alongside the cone volume from the base to the particle.
  13188. * The emission direction might be randomized.
  13189. */
  13190. export class ConeParticleEmitter implements IParticleEmitterType {
  13191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13192. directionRandomizer: number;
  13193. private _radius;
  13194. private _angle;
  13195. private _height;
  13196. /**
  13197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13198. */
  13199. radiusRange: number;
  13200. /**
  13201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13202. */
  13203. heightRange: number;
  13204. /**
  13205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13206. */
  13207. emitFromSpawnPointOnly: boolean;
  13208. /**
  13209. * Gets or sets the radius of the emission cone
  13210. */
  13211. get radius(): number;
  13212. set radius(value: number);
  13213. /**
  13214. * Gets or sets the angle of the emission cone
  13215. */
  13216. get angle(): number;
  13217. set angle(value: number);
  13218. private _buildHeight;
  13219. /**
  13220. * Creates a new instance ConeParticleEmitter
  13221. * @param radius the radius of the emission cone (1 by default)
  13222. * @param angle the cone base angle (PI by default)
  13223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13224. */
  13225. constructor(radius?: number, angle?: number,
  13226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13227. directionRandomizer?: number);
  13228. /**
  13229. * Called by the particle System when the direction is computed for the created particle.
  13230. * @param worldMatrix is the world matrix of the particle system
  13231. * @param directionToUpdate is the direction vector to update with the result
  13232. * @param particle is the particle we are computed the direction for
  13233. * @param isLocal defines if the direction should be set in local space
  13234. */
  13235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13236. /**
  13237. * Called by the particle System when the position is computed for the created particle.
  13238. * @param worldMatrix is the world matrix of the particle system
  13239. * @param positionToUpdate is the position vector to update with the result
  13240. * @param particle is the particle we are computed the position for
  13241. * @param isLocal defines if the position should be set in local space
  13242. */
  13243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13244. /**
  13245. * Clones the current emitter and returns a copy of it
  13246. * @returns the new emitter
  13247. */
  13248. clone(): ConeParticleEmitter;
  13249. /**
  13250. * Called by the GPUParticleSystem to setup the update shader
  13251. * @param effect defines the update shader
  13252. */
  13253. applyToShader(effect: Effect): void;
  13254. /**
  13255. * Returns a string to use to update the GPU particles update shader
  13256. * @returns a string containng the defines string
  13257. */
  13258. getEffectDefines(): string;
  13259. /**
  13260. * Returns the string "ConeParticleEmitter"
  13261. * @returns a string containing the class name
  13262. */
  13263. getClassName(): string;
  13264. /**
  13265. * Serializes the particle system to a JSON object.
  13266. * @returns the JSON object
  13267. */
  13268. serialize(): any;
  13269. /**
  13270. * Parse properties from a JSON object
  13271. * @param serializationObject defines the JSON object
  13272. */
  13273. parse(serializationObject: any): void;
  13274. }
  13275. }
  13276. declare module BABYLON {
  13277. /**
  13278. * Particle emitter emitting particles from the inside of a cylinder.
  13279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13280. */
  13281. export class CylinderParticleEmitter implements IParticleEmitterType {
  13282. /**
  13283. * The radius of the emission cylinder.
  13284. */
  13285. radius: number;
  13286. /**
  13287. * The height of the emission cylinder.
  13288. */
  13289. height: number;
  13290. /**
  13291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13292. */
  13293. radiusRange: number;
  13294. /**
  13295. * How much to randomize the particle direction [0-1].
  13296. */
  13297. directionRandomizer: number;
  13298. /**
  13299. * Creates a new instance CylinderParticleEmitter
  13300. * @param radius the radius of the emission cylinder (1 by default)
  13301. * @param height the height of the emission cylinder (1 by default)
  13302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13304. */
  13305. constructor(
  13306. /**
  13307. * The radius of the emission cylinder.
  13308. */
  13309. radius?: number,
  13310. /**
  13311. * The height of the emission cylinder.
  13312. */
  13313. height?: number,
  13314. /**
  13315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13316. */
  13317. radiusRange?: number,
  13318. /**
  13319. * How much to randomize the particle direction [0-1].
  13320. */
  13321. directionRandomizer?: number);
  13322. /**
  13323. * Called by the particle System when the direction is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param directionToUpdate is the direction vector to update with the result
  13326. * @param particle is the particle we are computed the direction for
  13327. * @param isLocal defines if the direction should be set in local space
  13328. */
  13329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Called by the particle System when the position is computed for the created particle.
  13332. * @param worldMatrix is the world matrix of the particle system
  13333. * @param positionToUpdate is the position vector to update with the result
  13334. * @param particle is the particle we are computed the position for
  13335. * @param isLocal defines if the position should be set in local space
  13336. */
  13337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13338. /**
  13339. * Clones the current emitter and returns a copy of it
  13340. * @returns the new emitter
  13341. */
  13342. clone(): CylinderParticleEmitter;
  13343. /**
  13344. * Called by the GPUParticleSystem to setup the update shader
  13345. * @param effect defines the update shader
  13346. */
  13347. applyToShader(effect: Effect): void;
  13348. /**
  13349. * Returns a string to use to update the GPU particles update shader
  13350. * @returns a string containng the defines string
  13351. */
  13352. getEffectDefines(): string;
  13353. /**
  13354. * Returns the string "CylinderParticleEmitter"
  13355. * @returns a string containing the class name
  13356. */
  13357. getClassName(): string;
  13358. /**
  13359. * Serializes the particle system to a JSON object.
  13360. * @returns the JSON object
  13361. */
  13362. serialize(): any;
  13363. /**
  13364. * Parse properties from a JSON object
  13365. * @param serializationObject defines the JSON object
  13366. */
  13367. parse(serializationObject: any): void;
  13368. }
  13369. /**
  13370. * Particle emitter emitting particles from the inside of a cylinder.
  13371. * It emits the particles randomly between two vectors.
  13372. */
  13373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13374. /**
  13375. * The min limit of the emission direction.
  13376. */
  13377. direction1: Vector3;
  13378. /**
  13379. * The max limit of the emission direction.
  13380. */
  13381. direction2: Vector3;
  13382. /**
  13383. * Creates a new instance CylinderDirectedParticleEmitter
  13384. * @param radius the radius of the emission cylinder (1 by default)
  13385. * @param height the height of the emission cylinder (1 by default)
  13386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13387. * @param direction1 the min limit of the emission direction (up vector by default)
  13388. * @param direction2 the max limit of the emission direction (up vector by default)
  13389. */
  13390. constructor(radius?: number, height?: number, radiusRange?: number,
  13391. /**
  13392. * The min limit of the emission direction.
  13393. */
  13394. direction1?: Vector3,
  13395. /**
  13396. * The max limit of the emission direction.
  13397. */
  13398. direction2?: Vector3);
  13399. /**
  13400. * Called by the particle System when the direction is computed for the created particle.
  13401. * @param worldMatrix is the world matrix of the particle system
  13402. * @param directionToUpdate is the direction vector to update with the result
  13403. * @param particle is the particle we are computed the direction for
  13404. */
  13405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13406. /**
  13407. * Clones the current emitter and returns a copy of it
  13408. * @returns the new emitter
  13409. */
  13410. clone(): CylinderDirectedParticleEmitter;
  13411. /**
  13412. * Called by the GPUParticleSystem to setup the update shader
  13413. * @param effect defines the update shader
  13414. */
  13415. applyToShader(effect: Effect): void;
  13416. /**
  13417. * Returns a string to use to update the GPU particles update shader
  13418. * @returns a string containng the defines string
  13419. */
  13420. getEffectDefines(): string;
  13421. /**
  13422. * Returns the string "CylinderDirectedParticleEmitter"
  13423. * @returns a string containing the class name
  13424. */
  13425. getClassName(): string;
  13426. /**
  13427. * Serializes the particle system to a JSON object.
  13428. * @returns the JSON object
  13429. */
  13430. serialize(): any;
  13431. /**
  13432. * Parse properties from a JSON object
  13433. * @param serializationObject defines the JSON object
  13434. */
  13435. parse(serializationObject: any): void;
  13436. }
  13437. }
  13438. declare module BABYLON {
  13439. /**
  13440. * Particle emitter emitting particles from the inside of a hemisphere.
  13441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13442. */
  13443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13444. /**
  13445. * The radius of the emission hemisphere.
  13446. */
  13447. radius: number;
  13448. /**
  13449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13450. */
  13451. radiusRange: number;
  13452. /**
  13453. * How much to randomize the particle direction [0-1].
  13454. */
  13455. directionRandomizer: number;
  13456. /**
  13457. * Creates a new instance HemisphericParticleEmitter
  13458. * @param radius the radius of the emission hemisphere (1 by default)
  13459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13461. */
  13462. constructor(
  13463. /**
  13464. * The radius of the emission hemisphere.
  13465. */
  13466. radius?: number,
  13467. /**
  13468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13469. */
  13470. radiusRange?: number,
  13471. /**
  13472. * How much to randomize the particle direction [0-1].
  13473. */
  13474. directionRandomizer?: number);
  13475. /**
  13476. * Called by the particle System when the direction is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param directionToUpdate is the direction vector to update with the result
  13479. * @param particle is the particle we are computed the direction for
  13480. * @param isLocal defines if the direction should be set in local space
  13481. */
  13482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Called by the particle System when the position is computed for the created particle.
  13485. * @param worldMatrix is the world matrix of the particle system
  13486. * @param positionToUpdate is the position vector to update with the result
  13487. * @param particle is the particle we are computed the position for
  13488. * @param isLocal defines if the position should be set in local space
  13489. */
  13490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13491. /**
  13492. * Clones the current emitter and returns a copy of it
  13493. * @returns the new emitter
  13494. */
  13495. clone(): HemisphericParticleEmitter;
  13496. /**
  13497. * Called by the GPUParticleSystem to setup the update shader
  13498. * @param effect defines the update shader
  13499. */
  13500. applyToShader(effect: Effect): void;
  13501. /**
  13502. * Returns a string to use to update the GPU particles update shader
  13503. * @returns a string containng the defines string
  13504. */
  13505. getEffectDefines(): string;
  13506. /**
  13507. * Returns the string "HemisphericParticleEmitter"
  13508. * @returns a string containing the class name
  13509. */
  13510. getClassName(): string;
  13511. /**
  13512. * Serializes the particle system to a JSON object.
  13513. * @returns the JSON object
  13514. */
  13515. serialize(): any;
  13516. /**
  13517. * Parse properties from a JSON object
  13518. * @param serializationObject defines the JSON object
  13519. */
  13520. parse(serializationObject: any): void;
  13521. }
  13522. }
  13523. declare module BABYLON {
  13524. /**
  13525. * Particle emitter emitting particles from a point.
  13526. * It emits the particles randomly between 2 given directions.
  13527. */
  13528. export class PointParticleEmitter implements IParticleEmitterType {
  13529. /**
  13530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13531. */
  13532. direction1: Vector3;
  13533. /**
  13534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13535. */
  13536. direction2: Vector3;
  13537. /**
  13538. * Creates a new instance PointParticleEmitter
  13539. */
  13540. constructor();
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): PointParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "PointParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module BABYLON {
  13590. /**
  13591. * Particle emitter emitting particles from the inside of a sphere.
  13592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13593. */
  13594. export class SphereParticleEmitter implements IParticleEmitterType {
  13595. /**
  13596. * The radius of the emission sphere.
  13597. */
  13598. radius: number;
  13599. /**
  13600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13601. */
  13602. radiusRange: number;
  13603. /**
  13604. * How much to randomize the particle direction [0-1].
  13605. */
  13606. directionRandomizer: number;
  13607. /**
  13608. * Creates a new instance SphereParticleEmitter
  13609. * @param radius the radius of the emission sphere (1 by default)
  13610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13612. */
  13613. constructor(
  13614. /**
  13615. * The radius of the emission sphere.
  13616. */
  13617. radius?: number,
  13618. /**
  13619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13620. */
  13621. radiusRange?: number,
  13622. /**
  13623. * How much to randomize the particle direction [0-1].
  13624. */
  13625. directionRandomizer?: number);
  13626. /**
  13627. * Called by the particle System when the direction is computed for the created particle.
  13628. * @param worldMatrix is the world matrix of the particle system
  13629. * @param directionToUpdate is the direction vector to update with the result
  13630. * @param particle is the particle we are computed the direction for
  13631. * @param isLocal defines if the direction should be set in local space
  13632. */
  13633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13634. /**
  13635. * Called by the particle System when the position is computed for the created particle.
  13636. * @param worldMatrix is the world matrix of the particle system
  13637. * @param positionToUpdate is the position vector to update with the result
  13638. * @param particle is the particle we are computed the position for
  13639. * @param isLocal defines if the position should be set in local space
  13640. */
  13641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13642. /**
  13643. * Clones the current emitter and returns a copy of it
  13644. * @returns the new emitter
  13645. */
  13646. clone(): SphereParticleEmitter;
  13647. /**
  13648. * Called by the GPUParticleSystem to setup the update shader
  13649. * @param effect defines the update shader
  13650. */
  13651. applyToShader(effect: Effect): void;
  13652. /**
  13653. * Returns a string to use to update the GPU particles update shader
  13654. * @returns a string containng the defines string
  13655. */
  13656. getEffectDefines(): string;
  13657. /**
  13658. * Returns the string "SphereParticleEmitter"
  13659. * @returns a string containing the class name
  13660. */
  13661. getClassName(): string;
  13662. /**
  13663. * Serializes the particle system to a JSON object.
  13664. * @returns the JSON object
  13665. */
  13666. serialize(): any;
  13667. /**
  13668. * Parse properties from a JSON object
  13669. * @param serializationObject defines the JSON object
  13670. */
  13671. parse(serializationObject: any): void;
  13672. }
  13673. /**
  13674. * Particle emitter emitting particles from the inside of a sphere.
  13675. * It emits the particles randomly between two vectors.
  13676. */
  13677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13678. /**
  13679. * The min limit of the emission direction.
  13680. */
  13681. direction1: Vector3;
  13682. /**
  13683. * The max limit of the emission direction.
  13684. */
  13685. direction2: Vector3;
  13686. /**
  13687. * Creates a new instance SphereDirectedParticleEmitter
  13688. * @param radius the radius of the emission sphere (1 by default)
  13689. * @param direction1 the min limit of the emission direction (up vector by default)
  13690. * @param direction2 the max limit of the emission direction (up vector by default)
  13691. */
  13692. constructor(radius?: number,
  13693. /**
  13694. * The min limit of the emission direction.
  13695. */
  13696. direction1?: Vector3,
  13697. /**
  13698. * The max limit of the emission direction.
  13699. */
  13700. direction2?: Vector3);
  13701. /**
  13702. * Called by the particle System when the direction is computed for the created particle.
  13703. * @param worldMatrix is the world matrix of the particle system
  13704. * @param directionToUpdate is the direction vector to update with the result
  13705. * @param particle is the particle we are computed the direction for
  13706. */
  13707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): SphereDirectedParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "SphereDirectedParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a custom list of positions.
  13743. */
  13744. export class CustomParticleEmitter implements IParticleEmitterType {
  13745. /**
  13746. * Gets or sets the position generator that will create the inital position of each particle.
  13747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13748. */
  13749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13750. /**
  13751. * Gets or sets the destination generator that will create the final destination of each particle.
  13752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13753. */
  13754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13755. /**
  13756. * Creates a new instance CustomParticleEmitter
  13757. */
  13758. constructor();
  13759. /**
  13760. * Called by the particle System when the direction is computed for the created particle.
  13761. * @param worldMatrix is the world matrix of the particle system
  13762. * @param directionToUpdate is the direction vector to update with the result
  13763. * @param particle is the particle we are computed the direction for
  13764. * @param isLocal defines if the direction should be set in local space
  13765. */
  13766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13767. /**
  13768. * Called by the particle System when the position is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param positionToUpdate is the position vector to update with the result
  13771. * @param particle is the particle we are computed the position for
  13772. * @param isLocal defines if the position should be set in local space
  13773. */
  13774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Clones the current emitter and returns a copy of it
  13777. * @returns the new emitter
  13778. */
  13779. clone(): CustomParticleEmitter;
  13780. /**
  13781. * Called by the GPUParticleSystem to setup the update shader
  13782. * @param effect defines the update shader
  13783. */
  13784. applyToShader(effect: Effect): void;
  13785. /**
  13786. * Returns a string to use to update the GPU particles update shader
  13787. * @returns a string containng the defines string
  13788. */
  13789. getEffectDefines(): string;
  13790. /**
  13791. * Returns the string "PointParticleEmitter"
  13792. * @returns a string containing the class name
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Serializes the particle system to a JSON object.
  13797. * @returns the JSON object
  13798. */
  13799. serialize(): any;
  13800. /**
  13801. * Parse properties from a JSON object
  13802. * @param serializationObject defines the JSON object
  13803. */
  13804. parse(serializationObject: any): void;
  13805. }
  13806. }
  13807. declare module BABYLON {
  13808. /**
  13809. * Particle emitter emitting particles from the inside of a box.
  13810. * It emits the particles randomly between 2 given directions.
  13811. */
  13812. export class MeshParticleEmitter implements IParticleEmitterType {
  13813. private _indices;
  13814. private _positions;
  13815. private _normals;
  13816. private _storedNormal;
  13817. private _mesh;
  13818. /**
  13819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13820. */
  13821. direction1: Vector3;
  13822. /**
  13823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13824. */
  13825. direction2: Vector3;
  13826. /**
  13827. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13828. */
  13829. useMeshNormalsForDirection: boolean;
  13830. /** Defines the mesh to use as source */
  13831. get mesh(): Nullable<AbstractMesh>;
  13832. set mesh(value: Nullable<AbstractMesh>);
  13833. /**
  13834. * Creates a new instance MeshParticleEmitter
  13835. * @param mesh defines the mesh to use as source
  13836. */
  13837. constructor(mesh?: Nullable<AbstractMesh>);
  13838. /**
  13839. * Called by the particle System when the direction is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param directionToUpdate is the direction vector to update with the result
  13842. * @param particle is the particle we are computed the direction for
  13843. * @param isLocal defines if the direction should be set in local space
  13844. */
  13845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Called by the particle System when the position is computed for the created particle.
  13848. * @param worldMatrix is the world matrix of the particle system
  13849. * @param positionToUpdate is the position vector to update with the result
  13850. * @param particle is the particle we are computed the position for
  13851. * @param isLocal defines if the position should be set in local space
  13852. */
  13853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13854. /**
  13855. * Clones the current emitter and returns a copy of it
  13856. * @returns the new emitter
  13857. */
  13858. clone(): MeshParticleEmitter;
  13859. /**
  13860. * Called by the GPUParticleSystem to setup the update shader
  13861. * @param effect defines the update shader
  13862. */
  13863. applyToShader(effect: Effect): void;
  13864. /**
  13865. * Returns a string to use to update the GPU particles update shader
  13866. * @returns a string containng the defines string
  13867. */
  13868. getEffectDefines(): string;
  13869. /**
  13870. * Returns the string "BoxParticleEmitter"
  13871. * @returns a string containing the class name
  13872. */
  13873. getClassName(): string;
  13874. /**
  13875. * Serializes the particle system to a JSON object.
  13876. * @returns the JSON object
  13877. */
  13878. serialize(): any;
  13879. /**
  13880. * Parse properties from a JSON object
  13881. * @param serializationObject defines the JSON object
  13882. * @param scene defines the hosting scene
  13883. */
  13884. parse(serializationObject: any, scene: Scene): void;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Interface representing a particle system in Babylon.js.
  13890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13892. */
  13893. export interface IParticleSystem {
  13894. /**
  13895. * List of animations used by the particle system.
  13896. */
  13897. animations: Animation[];
  13898. /**
  13899. * The id of the Particle system.
  13900. */
  13901. id: string;
  13902. /**
  13903. * The name of the Particle system.
  13904. */
  13905. name: string;
  13906. /**
  13907. * The emitter represents the Mesh or position we are attaching the particle system to.
  13908. */
  13909. emitter: Nullable<AbstractMesh | Vector3>;
  13910. /**
  13911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13912. */
  13913. isBillboardBased: boolean;
  13914. /**
  13915. * The rendering group used by the Particle system to chose when to render.
  13916. */
  13917. renderingGroupId: number;
  13918. /**
  13919. * The layer mask we are rendering the particles through.
  13920. */
  13921. layerMask: number;
  13922. /**
  13923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13924. */
  13925. updateSpeed: number;
  13926. /**
  13927. * The amount of time the particle system is running (depends of the overall update speed).
  13928. */
  13929. targetStopDuration: number;
  13930. /**
  13931. * The texture used to render each particle. (this can be a spritesheet)
  13932. */
  13933. particleTexture: Nullable<Texture>;
  13934. /**
  13935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13936. */
  13937. blendMode: number;
  13938. /**
  13939. * Minimum life time of emitting particles.
  13940. */
  13941. minLifeTime: number;
  13942. /**
  13943. * Maximum life time of emitting particles.
  13944. */
  13945. maxLifeTime: number;
  13946. /**
  13947. * Minimum Size of emitting particles.
  13948. */
  13949. minSize: number;
  13950. /**
  13951. * Maximum Size of emitting particles.
  13952. */
  13953. maxSize: number;
  13954. /**
  13955. * Minimum scale of emitting particles on X axis.
  13956. */
  13957. minScaleX: number;
  13958. /**
  13959. * Maximum scale of emitting particles on X axis.
  13960. */
  13961. maxScaleX: number;
  13962. /**
  13963. * Minimum scale of emitting particles on Y axis.
  13964. */
  13965. minScaleY: number;
  13966. /**
  13967. * Maximum scale of emitting particles on Y axis.
  13968. */
  13969. maxScaleY: number;
  13970. /**
  13971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13972. */
  13973. color1: Color4;
  13974. /**
  13975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13976. */
  13977. color2: Color4;
  13978. /**
  13979. * Color the particle will have at the end of its lifetime.
  13980. */
  13981. colorDead: Color4;
  13982. /**
  13983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13984. */
  13985. emitRate: number;
  13986. /**
  13987. * You can use gravity if you want to give an orientation to your particles.
  13988. */
  13989. gravity: Vector3;
  13990. /**
  13991. * Minimum power of emitting particles.
  13992. */
  13993. minEmitPower: number;
  13994. /**
  13995. * Maximum power of emitting particles.
  13996. */
  13997. maxEmitPower: number;
  13998. /**
  13999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14000. */
  14001. minAngularSpeed: number;
  14002. /**
  14003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14004. */
  14005. maxAngularSpeed: number;
  14006. /**
  14007. * Gets or sets the minimal initial rotation in radians.
  14008. */
  14009. minInitialRotation: number;
  14010. /**
  14011. * Gets or sets the maximal initial rotation in radians.
  14012. */
  14013. maxInitialRotation: number;
  14014. /**
  14015. * The particle emitter type defines the emitter used by the particle system.
  14016. * It can be for example box, sphere, or cone...
  14017. */
  14018. particleEmitterType: Nullable<IParticleEmitterType>;
  14019. /**
  14020. * Defines the delay in milliseconds before starting the system (0 by default)
  14021. */
  14022. startDelay: number;
  14023. /**
  14024. * 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
  14025. */
  14026. preWarmCycles: number;
  14027. /**
  14028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14029. */
  14030. preWarmStepOffset: number;
  14031. /**
  14032. * 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)
  14033. */
  14034. spriteCellChangeSpeed: number;
  14035. /**
  14036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14037. */
  14038. startSpriteCellID: number;
  14039. /**
  14040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14041. */
  14042. endSpriteCellID: number;
  14043. /**
  14044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14045. */
  14046. spriteCellWidth: number;
  14047. /**
  14048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14049. */
  14050. spriteCellHeight: number;
  14051. /**
  14052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14053. */
  14054. spriteRandomStartCell: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14057. */
  14058. isAnimationSheetEnabled: boolean;
  14059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14060. translationPivot: Vector2;
  14061. /**
  14062. * Gets or sets a texture used to add random noise to particle positions
  14063. */
  14064. noiseTexture: Nullable<BaseTexture>;
  14065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14066. noiseStrength: Vector3;
  14067. /**
  14068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14070. */
  14071. billboardMode: number;
  14072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14073. limitVelocityDamping: number;
  14074. /**
  14075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14076. */
  14077. beginAnimationOnStart: boolean;
  14078. /**
  14079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14080. */
  14081. beginAnimationFrom: number;
  14082. /**
  14083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14084. */
  14085. beginAnimationTo: number;
  14086. /**
  14087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14088. */
  14089. beginAnimationLoop: boolean;
  14090. /**
  14091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14092. */
  14093. disposeOnStop: boolean;
  14094. /**
  14095. * Specifies if the particles are updated in emitter local space or world space
  14096. */
  14097. isLocal: boolean;
  14098. /** Snippet ID if the particle system was created from the snippet server */
  14099. snippetId: string;
  14100. /**
  14101. * Gets the maximum number of particles active at the same time.
  14102. * @returns The max number of active particles.
  14103. */
  14104. getCapacity(): number;
  14105. /**
  14106. * Gets the number of particles active at the same time.
  14107. * @returns The number of active particles.
  14108. */
  14109. getActiveCount(): number;
  14110. /**
  14111. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14112. * @returns True if it has been started, otherwise false.
  14113. */
  14114. isStarted(): boolean;
  14115. /**
  14116. * Animates the particle system for this frame.
  14117. */
  14118. animate(): void;
  14119. /**
  14120. * Renders the particle system in its current state.
  14121. * @returns the current number of particles
  14122. */
  14123. render(): number;
  14124. /**
  14125. * Dispose the particle system and frees its associated resources.
  14126. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14127. */
  14128. dispose(disposeTexture?: boolean): void;
  14129. /**
  14130. * An event triggered when the system is disposed
  14131. */
  14132. onDisposeObservable: Observable<IParticleSystem>;
  14133. /**
  14134. * Clones the particle system.
  14135. * @param name The name of the cloned object
  14136. * @param newEmitter The new emitter to use
  14137. * @returns the cloned particle system
  14138. */
  14139. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14140. /**
  14141. * Serializes the particle system to a JSON object
  14142. * @param serializeTexture defines if the texture must be serialized as well
  14143. * @returns the JSON object
  14144. */
  14145. serialize(serializeTexture: boolean): any;
  14146. /**
  14147. * Rebuild the particle system
  14148. */
  14149. rebuild(): void;
  14150. /** Force the system to rebuild all gradients that need to be resync */
  14151. forceRefreshGradients(): void;
  14152. /**
  14153. * Starts the particle system and begins to emit
  14154. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14155. */
  14156. start(delay?: number): void;
  14157. /**
  14158. * Stops the particle system.
  14159. */
  14160. stop(): void;
  14161. /**
  14162. * Remove all active particles
  14163. */
  14164. reset(): void;
  14165. /**
  14166. * Gets a boolean indicating that the system is stopping
  14167. * @returns true if the system is currently stopping
  14168. */
  14169. isStopping(): boolean;
  14170. /**
  14171. * Is this system ready to be used/rendered
  14172. * @return true if the system is ready
  14173. */
  14174. isReady(): boolean;
  14175. /**
  14176. * Returns the string "ParticleSystem"
  14177. * @returns a string containing the class name
  14178. */
  14179. getClassName(): string;
  14180. /**
  14181. * Gets the custom effect used to render the particles
  14182. * @param blendMode Blend mode for which the effect should be retrieved
  14183. * @returns The effect
  14184. */
  14185. getCustomEffect(blendMode: number): Nullable<Effect>;
  14186. /**
  14187. * Sets the custom effect used to render the particles
  14188. * @param effect The effect to set
  14189. * @param blendMode Blend mode for which the effect should be set
  14190. */
  14191. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14192. /**
  14193. * Fill the defines array according to the current settings of the particle system
  14194. * @param defines Array to be updated
  14195. * @param blendMode blend mode to take into account when updating the array
  14196. */
  14197. fillDefines(defines: Array<string>, blendMode: number): void;
  14198. /**
  14199. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14200. * @param uniforms Uniforms array to fill
  14201. * @param attributes Attributes array to fill
  14202. * @param samplers Samplers array to fill
  14203. */
  14204. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14205. /**
  14206. * Observable that will be called just before the particles are drawn
  14207. */
  14208. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14209. /**
  14210. * Gets the name of the particle vertex shader
  14211. */
  14212. vertexShaderName: string;
  14213. /**
  14214. * Adds a new color gradient
  14215. * @param gradient defines the gradient to use (between 0 and 1)
  14216. * @param color1 defines the color to affect to the specified gradient
  14217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14218. * @returns the current particle system
  14219. */
  14220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14221. /**
  14222. * Remove a specific color gradient
  14223. * @param gradient defines the gradient to remove
  14224. * @returns the current particle system
  14225. */
  14226. removeColorGradient(gradient: number): IParticleSystem;
  14227. /**
  14228. * Adds a new size gradient
  14229. * @param gradient defines the gradient to use (between 0 and 1)
  14230. * @param factor defines the size factor to affect to the specified gradient
  14231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14232. * @returns the current particle system
  14233. */
  14234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14235. /**
  14236. * Remove a specific size gradient
  14237. * @param gradient defines the gradient to remove
  14238. * @returns the current particle system
  14239. */
  14240. removeSizeGradient(gradient: number): IParticleSystem;
  14241. /**
  14242. * Gets the current list of color gradients.
  14243. * You must use addColorGradient and removeColorGradient to udpate this list
  14244. * @returns the list of color gradients
  14245. */
  14246. getColorGradients(): Nullable<Array<ColorGradient>>;
  14247. /**
  14248. * Gets the current list of size gradients.
  14249. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14250. * @returns the list of size gradients
  14251. */
  14252. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Gets the current list of angular speed gradients.
  14255. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14256. * @returns the list of angular speed gradients
  14257. */
  14258. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14259. /**
  14260. * Adds a new angular speed gradient
  14261. * @param gradient defines the gradient to use (between 0 and 1)
  14262. * @param factor defines the angular speed to affect to the specified gradient
  14263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14264. * @returns the current particle system
  14265. */
  14266. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14267. /**
  14268. * Remove a specific angular speed gradient
  14269. * @param gradient defines the gradient to remove
  14270. * @returns the current particle system
  14271. */
  14272. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14273. /**
  14274. * Gets the current list of velocity gradients.
  14275. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14276. * @returns the list of velocity gradients
  14277. */
  14278. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14279. /**
  14280. * Adds a new velocity gradient
  14281. * @param gradient defines the gradient to use (between 0 and 1)
  14282. * @param factor defines the velocity to affect to the specified gradient
  14283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14284. * @returns the current particle system
  14285. */
  14286. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14287. /**
  14288. * Remove a specific velocity gradient
  14289. * @param gradient defines the gradient to remove
  14290. * @returns the current particle system
  14291. */
  14292. removeVelocityGradient(gradient: number): IParticleSystem;
  14293. /**
  14294. * Gets the current list of limit velocity gradients.
  14295. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14296. * @returns the list of limit velocity gradients
  14297. */
  14298. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Adds a new limit velocity gradient
  14301. * @param gradient defines the gradient to use (between 0 and 1)
  14302. * @param factor defines the limit velocity to affect to the specified gradient
  14303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14304. * @returns the current particle system
  14305. */
  14306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14307. /**
  14308. * Remove a specific limit velocity gradient
  14309. * @param gradient defines the gradient to remove
  14310. * @returns the current particle system
  14311. */
  14312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14313. /**
  14314. * Adds a new drag gradient
  14315. * @param gradient defines the gradient to use (between 0 and 1)
  14316. * @param factor defines the drag to affect to the specified gradient
  14317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14318. * @returns the current particle system
  14319. */
  14320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14321. /**
  14322. * Remove a specific drag gradient
  14323. * @param gradient defines the gradient to remove
  14324. * @returns the current particle system
  14325. */
  14326. removeDragGradient(gradient: number): IParticleSystem;
  14327. /**
  14328. * Gets the current list of drag gradients.
  14329. * You must use addDragGradient and removeDragGradient to udpate this list
  14330. * @returns the list of drag gradients
  14331. */
  14332. getDragGradients(): Nullable<Array<FactorGradient>>;
  14333. /**
  14334. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14335. * @param gradient defines the gradient to use (between 0 and 1)
  14336. * @param factor defines the emit rate to affect to the specified gradient
  14337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14338. * @returns the current particle system
  14339. */
  14340. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14341. /**
  14342. * Remove a specific emit rate gradient
  14343. * @param gradient defines the gradient to remove
  14344. * @returns the current particle system
  14345. */
  14346. removeEmitRateGradient(gradient: number): IParticleSystem;
  14347. /**
  14348. * Gets the current list of emit rate gradients.
  14349. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14350. * @returns the list of emit rate gradients
  14351. */
  14352. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14353. /**
  14354. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14355. * @param gradient defines the gradient to use (between 0 and 1)
  14356. * @param factor defines the start size to affect to the specified gradient
  14357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14358. * @returns the current particle system
  14359. */
  14360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14361. /**
  14362. * Remove a specific start size gradient
  14363. * @param gradient defines the gradient to remove
  14364. * @returns the current particle system
  14365. */
  14366. removeStartSizeGradient(gradient: number): IParticleSystem;
  14367. /**
  14368. * Gets the current list of start size gradients.
  14369. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14370. * @returns the list of start size gradients
  14371. */
  14372. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Adds a new life time gradient
  14375. * @param gradient defines the gradient to use (between 0 and 1)
  14376. * @param factor defines the life time factor to affect to the specified gradient
  14377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14378. * @returns the current particle system
  14379. */
  14380. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14381. /**
  14382. * Remove a specific life time gradient
  14383. * @param gradient defines the gradient to remove
  14384. * @returns the current particle system
  14385. */
  14386. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14387. /**
  14388. * Gets the current list of life time gradients.
  14389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14390. * @returns the list of life time gradients
  14391. */
  14392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14393. /**
  14394. * Gets the current list of color gradients.
  14395. * You must use addColorGradient and removeColorGradient to udpate this list
  14396. * @returns the list of color gradients
  14397. */
  14398. getColorGradients(): Nullable<Array<ColorGradient>>;
  14399. /**
  14400. * Adds a new ramp gradient used to remap particle colors
  14401. * @param gradient defines the gradient to use (between 0 and 1)
  14402. * @param color defines the color to affect to the specified gradient
  14403. * @returns the current particle system
  14404. */
  14405. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14406. /**
  14407. * Gets the current list of ramp gradients.
  14408. * You must use addRampGradient and removeRampGradient to udpate this list
  14409. * @returns the list of ramp gradients
  14410. */
  14411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14412. /** Gets or sets a boolean indicating that ramp gradients must be used
  14413. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14414. */
  14415. useRampGradients: boolean;
  14416. /**
  14417. * Adds a new color remap gradient
  14418. * @param gradient defines the gradient to use (between 0 and 1)
  14419. * @param min defines the color remap minimal range
  14420. * @param max defines the color remap maximal range
  14421. * @returns the current particle system
  14422. */
  14423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of color remap gradients.
  14426. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14427. * @returns the list of color remap gradients
  14428. */
  14429. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Adds a new alpha remap gradient
  14432. * @param gradient defines the gradient to use (between 0 and 1)
  14433. * @param min defines the alpha remap minimal range
  14434. * @param max defines the alpha remap maximal range
  14435. * @returns the current particle system
  14436. */
  14437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14438. /**
  14439. * Gets the current list of alpha remap gradients.
  14440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14441. * @returns the list of alpha remap gradients
  14442. */
  14443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14444. /**
  14445. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14448. * @returns the emitter
  14449. */
  14450. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14451. /**
  14452. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14453. * @param radius The radius of the hemisphere to emit from
  14454. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14455. * @returns the emitter
  14456. */
  14457. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14458. /**
  14459. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14460. * @param radius The radius of the sphere to emit from
  14461. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14462. * @returns the emitter
  14463. */
  14464. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14465. /**
  14466. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14467. * @param radius The radius of the sphere to emit from
  14468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14470. * @returns the emitter
  14471. */
  14472. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14473. /**
  14474. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14475. * @param radius The radius of the emission cylinder
  14476. * @param height The height of the emission cylinder
  14477. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14478. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14479. * @returns the emitter
  14480. */
  14481. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14482. /**
  14483. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14484. * @param radius The radius of the cylinder to emit from
  14485. * @param height The height of the emission cylinder
  14486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14489. * @returns the emitter
  14490. */
  14491. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14492. /**
  14493. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14494. * @param radius The radius of the cone to emit from
  14495. * @param angle The base angle of the cone
  14496. * @returns the emitter
  14497. */
  14498. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14499. /**
  14500. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14503. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14504. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14505. * @returns the emitter
  14506. */
  14507. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14508. /**
  14509. * Get hosting scene
  14510. * @returns the scene
  14511. */
  14512. getScene(): Scene;
  14513. }
  14514. }
  14515. declare module BABYLON {
  14516. /**
  14517. * 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.
  14518. * @see https://doc.babylonjs.com/how_to/transformnode
  14519. */
  14520. export class TransformNode extends Node {
  14521. /**
  14522. * Object will not rotate to face the camera
  14523. */
  14524. static BILLBOARDMODE_NONE: number;
  14525. /**
  14526. * Object will rotate to face the camera but only on the x axis
  14527. */
  14528. static BILLBOARDMODE_X: number;
  14529. /**
  14530. * Object will rotate to face the camera but only on the y axis
  14531. */
  14532. static BILLBOARDMODE_Y: number;
  14533. /**
  14534. * Object will rotate to face the camera but only on the z axis
  14535. */
  14536. static BILLBOARDMODE_Z: number;
  14537. /**
  14538. * Object will rotate to face the camera
  14539. */
  14540. static BILLBOARDMODE_ALL: number;
  14541. /**
  14542. * Object will rotate to face the camera's position instead of orientation
  14543. */
  14544. static BILLBOARDMODE_USE_POSITION: number;
  14545. private _forward;
  14546. private _forwardInverted;
  14547. private _up;
  14548. private _right;
  14549. private _rightInverted;
  14550. private _position;
  14551. private _rotation;
  14552. private _rotationQuaternion;
  14553. protected _scaling: Vector3;
  14554. protected _isDirty: boolean;
  14555. private _transformToBoneReferal;
  14556. private _isAbsoluteSynced;
  14557. private _billboardMode;
  14558. /**
  14559. * Gets or sets the billboard mode. Default is 0.
  14560. *
  14561. * | Value | Type | Description |
  14562. * | --- | --- | --- |
  14563. * | 0 | BILLBOARDMODE_NONE | |
  14564. * | 1 | BILLBOARDMODE_X | |
  14565. * | 2 | BILLBOARDMODE_Y | |
  14566. * | 4 | BILLBOARDMODE_Z | |
  14567. * | 7 | BILLBOARDMODE_ALL | |
  14568. *
  14569. */
  14570. get billboardMode(): number;
  14571. set billboardMode(value: number);
  14572. private _preserveParentRotationForBillboard;
  14573. /**
  14574. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14575. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14576. */
  14577. get preserveParentRotationForBillboard(): boolean;
  14578. set preserveParentRotationForBillboard(value: boolean);
  14579. /**
  14580. * 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
  14581. */
  14582. scalingDeterminant: number;
  14583. private _infiniteDistance;
  14584. /**
  14585. * Gets or sets the distance of the object to max, often used by skybox
  14586. */
  14587. get infiniteDistance(): boolean;
  14588. set infiniteDistance(value: boolean);
  14589. /**
  14590. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14591. * By default the system will update normals to compensate
  14592. */
  14593. ignoreNonUniformScaling: boolean;
  14594. /**
  14595. * 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
  14596. */
  14597. reIntegrateRotationIntoRotationQuaternion: boolean;
  14598. /** @hidden */
  14599. _poseMatrix: Nullable<Matrix>;
  14600. /** @hidden */
  14601. _localMatrix: Matrix;
  14602. private _usePivotMatrix;
  14603. private _absolutePosition;
  14604. private _absoluteScaling;
  14605. private _absoluteRotationQuaternion;
  14606. private _pivotMatrix;
  14607. private _pivotMatrixInverse;
  14608. protected _postMultiplyPivotMatrix: boolean;
  14609. protected _isWorldMatrixFrozen: boolean;
  14610. /** @hidden */
  14611. _indexInSceneTransformNodesArray: number;
  14612. /**
  14613. * An event triggered after the world matrix is updated
  14614. */
  14615. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14616. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14617. /**
  14618. * Gets a string identifying the name of the class
  14619. * @returns "TransformNode" string
  14620. */
  14621. getClassName(): string;
  14622. /**
  14623. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14624. */
  14625. get position(): Vector3;
  14626. set position(newPosition: Vector3);
  14627. /**
  14628. * 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)).
  14629. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14630. */
  14631. get rotation(): Vector3;
  14632. set rotation(newRotation: Vector3);
  14633. /**
  14634. * 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)).
  14635. */
  14636. get scaling(): Vector3;
  14637. set scaling(newScaling: Vector3);
  14638. /**
  14639. * 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).
  14640. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14641. */
  14642. get rotationQuaternion(): Nullable<Quaternion>;
  14643. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14644. /**
  14645. * The forward direction of that transform in world space.
  14646. */
  14647. get forward(): Vector3;
  14648. /**
  14649. * The up direction of that transform in world space.
  14650. */
  14651. get up(): Vector3;
  14652. /**
  14653. * The right direction of that transform in world space.
  14654. */
  14655. get right(): Vector3;
  14656. /**
  14657. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14658. * @param matrix the matrix to copy the pose from
  14659. * @returns this TransformNode.
  14660. */
  14661. updatePoseMatrix(matrix: Matrix): TransformNode;
  14662. /**
  14663. * Returns the mesh Pose matrix.
  14664. * @returns the pose matrix
  14665. */
  14666. getPoseMatrix(): Matrix;
  14667. /** @hidden */
  14668. _isSynchronized(): boolean;
  14669. /** @hidden */
  14670. _initCache(): void;
  14671. /**
  14672. * Flag the transform node as dirty (Forcing it to update everything)
  14673. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14674. * @returns this transform node
  14675. */
  14676. markAsDirty(property: string): TransformNode;
  14677. /**
  14678. * Returns the current mesh absolute position.
  14679. * Returns a Vector3.
  14680. */
  14681. get absolutePosition(): Vector3;
  14682. /**
  14683. * Returns the current mesh absolute scaling.
  14684. * Returns a Vector3.
  14685. */
  14686. get absoluteScaling(): Vector3;
  14687. /**
  14688. * Returns the current mesh absolute rotation.
  14689. * Returns a Quaternion.
  14690. */
  14691. get absoluteRotationQuaternion(): Quaternion;
  14692. /**
  14693. * Sets a new matrix to apply before all other transformation
  14694. * @param matrix defines the transform matrix
  14695. * @returns the current TransformNode
  14696. */
  14697. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14698. /**
  14699. * Sets a new pivot matrix to the current node
  14700. * @param matrix defines the new pivot matrix to use
  14701. * @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
  14702. * @returns the current TransformNode
  14703. */
  14704. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14705. /**
  14706. * Returns the mesh pivot matrix.
  14707. * Default : Identity.
  14708. * @returns the matrix
  14709. */
  14710. getPivotMatrix(): Matrix;
  14711. /**
  14712. * Instantiate (when possible) or clone that node with its hierarchy
  14713. * @param newParent defines the new parent to use for the instance (or clone)
  14714. * @param options defines options to configure how copy is done
  14715. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14716. * @returns an instance (or a clone) of the current node with its hiearchy
  14717. */
  14718. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14719. doNotInstantiate: boolean;
  14720. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14721. /**
  14722. * Prevents the World matrix to be computed any longer
  14723. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14724. * @returns the TransformNode.
  14725. */
  14726. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14727. /**
  14728. * Allows back the World matrix computation.
  14729. * @returns the TransformNode.
  14730. */
  14731. unfreezeWorldMatrix(): this;
  14732. /**
  14733. * True if the World matrix has been frozen.
  14734. */
  14735. get isWorldMatrixFrozen(): boolean;
  14736. /**
  14737. * Retuns the mesh absolute position in the World.
  14738. * @returns a Vector3.
  14739. */
  14740. getAbsolutePosition(): Vector3;
  14741. /**
  14742. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14743. * @param absolutePosition the absolute position to set
  14744. * @returns the TransformNode.
  14745. */
  14746. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14747. /**
  14748. * Sets the mesh position in its local space.
  14749. * @param vector3 the position to set in localspace
  14750. * @returns the TransformNode.
  14751. */
  14752. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14753. /**
  14754. * Returns the mesh position in the local space from the current World matrix values.
  14755. * @returns a new Vector3.
  14756. */
  14757. getPositionExpressedInLocalSpace(): Vector3;
  14758. /**
  14759. * Translates the mesh along the passed Vector3 in its local space.
  14760. * @param vector3 the distance to translate in localspace
  14761. * @returns the TransformNode.
  14762. */
  14763. locallyTranslate(vector3: Vector3): TransformNode;
  14764. private static _lookAtVectorCache;
  14765. /**
  14766. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14767. * @param targetPoint the position (must be in same space as current mesh) to look at
  14768. * @param yawCor optional yaw (y-axis) correction in radians
  14769. * @param pitchCor optional pitch (x-axis) correction in radians
  14770. * @param rollCor optional roll (z-axis) correction in radians
  14771. * @param space the choosen space of the target
  14772. * @returns the TransformNode.
  14773. */
  14774. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14775. /**
  14776. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14777. * This Vector3 is expressed in the World space.
  14778. * @param localAxis axis to rotate
  14779. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14780. */
  14781. getDirection(localAxis: Vector3): Vector3;
  14782. /**
  14783. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14784. * localAxis is expressed in the mesh local space.
  14785. * result is computed in the Wordl space from the mesh World matrix.
  14786. * @param localAxis axis to rotate
  14787. * @param result the resulting transformnode
  14788. * @returns this TransformNode.
  14789. */
  14790. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14791. /**
  14792. * Sets this transform node rotation to the given local axis.
  14793. * @param localAxis the axis in local space
  14794. * @param yawCor optional yaw (y-axis) correction in radians
  14795. * @param pitchCor optional pitch (x-axis) correction in radians
  14796. * @param rollCor optional roll (z-axis) correction in radians
  14797. * @returns this TransformNode
  14798. */
  14799. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14800. /**
  14801. * Sets a new pivot point to the current node
  14802. * @param point defines the new pivot point to use
  14803. * @param space defines if the point is in world or local space (local by default)
  14804. * @returns the current TransformNode
  14805. */
  14806. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14807. /**
  14808. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14809. * @returns the pivot point
  14810. */
  14811. getPivotPoint(): Vector3;
  14812. /**
  14813. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14814. * @param result the vector3 to store the result
  14815. * @returns this TransformNode.
  14816. */
  14817. getPivotPointToRef(result: Vector3): TransformNode;
  14818. /**
  14819. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14820. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14821. */
  14822. getAbsolutePivotPoint(): Vector3;
  14823. /**
  14824. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14825. * @param result vector3 to store the result
  14826. * @returns this TransformNode.
  14827. */
  14828. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14829. /**
  14830. * Defines the passed node as the parent of the current node.
  14831. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14832. * @see https://doc.babylonjs.com/how_to/parenting
  14833. * @param node the node ot set as the parent
  14834. * @returns this TransformNode.
  14835. */
  14836. setParent(node: Nullable<Node>): TransformNode;
  14837. private _nonUniformScaling;
  14838. /**
  14839. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14840. */
  14841. get nonUniformScaling(): boolean;
  14842. /** @hidden */
  14843. _updateNonUniformScalingState(value: boolean): boolean;
  14844. /**
  14845. * Attach the current TransformNode to another TransformNode associated with a bone
  14846. * @param bone Bone affecting the TransformNode
  14847. * @param affectedTransformNode TransformNode associated with the bone
  14848. * @returns this object
  14849. */
  14850. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14851. /**
  14852. * Detach the transform node if its associated with a bone
  14853. * @returns this object
  14854. */
  14855. detachFromBone(): TransformNode;
  14856. private static _rotationAxisCache;
  14857. /**
  14858. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14859. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14860. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14861. * The passed axis is also normalized.
  14862. * @param axis the axis to rotate around
  14863. * @param amount the amount to rotate in radians
  14864. * @param space Space to rotate in (Default: local)
  14865. * @returns the TransformNode.
  14866. */
  14867. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14868. /**
  14869. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14870. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14871. * The passed axis is also normalized. .
  14872. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14873. * @param point the point to rotate around
  14874. * @param axis the axis to rotate around
  14875. * @param amount the amount to rotate in radians
  14876. * @returns the TransformNode
  14877. */
  14878. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14879. /**
  14880. * Translates the mesh along the axis vector for the passed distance in the given space.
  14881. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14882. * @param axis the axis to translate in
  14883. * @param distance the distance to translate
  14884. * @param space Space to rotate in (Default: local)
  14885. * @returns the TransformNode.
  14886. */
  14887. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14888. /**
  14889. * Adds a rotation step to the mesh current rotation.
  14890. * x, y, z are Euler angles expressed in radians.
  14891. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14892. * This means this rotation is made in the mesh local space only.
  14893. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14894. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14895. * ```javascript
  14896. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14897. * ```
  14898. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14899. * 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.
  14900. * @param x Rotation to add
  14901. * @param y Rotation to add
  14902. * @param z Rotation to add
  14903. * @returns the TransformNode.
  14904. */
  14905. addRotation(x: number, y: number, z: number): TransformNode;
  14906. /**
  14907. * @hidden
  14908. */
  14909. protected _getEffectiveParent(): Nullable<Node>;
  14910. /**
  14911. * Computes the world matrix of the node
  14912. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14913. * @returns the world matrix
  14914. */
  14915. computeWorldMatrix(force?: boolean): Matrix;
  14916. /**
  14917. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14918. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14919. */
  14920. resetLocalMatrix(independentOfChildren?: boolean): void;
  14921. protected _afterComputeWorldMatrix(): void;
  14922. /**
  14923. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14924. * @param func callback function to add
  14925. *
  14926. * @returns the TransformNode.
  14927. */
  14928. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14929. /**
  14930. * Removes a registered callback function.
  14931. * @param func callback function to remove
  14932. * @returns the TransformNode.
  14933. */
  14934. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14935. /**
  14936. * Gets the position of the current mesh in camera space
  14937. * @param camera defines the camera to use
  14938. * @returns a position
  14939. */
  14940. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14941. /**
  14942. * Returns the distance from the mesh to the active camera
  14943. * @param camera defines the camera to use
  14944. * @returns the distance
  14945. */
  14946. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14947. /**
  14948. * Clone the current transform node
  14949. * @param name Name of the new clone
  14950. * @param newParent New parent for the clone
  14951. * @param doNotCloneChildren Do not clone children hierarchy
  14952. * @returns the new transform node
  14953. */
  14954. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14955. /**
  14956. * Serializes the objects information.
  14957. * @param currentSerializationObject defines the object to serialize in
  14958. * @returns the serialized object
  14959. */
  14960. serialize(currentSerializationObject?: any): any;
  14961. /**
  14962. * Returns a new TransformNode object parsed from the source provided.
  14963. * @param parsedTransformNode is the source.
  14964. * @param scene the scne the object belongs to
  14965. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14966. * @returns a new TransformNode object parsed from the source provided.
  14967. */
  14968. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14969. /**
  14970. * Get all child-transformNodes of this node
  14971. * @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
  14972. * @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
  14973. * @returns an array of TransformNode
  14974. */
  14975. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14976. /**
  14977. * Releases resources associated with this transform node.
  14978. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14979. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14980. */
  14981. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14982. /**
  14983. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14984. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14985. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14986. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14987. * @returns the current mesh
  14988. */
  14989. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14990. private _syncAbsoluteScalingAndRotation;
  14991. }
  14992. }
  14993. declare module BABYLON {
  14994. /**
  14995. * Class used to override all child animations of a given target
  14996. */
  14997. export class AnimationPropertiesOverride {
  14998. /**
  14999. * Gets or sets a value indicating if animation blending must be used
  15000. */
  15001. enableBlending: boolean;
  15002. /**
  15003. * Gets or sets the blending speed to use when enableBlending is true
  15004. */
  15005. blendingSpeed: number;
  15006. /**
  15007. * Gets or sets the default loop mode to use
  15008. */
  15009. loopMode: number;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Class used to store bone information
  15015. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15016. */
  15017. export class Bone extends Node {
  15018. /**
  15019. * defines the bone name
  15020. */
  15021. name: string;
  15022. private static _tmpVecs;
  15023. private static _tmpQuat;
  15024. private static _tmpMats;
  15025. /**
  15026. * Gets the list of child bones
  15027. */
  15028. children: Bone[];
  15029. /** Gets the animations associated with this bone */
  15030. animations: Animation[];
  15031. /**
  15032. * Gets or sets bone length
  15033. */
  15034. length: number;
  15035. /**
  15036. * @hidden Internal only
  15037. * Set this value to map this bone to a different index in the transform matrices
  15038. * Set this value to -1 to exclude the bone from the transform matrices
  15039. */
  15040. _index: Nullable<number>;
  15041. private _skeleton;
  15042. private _localMatrix;
  15043. private _restPose;
  15044. private _baseMatrix;
  15045. private _absoluteTransform;
  15046. private _invertedAbsoluteTransform;
  15047. private _parent;
  15048. private _scalingDeterminant;
  15049. private _worldTransform;
  15050. private _localScaling;
  15051. private _localRotation;
  15052. private _localPosition;
  15053. private _needToDecompose;
  15054. private _needToCompose;
  15055. /** @hidden */
  15056. _linkedTransformNode: Nullable<TransformNode>;
  15057. /** @hidden */
  15058. _waitingTransformNodeId: Nullable<string>;
  15059. /** @hidden */
  15060. get _matrix(): Matrix;
  15061. /** @hidden */
  15062. set _matrix(value: Matrix);
  15063. /**
  15064. * Create a new bone
  15065. * @param name defines the bone name
  15066. * @param skeleton defines the parent skeleton
  15067. * @param parentBone defines the parent (can be null if the bone is the root)
  15068. * @param localMatrix defines the local matrix
  15069. * @param restPose defines the rest pose matrix
  15070. * @param baseMatrix defines the base matrix
  15071. * @param index defines index of the bone in the hiearchy
  15072. */
  15073. constructor(
  15074. /**
  15075. * defines the bone name
  15076. */
  15077. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15078. /**
  15079. * Gets the current object class name.
  15080. * @return the class name
  15081. */
  15082. getClassName(): string;
  15083. /**
  15084. * Gets the parent skeleton
  15085. * @returns a skeleton
  15086. */
  15087. getSkeleton(): Skeleton;
  15088. /**
  15089. * Gets parent bone
  15090. * @returns a bone or null if the bone is the root of the bone hierarchy
  15091. */
  15092. getParent(): Nullable<Bone>;
  15093. /**
  15094. * Returns an array containing the root bones
  15095. * @returns an array containing the root bones
  15096. */
  15097. getChildren(): Array<Bone>;
  15098. /**
  15099. * Gets the node index in matrix array generated for rendering
  15100. * @returns the node index
  15101. */
  15102. getIndex(): number;
  15103. /**
  15104. * Sets the parent bone
  15105. * @param parent defines the parent (can be null if the bone is the root)
  15106. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15107. */
  15108. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15109. /**
  15110. * Gets the local matrix
  15111. * @returns a matrix
  15112. */
  15113. getLocalMatrix(): Matrix;
  15114. /**
  15115. * Gets the base matrix (initial matrix which remains unchanged)
  15116. * @returns a matrix
  15117. */
  15118. getBaseMatrix(): Matrix;
  15119. /**
  15120. * Gets the rest pose matrix
  15121. * @returns a matrix
  15122. */
  15123. getRestPose(): Matrix;
  15124. /**
  15125. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15126. */
  15127. getWorldMatrix(): Matrix;
  15128. /**
  15129. * Sets the local matrix to rest pose matrix
  15130. */
  15131. returnToRest(): void;
  15132. /**
  15133. * Gets the inverse of the absolute transform matrix.
  15134. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15135. * @returns a matrix
  15136. */
  15137. getInvertedAbsoluteTransform(): Matrix;
  15138. /**
  15139. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15140. * @returns a matrix
  15141. */
  15142. getAbsoluteTransform(): Matrix;
  15143. /**
  15144. * Links with the given transform node.
  15145. * The local matrix of this bone is copied from the transform node every frame.
  15146. * @param transformNode defines the transform node to link to
  15147. */
  15148. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15149. /**
  15150. * Gets the node used to drive the bone's transformation
  15151. * @returns a transform node or null
  15152. */
  15153. getTransformNode(): Nullable<TransformNode>;
  15154. /** Gets or sets current position (in local space) */
  15155. get position(): Vector3;
  15156. set position(newPosition: Vector3);
  15157. /** Gets or sets current rotation (in local space) */
  15158. get rotation(): Vector3;
  15159. set rotation(newRotation: Vector3);
  15160. /** Gets or sets current rotation quaternion (in local space) */
  15161. get rotationQuaternion(): Quaternion;
  15162. set rotationQuaternion(newRotation: Quaternion);
  15163. /** Gets or sets current scaling (in local space) */
  15164. get scaling(): Vector3;
  15165. set scaling(newScaling: Vector3);
  15166. /**
  15167. * Gets the animation properties override
  15168. */
  15169. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15170. private _decompose;
  15171. private _compose;
  15172. /**
  15173. * Update the base and local matrices
  15174. * @param matrix defines the new base or local matrix
  15175. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15176. * @param updateLocalMatrix defines if the local matrix should be updated
  15177. */
  15178. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15179. /** @hidden */
  15180. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15181. /**
  15182. * Flag the bone as dirty (Forcing it to update everything)
  15183. */
  15184. markAsDirty(): void;
  15185. /** @hidden */
  15186. _markAsDirtyAndCompose(): void;
  15187. private _markAsDirtyAndDecompose;
  15188. /**
  15189. * Translate the bone in local or world space
  15190. * @param vec The amount to translate the bone
  15191. * @param space The space that the translation is in
  15192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15193. */
  15194. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15195. /**
  15196. * Set the postion of the bone in local or world space
  15197. * @param position The position to set the bone
  15198. * @param space The space that the position is in
  15199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15200. */
  15201. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15202. /**
  15203. * Set the absolute position of the bone (world space)
  15204. * @param position The position to set the bone
  15205. * @param mesh The mesh that this bone is attached to
  15206. */
  15207. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15208. /**
  15209. * Scale the bone on the x, y and z axes (in local space)
  15210. * @param x The amount to scale the bone on the x axis
  15211. * @param y The amount to scale the bone on the y axis
  15212. * @param z The amount to scale the bone on the z axis
  15213. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15214. */
  15215. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15216. /**
  15217. * Set the bone scaling in local space
  15218. * @param scale defines the scaling vector
  15219. */
  15220. setScale(scale: Vector3): void;
  15221. /**
  15222. * Gets the current scaling in local space
  15223. * @returns the current scaling vector
  15224. */
  15225. getScale(): Vector3;
  15226. /**
  15227. * Gets the current scaling in local space and stores it in a target vector
  15228. * @param result defines the target vector
  15229. */
  15230. getScaleToRef(result: Vector3): void;
  15231. /**
  15232. * Set the yaw, pitch, and roll of the bone in local or world space
  15233. * @param yaw The rotation of the bone on the y axis
  15234. * @param pitch The rotation of the bone on the x axis
  15235. * @param roll The rotation of the bone on the z axis
  15236. * @param space The space that the axes of rotation are in
  15237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15238. */
  15239. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15240. /**
  15241. * Add a rotation to the bone on an axis in local or world space
  15242. * @param axis The axis to rotate the bone on
  15243. * @param amount The amount to rotate the bone
  15244. * @param space The space that the axis is in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. */
  15247. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15248. /**
  15249. * Set the rotation of the bone to a particular axis angle in local or world space
  15250. * @param axis The axis to rotate the bone on
  15251. * @param angle The angle that the bone should be rotated to
  15252. * @param space The space that the axis is in
  15253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15254. */
  15255. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15256. /**
  15257. * Set the euler rotation of the bone in local of world space
  15258. * @param rotation The euler rotation that the bone should be set to
  15259. * @param space The space that the rotation is in
  15260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15261. */
  15262. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15263. /**
  15264. * Set the quaternion rotation of the bone in local of world space
  15265. * @param quat The quaternion rotation that the bone should be set to
  15266. * @param space The space that the rotation is in
  15267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15268. */
  15269. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15270. /**
  15271. * Set the rotation matrix of the bone in local of world space
  15272. * @param rotMat The rotation matrix that the bone should be set to
  15273. * @param space The space that the rotation is in
  15274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15275. */
  15276. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15277. private _rotateWithMatrix;
  15278. private _getNegativeRotationToRef;
  15279. /**
  15280. * Get the position of the bone in local or world space
  15281. * @param space The space that the returned position is in
  15282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15283. * @returns The position of the bone
  15284. */
  15285. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15286. /**
  15287. * Copy the position of the bone to a vector3 in local or world space
  15288. * @param space The space that the returned position is in
  15289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15290. * @param result The vector3 to copy the position to
  15291. */
  15292. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15293. /**
  15294. * Get the absolute position of the bone (world space)
  15295. * @param mesh The mesh that this bone is attached to
  15296. * @returns The absolute position of the bone
  15297. */
  15298. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15299. /**
  15300. * Copy the absolute position of the bone (world space) to the result param
  15301. * @param mesh The mesh that this bone is attached to
  15302. * @param result The vector3 to copy the absolute position to
  15303. */
  15304. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15305. /**
  15306. * Compute the absolute transforms of this bone and its children
  15307. */
  15308. computeAbsoluteTransforms(): void;
  15309. /**
  15310. * Get the world direction from an axis that is in the local space of the bone
  15311. * @param localAxis The local direction that is used to compute the world direction
  15312. * @param mesh The mesh that this bone is attached to
  15313. * @returns The world direction
  15314. */
  15315. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15316. /**
  15317. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15318. * @param localAxis The local direction that is used to compute the world direction
  15319. * @param mesh The mesh that this bone is attached to
  15320. * @param result The vector3 that the world direction will be copied to
  15321. */
  15322. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15323. /**
  15324. * Get the euler rotation of the bone in local or world space
  15325. * @param space The space that the rotation should be in
  15326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15327. * @returns The euler rotation
  15328. */
  15329. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15330. /**
  15331. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15332. * @param space The space that the rotation should be in
  15333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15334. * @param result The vector3 that the rotation should be copied to
  15335. */
  15336. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15337. /**
  15338. * Get the quaternion rotation of the bone in either local or world space
  15339. * @param space The space that the rotation should be in
  15340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15341. * @returns The quaternion rotation
  15342. */
  15343. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15344. /**
  15345. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15346. * @param space The space that the rotation should be in
  15347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15348. * @param result The quaternion that the rotation should be copied to
  15349. */
  15350. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15351. /**
  15352. * Get the rotation matrix of the bone in local or world space
  15353. * @param space The space that the rotation should be in
  15354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15355. * @returns The rotation matrix
  15356. */
  15357. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15358. /**
  15359. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15360. * @param space The space that the rotation should be in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. * @param result The quaternion that the rotation should be copied to
  15363. */
  15364. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15365. /**
  15366. * Get the world position of a point that is in the local space of the bone
  15367. * @param position The local position
  15368. * @param mesh The mesh that this bone is attached to
  15369. * @returns The world position
  15370. */
  15371. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15372. /**
  15373. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15374. * @param position The local position
  15375. * @param mesh The mesh that this bone is attached to
  15376. * @param result The vector3 that the world position should be copied to
  15377. */
  15378. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15379. /**
  15380. * Get the local position of a point that is in world space
  15381. * @param position The world position
  15382. * @param mesh The mesh that this bone is attached to
  15383. * @returns The local position
  15384. */
  15385. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15386. /**
  15387. * Get the local position of a point that is in world space and copy it to the result param
  15388. * @param position The world position
  15389. * @param mesh The mesh that this bone is attached to
  15390. * @param result The vector3 that the local position should be copied to
  15391. */
  15392. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15393. }
  15394. }
  15395. declare module BABYLON {
  15396. /**
  15397. * Defines a runtime animation
  15398. */
  15399. export class RuntimeAnimation {
  15400. private _events;
  15401. /**
  15402. * The current frame of the runtime animation
  15403. */
  15404. private _currentFrame;
  15405. /**
  15406. * The animation used by the runtime animation
  15407. */
  15408. private _animation;
  15409. /**
  15410. * The target of the runtime animation
  15411. */
  15412. private _target;
  15413. /**
  15414. * The initiating animatable
  15415. */
  15416. private _host;
  15417. /**
  15418. * The original value of the runtime animation
  15419. */
  15420. private _originalValue;
  15421. /**
  15422. * The original blend value of the runtime animation
  15423. */
  15424. private _originalBlendValue;
  15425. /**
  15426. * The offsets cache of the runtime animation
  15427. */
  15428. private _offsetsCache;
  15429. /**
  15430. * The high limits cache of the runtime animation
  15431. */
  15432. private _highLimitsCache;
  15433. /**
  15434. * Specifies if the runtime animation has been stopped
  15435. */
  15436. private _stopped;
  15437. /**
  15438. * The blending factor of the runtime animation
  15439. */
  15440. private _blendingFactor;
  15441. /**
  15442. * The BabylonJS scene
  15443. */
  15444. private _scene;
  15445. /**
  15446. * The current value of the runtime animation
  15447. */
  15448. private _currentValue;
  15449. /** @hidden */
  15450. _animationState: _IAnimationState;
  15451. /**
  15452. * The active target of the runtime animation
  15453. */
  15454. private _activeTargets;
  15455. private _currentActiveTarget;
  15456. private _directTarget;
  15457. /**
  15458. * The target path of the runtime animation
  15459. */
  15460. private _targetPath;
  15461. /**
  15462. * The weight of the runtime animation
  15463. */
  15464. private _weight;
  15465. /**
  15466. * The ratio offset of the runtime animation
  15467. */
  15468. private _ratioOffset;
  15469. /**
  15470. * The previous delay of the runtime animation
  15471. */
  15472. private _previousDelay;
  15473. /**
  15474. * The previous ratio of the runtime animation
  15475. */
  15476. private _previousRatio;
  15477. private _enableBlending;
  15478. private _keys;
  15479. private _minFrame;
  15480. private _maxFrame;
  15481. private _minValue;
  15482. private _maxValue;
  15483. private _targetIsArray;
  15484. /**
  15485. * Gets the current frame of the runtime animation
  15486. */
  15487. get currentFrame(): number;
  15488. /**
  15489. * Gets the weight of the runtime animation
  15490. */
  15491. get weight(): number;
  15492. /**
  15493. * Gets the current value of the runtime animation
  15494. */
  15495. get currentValue(): any;
  15496. /**
  15497. * Gets the target path of the runtime animation
  15498. */
  15499. get targetPath(): string;
  15500. /**
  15501. * Gets the actual target of the runtime animation
  15502. */
  15503. get target(): any;
  15504. /**
  15505. * Gets the additive state of the runtime animation
  15506. */
  15507. get isAdditive(): boolean;
  15508. /** @hidden */
  15509. _onLoop: () => void;
  15510. /**
  15511. * Create a new RuntimeAnimation object
  15512. * @param target defines the target of the animation
  15513. * @param animation defines the source animation object
  15514. * @param scene defines the hosting scene
  15515. * @param host defines the initiating Animatable
  15516. */
  15517. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15518. private _preparePath;
  15519. /**
  15520. * Gets the animation from the runtime animation
  15521. */
  15522. get animation(): Animation;
  15523. /**
  15524. * Resets the runtime animation to the beginning
  15525. * @param restoreOriginal defines whether to restore the target property to the original value
  15526. */
  15527. reset(restoreOriginal?: boolean): void;
  15528. /**
  15529. * Specifies if the runtime animation is stopped
  15530. * @returns Boolean specifying if the runtime animation is stopped
  15531. */
  15532. isStopped(): boolean;
  15533. /**
  15534. * Disposes of the runtime animation
  15535. */
  15536. dispose(): void;
  15537. /**
  15538. * Apply the interpolated value to the target
  15539. * @param currentValue defines the value computed by the animation
  15540. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15541. */
  15542. setValue(currentValue: any, weight: number): void;
  15543. private _getOriginalValues;
  15544. private _setValue;
  15545. /**
  15546. * Gets the loop pmode of the runtime animation
  15547. * @returns Loop Mode
  15548. */
  15549. private _getCorrectLoopMode;
  15550. /**
  15551. * Move the current animation to a given frame
  15552. * @param frame defines the frame to move to
  15553. */
  15554. goToFrame(frame: number): void;
  15555. /**
  15556. * @hidden Internal use only
  15557. */
  15558. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15559. /**
  15560. * Execute the current animation
  15561. * @param delay defines the delay to add to the current frame
  15562. * @param from defines the lower bound of the animation range
  15563. * @param to defines the upper bound of the animation range
  15564. * @param loop defines if the current animation must loop
  15565. * @param speedRatio defines the current speed ratio
  15566. * @param weight defines the weight of the animation (default is -1 so no weight)
  15567. * @param onLoop optional callback called when animation loops
  15568. * @returns a boolean indicating if the animation is running
  15569. */
  15570. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15571. }
  15572. }
  15573. declare module BABYLON {
  15574. /**
  15575. * Class used to store an actual running animation
  15576. */
  15577. export class Animatable {
  15578. /** defines the target object */
  15579. target: any;
  15580. /** defines the starting frame number (default is 0) */
  15581. fromFrame: number;
  15582. /** defines the ending frame number (default is 100) */
  15583. toFrame: number;
  15584. /** defines if the animation must loop (default is false) */
  15585. loopAnimation: boolean;
  15586. /** defines a callback to call when animation ends if it is not looping */
  15587. onAnimationEnd?: (() => void) | null | undefined;
  15588. /** defines a callback to call when animation loops */
  15589. onAnimationLoop?: (() => void) | null | undefined;
  15590. /** defines whether the animation should be evaluated additively */
  15591. isAdditive: boolean;
  15592. private _localDelayOffset;
  15593. private _pausedDelay;
  15594. private _runtimeAnimations;
  15595. private _paused;
  15596. private _scene;
  15597. private _speedRatio;
  15598. private _weight;
  15599. private _syncRoot;
  15600. /**
  15601. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15602. * This will only apply for non looping animation (default is true)
  15603. */
  15604. disposeOnEnd: boolean;
  15605. /**
  15606. * Gets a boolean indicating if the animation has started
  15607. */
  15608. animationStarted: boolean;
  15609. /**
  15610. * Observer raised when the animation ends
  15611. */
  15612. onAnimationEndObservable: Observable<Animatable>;
  15613. /**
  15614. * Observer raised when the animation loops
  15615. */
  15616. onAnimationLoopObservable: Observable<Animatable>;
  15617. /**
  15618. * Gets the root Animatable used to synchronize and normalize animations
  15619. */
  15620. get syncRoot(): Nullable<Animatable>;
  15621. /**
  15622. * Gets the current frame of the first RuntimeAnimation
  15623. * Used to synchronize Animatables
  15624. */
  15625. get masterFrame(): number;
  15626. /**
  15627. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15628. */
  15629. get weight(): number;
  15630. set weight(value: number);
  15631. /**
  15632. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15633. */
  15634. get speedRatio(): number;
  15635. set speedRatio(value: number);
  15636. /**
  15637. * Creates a new Animatable
  15638. * @param scene defines the hosting scene
  15639. * @param target defines the target object
  15640. * @param fromFrame defines the starting frame number (default is 0)
  15641. * @param toFrame defines the ending frame number (default is 100)
  15642. * @param loopAnimation defines if the animation must loop (default is false)
  15643. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15644. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15645. * @param animations defines a group of animation to add to the new Animatable
  15646. * @param onAnimationLoop defines a callback to call when animation loops
  15647. * @param isAdditive defines whether the animation should be evaluated additively
  15648. */
  15649. constructor(scene: Scene,
  15650. /** defines the target object */
  15651. target: any,
  15652. /** defines the starting frame number (default is 0) */
  15653. fromFrame?: number,
  15654. /** defines the ending frame number (default is 100) */
  15655. toFrame?: number,
  15656. /** defines if the animation must loop (default is false) */
  15657. loopAnimation?: boolean, speedRatio?: number,
  15658. /** defines a callback to call when animation ends if it is not looping */
  15659. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15660. /** defines a callback to call when animation loops */
  15661. onAnimationLoop?: (() => void) | null | undefined,
  15662. /** defines whether the animation should be evaluated additively */
  15663. isAdditive?: boolean);
  15664. /**
  15665. * Synchronize and normalize current Animatable with a source Animatable
  15666. * This is useful when using animation weights and when animations are not of the same length
  15667. * @param root defines the root Animatable to synchronize with
  15668. * @returns the current Animatable
  15669. */
  15670. syncWith(root: Animatable): Animatable;
  15671. /**
  15672. * Gets the list of runtime animations
  15673. * @returns an array of RuntimeAnimation
  15674. */
  15675. getAnimations(): RuntimeAnimation[];
  15676. /**
  15677. * Adds more animations to the current animatable
  15678. * @param target defines the target of the animations
  15679. * @param animations defines the new animations to add
  15680. */
  15681. appendAnimations(target: any, animations: Animation[]): void;
  15682. /**
  15683. * Gets the source animation for a specific property
  15684. * @param property defines the propertyu to look for
  15685. * @returns null or the source animation for the given property
  15686. */
  15687. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15688. /**
  15689. * Gets the runtime animation for a specific property
  15690. * @param property defines the propertyu to look for
  15691. * @returns null or the runtime animation for the given property
  15692. */
  15693. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15694. /**
  15695. * Resets the animatable to its original state
  15696. */
  15697. reset(): void;
  15698. /**
  15699. * Allows the animatable to blend with current running animations
  15700. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15701. * @param blendingSpeed defines the blending speed to use
  15702. */
  15703. enableBlending(blendingSpeed: number): void;
  15704. /**
  15705. * Disable animation blending
  15706. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15707. */
  15708. disableBlending(): void;
  15709. /**
  15710. * Jump directly to a given frame
  15711. * @param frame defines the frame to jump to
  15712. */
  15713. goToFrame(frame: number): void;
  15714. /**
  15715. * Pause the animation
  15716. */
  15717. pause(): void;
  15718. /**
  15719. * Restart the animation
  15720. */
  15721. restart(): void;
  15722. private _raiseOnAnimationEnd;
  15723. /**
  15724. * Stop and delete the current animation
  15725. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15726. * @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)
  15727. */
  15728. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15729. /**
  15730. * Wait asynchronously for the animation to end
  15731. * @returns a promise which will be fullfilled when the animation ends
  15732. */
  15733. waitAsync(): Promise<Animatable>;
  15734. /** @hidden */
  15735. _animate(delay: number): boolean;
  15736. }
  15737. interface Scene {
  15738. /** @hidden */
  15739. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15740. /** @hidden */
  15741. _processLateAnimationBindingsForMatrices(holder: {
  15742. totalWeight: number;
  15743. totalAdditiveWeight: number;
  15744. animations: RuntimeAnimation[];
  15745. additiveAnimations: RuntimeAnimation[];
  15746. originalValue: Matrix;
  15747. }): any;
  15748. /** @hidden */
  15749. _processLateAnimationBindingsForQuaternions(holder: {
  15750. totalWeight: number;
  15751. totalAdditiveWeight: number;
  15752. animations: RuntimeAnimation[];
  15753. additiveAnimations: RuntimeAnimation[];
  15754. originalValue: Quaternion;
  15755. }, refQuaternion: Quaternion): Quaternion;
  15756. /** @hidden */
  15757. _processLateAnimationBindings(): void;
  15758. /**
  15759. * Will start the animation sequence of a given target
  15760. * @param target defines the target
  15761. * @param from defines from which frame should animation start
  15762. * @param to defines until which frame should animation run.
  15763. * @param weight defines the weight to apply to the animation (1.0 by default)
  15764. * @param loop defines if the animation loops
  15765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15766. * @param onAnimationEnd defines the function to be executed when the animation ends
  15767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15769. * @param onAnimationLoop defines the callback to call when an animation loops
  15770. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15771. * @returns the animatable object created for this animation
  15772. */
  15773. 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;
  15774. /**
  15775. * Will start the animation sequence of a given target
  15776. * @param target defines the target
  15777. * @param from defines from which frame should animation start
  15778. * @param to defines until which frame should animation run.
  15779. * @param loop defines if the animation loops
  15780. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15781. * @param onAnimationEnd defines the function to be executed when the animation ends
  15782. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15783. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15784. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15785. * @param onAnimationLoop defines the callback to call when an animation loops
  15786. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15787. * @returns the animatable object created for this animation
  15788. */
  15789. 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;
  15790. /**
  15791. * Will start the animation sequence of a given target and its hierarchy
  15792. * @param target defines the target
  15793. * @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.
  15794. * @param from defines from which frame should animation start
  15795. * @param to defines until which frame should animation run.
  15796. * @param loop defines if the animation loops
  15797. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15798. * @param onAnimationEnd defines the function to be executed when the animation ends
  15799. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15800. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15802. * @param onAnimationLoop defines the callback to call when an animation loops
  15803. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15804. * @returns the list of created animatables
  15805. */
  15806. 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[];
  15807. /**
  15808. * Begin a new animation on a given node
  15809. * @param target defines the target where the animation will take place
  15810. * @param animations defines the list of animations to start
  15811. * @param from defines the initial value
  15812. * @param to defines the final value
  15813. * @param loop defines if you want animation to loop (off by default)
  15814. * @param speedRatio defines the speed ratio to apply to all animations
  15815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15816. * @param onAnimationLoop defines the callback to call when an animation loops
  15817. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15818. * @returns the list of created animatables
  15819. */
  15820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15821. /**
  15822. * Begin a new animation on a given node and its hierarchy
  15823. * @param target defines the root node where the animation will take place
  15824. * @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.
  15825. * @param animations defines the list of animations to start
  15826. * @param from defines the initial value
  15827. * @param to defines the final value
  15828. * @param loop defines if you want animation to loop (off by default)
  15829. * @param speedRatio defines the speed ratio to apply to all animations
  15830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15831. * @param onAnimationLoop defines the callback to call when an animation loops
  15832. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15833. * @returns the list of animatables created for all nodes
  15834. */
  15835. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15836. /**
  15837. * Gets the animatable associated with a specific target
  15838. * @param target defines the target of the animatable
  15839. * @returns the required animatable if found
  15840. */
  15841. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15842. /**
  15843. * Gets all animatables associated with a given target
  15844. * @param target defines the target to look animatables for
  15845. * @returns an array of Animatables
  15846. */
  15847. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15848. /**
  15849. * Stops and removes all animations that have been applied to the scene
  15850. */
  15851. stopAllAnimations(): void;
  15852. /**
  15853. * Gets the current delta time used by animation engine
  15854. */
  15855. deltaTime: number;
  15856. }
  15857. interface Bone {
  15858. /**
  15859. * Copy an animation range from another bone
  15860. * @param source defines the source bone
  15861. * @param rangeName defines the range name to copy
  15862. * @param frameOffset defines the frame offset
  15863. * @param rescaleAsRequired defines if rescaling must be applied if required
  15864. * @param skelDimensionsRatio defines the scaling ratio
  15865. * @returns true if operation was successful
  15866. */
  15867. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15868. }
  15869. }
  15870. declare module BABYLON {
  15871. /**
  15872. * Class used to handle skinning animations
  15873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15874. */
  15875. export class Skeleton implements IAnimatable {
  15876. /** defines the skeleton name */
  15877. name: string;
  15878. /** defines the skeleton Id */
  15879. id: string;
  15880. /**
  15881. * Defines the list of child bones
  15882. */
  15883. bones: Bone[];
  15884. /**
  15885. * Defines an estimate of the dimension of the skeleton at rest
  15886. */
  15887. dimensionsAtRest: Vector3;
  15888. /**
  15889. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15890. */
  15891. needInitialSkinMatrix: boolean;
  15892. /**
  15893. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15894. */
  15895. overrideMesh: Nullable<AbstractMesh>;
  15896. /**
  15897. * Gets the list of animations attached to this skeleton
  15898. */
  15899. animations: Array<Animation>;
  15900. private _scene;
  15901. private _isDirty;
  15902. private _transformMatrices;
  15903. private _transformMatrixTexture;
  15904. private _meshesWithPoseMatrix;
  15905. private _animatables;
  15906. private _identity;
  15907. private _synchronizedWithMesh;
  15908. private _ranges;
  15909. private _lastAbsoluteTransformsUpdateId;
  15910. private _canUseTextureForBones;
  15911. private _uniqueId;
  15912. /** @hidden */
  15913. _numBonesWithLinkedTransformNode: number;
  15914. /** @hidden */
  15915. _hasWaitingData: Nullable<boolean>;
  15916. /**
  15917. * Specifies if the skeleton should be serialized
  15918. */
  15919. doNotSerialize: boolean;
  15920. private _useTextureToStoreBoneMatrices;
  15921. /**
  15922. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15923. * Please note that this option is not available if the hardware does not support it
  15924. */
  15925. get useTextureToStoreBoneMatrices(): boolean;
  15926. set useTextureToStoreBoneMatrices(value: boolean);
  15927. private _animationPropertiesOverride;
  15928. /**
  15929. * Gets or sets the animation properties override
  15930. */
  15931. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15932. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15933. /**
  15934. * List of inspectable custom properties (used by the Inspector)
  15935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15936. */
  15937. inspectableCustomProperties: IInspectable[];
  15938. /**
  15939. * An observable triggered before computing the skeleton's matrices
  15940. */
  15941. onBeforeComputeObservable: Observable<Skeleton>;
  15942. /**
  15943. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15944. */
  15945. get isUsingTextureForMatrices(): boolean;
  15946. /**
  15947. * Gets the unique ID of this skeleton
  15948. */
  15949. get uniqueId(): number;
  15950. /**
  15951. * Creates a new skeleton
  15952. * @param name defines the skeleton name
  15953. * @param id defines the skeleton Id
  15954. * @param scene defines the hosting scene
  15955. */
  15956. constructor(
  15957. /** defines the skeleton name */
  15958. name: string,
  15959. /** defines the skeleton Id */
  15960. id: string, scene: Scene);
  15961. /**
  15962. * Gets the current object class name.
  15963. * @return the class name
  15964. */
  15965. getClassName(): string;
  15966. /**
  15967. * Returns an array containing the root bones
  15968. * @returns an array containing the root bones
  15969. */
  15970. getChildren(): Array<Bone>;
  15971. /**
  15972. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15973. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15974. * @returns a Float32Array containing matrices data
  15975. */
  15976. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15977. /**
  15978. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15979. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15980. * @returns a raw texture containing the data
  15981. */
  15982. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15983. /**
  15984. * Gets the current hosting scene
  15985. * @returns a scene object
  15986. */
  15987. getScene(): Scene;
  15988. /**
  15989. * Gets a string representing the current skeleton data
  15990. * @param fullDetails defines a boolean indicating if we want a verbose version
  15991. * @returns a string representing the current skeleton data
  15992. */
  15993. toString(fullDetails?: boolean): string;
  15994. /**
  15995. * Get bone's index searching by name
  15996. * @param name defines bone's name to search for
  15997. * @return the indice of the bone. Returns -1 if not found
  15998. */
  15999. getBoneIndexByName(name: string): number;
  16000. /**
  16001. * Creater a new animation range
  16002. * @param name defines the name of the range
  16003. * @param from defines the start key
  16004. * @param to defines the end key
  16005. */
  16006. createAnimationRange(name: string, from: number, to: number): void;
  16007. /**
  16008. * Delete a specific animation range
  16009. * @param name defines the name of the range
  16010. * @param deleteFrames defines if frames must be removed as well
  16011. */
  16012. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16013. /**
  16014. * Gets a specific animation range
  16015. * @param name defines the name of the range to look for
  16016. * @returns the requested animation range or null if not found
  16017. */
  16018. getAnimationRange(name: string): Nullable<AnimationRange>;
  16019. /**
  16020. * Gets the list of all animation ranges defined on this skeleton
  16021. * @returns an array
  16022. */
  16023. getAnimationRanges(): Nullable<AnimationRange>[];
  16024. /**
  16025. * Copy animation range from a source skeleton.
  16026. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16027. * @param source defines the source skeleton
  16028. * @param name defines the name of the range to copy
  16029. * @param rescaleAsRequired defines if rescaling must be applied if required
  16030. * @returns true if operation was successful
  16031. */
  16032. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16033. /**
  16034. * Forces the skeleton to go to rest pose
  16035. */
  16036. returnToRest(): void;
  16037. private _getHighestAnimationFrame;
  16038. /**
  16039. * Begin a specific animation range
  16040. * @param name defines the name of the range to start
  16041. * @param loop defines if looping must be turned on (false by default)
  16042. * @param speedRatio defines the speed ratio to apply (1 by default)
  16043. * @param onAnimationEnd defines a callback which will be called when animation will end
  16044. * @returns a new animatable
  16045. */
  16046. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16047. /**
  16048. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16049. * @param skeleton defines the Skeleton containing the animation range to convert
  16050. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16051. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16052. * @returns the original skeleton
  16053. */
  16054. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16055. /** @hidden */
  16056. _markAsDirty(): void;
  16057. /** @hidden */
  16058. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. /** @hidden */
  16060. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16061. private _computeTransformMatrices;
  16062. /**
  16063. * Build all resources required to render a skeleton
  16064. */
  16065. prepare(): void;
  16066. /**
  16067. * Gets the list of animatables currently running for this skeleton
  16068. * @returns an array of animatables
  16069. */
  16070. getAnimatables(): IAnimatable[];
  16071. /**
  16072. * Clone the current skeleton
  16073. * @param name defines the name of the new skeleton
  16074. * @param id defines the id of the new skeleton
  16075. * @returns the new skeleton
  16076. */
  16077. clone(name: string, id?: string): Skeleton;
  16078. /**
  16079. * Enable animation blending for this skeleton
  16080. * @param blendingSpeed defines the blending speed to apply
  16081. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16082. */
  16083. enableBlending(blendingSpeed?: number): void;
  16084. /**
  16085. * Releases all resources associated with the current skeleton
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Serialize the skeleton in a JSON object
  16090. * @returns a JSON object
  16091. */
  16092. serialize(): any;
  16093. /**
  16094. * Creates a new skeleton from serialized data
  16095. * @param parsedSkeleton defines the serialized data
  16096. * @param scene defines the hosting scene
  16097. * @returns a new skeleton
  16098. */
  16099. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16100. /**
  16101. * Compute all node absolute transforms
  16102. * @param forceUpdate defines if computation must be done even if cache is up to date
  16103. */
  16104. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16105. /**
  16106. * Gets the root pose matrix
  16107. * @returns a matrix
  16108. */
  16109. getPoseMatrix(): Nullable<Matrix>;
  16110. /**
  16111. * Sorts bones per internal index
  16112. */
  16113. sortBones(): void;
  16114. private _sortBones;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Creates an instance based on a source mesh.
  16120. */
  16121. export class InstancedMesh extends AbstractMesh {
  16122. private _sourceMesh;
  16123. private _currentLOD;
  16124. /** @hidden */
  16125. _indexInSourceMeshInstanceArray: number;
  16126. constructor(name: string, source: Mesh);
  16127. /**
  16128. * Returns the string "InstancedMesh".
  16129. */
  16130. getClassName(): string;
  16131. /** Gets the list of lights affecting that mesh */
  16132. get lightSources(): Light[];
  16133. _resyncLightSources(): void;
  16134. _resyncLightSource(light: Light): void;
  16135. _removeLightSource(light: Light, dispose: boolean): void;
  16136. /**
  16137. * If the source mesh receives shadows
  16138. */
  16139. get receiveShadows(): boolean;
  16140. /**
  16141. * The material of the source mesh
  16142. */
  16143. get material(): Nullable<Material>;
  16144. /**
  16145. * Visibility of the source mesh
  16146. */
  16147. get visibility(): number;
  16148. /**
  16149. * Skeleton of the source mesh
  16150. */
  16151. get skeleton(): Nullable<Skeleton>;
  16152. /**
  16153. * Rendering ground id of the source mesh
  16154. */
  16155. get renderingGroupId(): number;
  16156. set renderingGroupId(value: number);
  16157. /**
  16158. * Returns the total number of vertices (integer).
  16159. */
  16160. getTotalVertices(): number;
  16161. /**
  16162. * Returns a positive integer : the total number of indices in this mesh geometry.
  16163. * @returns the numner of indices or zero if the mesh has no geometry.
  16164. */
  16165. getTotalIndices(): number;
  16166. /**
  16167. * The source mesh of the instance
  16168. */
  16169. get sourceMesh(): Mesh;
  16170. /**
  16171. * Creates a new InstancedMesh object from the mesh model.
  16172. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16173. * @param name defines the name of the new instance
  16174. * @returns a new InstancedMesh
  16175. */
  16176. createInstance(name: string): InstancedMesh;
  16177. /**
  16178. * Is this node ready to be used/rendered
  16179. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16180. * @return {boolean} is it ready
  16181. */
  16182. isReady(completeCheck?: boolean): boolean;
  16183. /**
  16184. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16185. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16186. * @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.
  16187. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16188. */
  16189. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16190. /**
  16191. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16192. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16193. * The `data` are either a numeric array either a Float32Array.
  16194. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16195. * 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).
  16196. * Note that a new underlying VertexBuffer object is created each call.
  16197. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16198. *
  16199. * Possible `kind` values :
  16200. * - VertexBuffer.PositionKind
  16201. * - VertexBuffer.UVKind
  16202. * - VertexBuffer.UV2Kind
  16203. * - VertexBuffer.UV3Kind
  16204. * - VertexBuffer.UV4Kind
  16205. * - VertexBuffer.UV5Kind
  16206. * - VertexBuffer.UV6Kind
  16207. * - VertexBuffer.ColorKind
  16208. * - VertexBuffer.MatricesIndicesKind
  16209. * - VertexBuffer.MatricesIndicesExtraKind
  16210. * - VertexBuffer.MatricesWeightsKind
  16211. * - VertexBuffer.MatricesWeightsExtraKind
  16212. *
  16213. * Returns the Mesh.
  16214. */
  16215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16216. /**
  16217. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16218. * If the mesh has no geometry, it is simply returned as it is.
  16219. * The `data` are either a numeric array either a Float32Array.
  16220. * No new underlying VertexBuffer object is created.
  16221. * 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.
  16222. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16223. *
  16224. * Possible `kind` values :
  16225. * - VertexBuffer.PositionKind
  16226. * - VertexBuffer.UVKind
  16227. * - VertexBuffer.UV2Kind
  16228. * - VertexBuffer.UV3Kind
  16229. * - VertexBuffer.UV4Kind
  16230. * - VertexBuffer.UV5Kind
  16231. * - VertexBuffer.UV6Kind
  16232. * - VertexBuffer.ColorKind
  16233. * - VertexBuffer.MatricesIndicesKind
  16234. * - VertexBuffer.MatricesIndicesExtraKind
  16235. * - VertexBuffer.MatricesWeightsKind
  16236. * - VertexBuffer.MatricesWeightsExtraKind
  16237. *
  16238. * Returns the Mesh.
  16239. */
  16240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16241. /**
  16242. * Sets the mesh indices.
  16243. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16244. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16245. * This method creates a new index buffer each call.
  16246. * Returns the Mesh.
  16247. */
  16248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16249. /**
  16250. * Boolean : True if the mesh owns the requested kind of data.
  16251. */
  16252. isVerticesDataPresent(kind: string): boolean;
  16253. /**
  16254. * Returns an array of indices (IndicesArray).
  16255. */
  16256. getIndices(): Nullable<IndicesArray>;
  16257. get _positions(): Nullable<Vector3[]>;
  16258. /**
  16259. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16260. * This means the mesh underlying bounding box and sphere are recomputed.
  16261. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16262. * @returns the current mesh
  16263. */
  16264. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16265. /** @hidden */
  16266. _preActivate(): InstancedMesh;
  16267. /** @hidden */
  16268. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16269. /** @hidden */
  16270. _postActivate(): void;
  16271. getWorldMatrix(): Matrix;
  16272. get isAnInstance(): boolean;
  16273. /**
  16274. * Returns the current associated LOD AbstractMesh.
  16275. */
  16276. getLOD(camera: Camera): AbstractMesh;
  16277. /** @hidden */
  16278. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16279. /** @hidden */
  16280. _syncSubMeshes(): InstancedMesh;
  16281. /** @hidden */
  16282. _generatePointsArray(): boolean;
  16283. /**
  16284. * Creates a new InstancedMesh from the current mesh.
  16285. * - name (string) : the cloned mesh name
  16286. * - newParent (optional Node) : the optional Node to parent the clone to.
  16287. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16288. *
  16289. * Returns the clone.
  16290. */
  16291. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16292. /**
  16293. * Disposes the InstancedMesh.
  16294. * Returns nothing.
  16295. */
  16296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16297. }
  16298. interface Mesh {
  16299. /**
  16300. * Register a custom buffer that will be instanced
  16301. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16302. * @param kind defines the buffer kind
  16303. * @param stride defines the stride in floats
  16304. */
  16305. registerInstancedBuffer(kind: string, stride: number): void;
  16306. /**
  16307. * true to use the edge renderer for all instances of this mesh
  16308. */
  16309. edgesShareWithInstances: boolean;
  16310. /** @hidden */
  16311. _userInstancedBuffersStorage: {
  16312. data: {
  16313. [key: string]: Float32Array;
  16314. };
  16315. sizes: {
  16316. [key: string]: number;
  16317. };
  16318. vertexBuffers: {
  16319. [key: string]: Nullable<VertexBuffer>;
  16320. };
  16321. strides: {
  16322. [key: string]: number;
  16323. };
  16324. };
  16325. }
  16326. interface AbstractMesh {
  16327. /**
  16328. * Object used to store instanced buffers defined by user
  16329. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16330. */
  16331. instancedBuffers: {
  16332. [key: string]: any;
  16333. };
  16334. }
  16335. }
  16336. declare module BABYLON {
  16337. /**
  16338. * Defines the options associated with the creation of a shader material.
  16339. */
  16340. export interface IShaderMaterialOptions {
  16341. /**
  16342. * Does the material work in alpha blend mode
  16343. */
  16344. needAlphaBlending: boolean;
  16345. /**
  16346. * Does the material work in alpha test mode
  16347. */
  16348. needAlphaTesting: boolean;
  16349. /**
  16350. * The list of attribute names used in the shader
  16351. */
  16352. attributes: string[];
  16353. /**
  16354. * The list of unifrom names used in the shader
  16355. */
  16356. uniforms: string[];
  16357. /**
  16358. * The list of UBO names used in the shader
  16359. */
  16360. uniformBuffers: string[];
  16361. /**
  16362. * The list of sampler names used in the shader
  16363. */
  16364. samplers: string[];
  16365. /**
  16366. * The list of defines used in the shader
  16367. */
  16368. defines: string[];
  16369. }
  16370. /**
  16371. * 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.
  16372. *
  16373. * This returned material effects how the mesh will look based on the code in the shaders.
  16374. *
  16375. * @see http://doc.babylonjs.com/how_to/shader_material
  16376. */
  16377. export class ShaderMaterial extends Material {
  16378. private _shaderPath;
  16379. private _options;
  16380. private _textures;
  16381. private _textureArrays;
  16382. private _floats;
  16383. private _ints;
  16384. private _floatsArrays;
  16385. private _colors3;
  16386. private _colors3Arrays;
  16387. private _colors4;
  16388. private _colors4Arrays;
  16389. private _vectors2;
  16390. private _vectors3;
  16391. private _vectors4;
  16392. private _matrices;
  16393. private _matrixArrays;
  16394. private _matrices3x3;
  16395. private _matrices2x2;
  16396. private _vectors2Arrays;
  16397. private _vectors3Arrays;
  16398. private _vectors4Arrays;
  16399. private _cachedWorldViewMatrix;
  16400. private _cachedWorldViewProjectionMatrix;
  16401. private _renderId;
  16402. private _multiview;
  16403. private _cachedDefines;
  16404. /** Define the Url to load snippets */
  16405. static SnippetUrl: string;
  16406. /** Snippet ID if the material was created from the snippet server */
  16407. snippetId: string;
  16408. /**
  16409. * Instantiate a new shader material.
  16410. * 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.
  16411. * This returned material effects how the mesh will look based on the code in the shaders.
  16412. * @see http://doc.babylonjs.com/how_to/shader_material
  16413. * @param name Define the name of the material in the scene
  16414. * @param scene Define the scene the material belongs to
  16415. * @param shaderPath Defines the route to the shader code in one of three ways:
  16416. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16417. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16418. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16419. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16420. * @param options Define the options used to create the shader
  16421. */
  16422. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16423. /**
  16424. * Gets the shader path used to define the shader code
  16425. * It can be modified to trigger a new compilation
  16426. */
  16427. get shaderPath(): any;
  16428. /**
  16429. * Sets the shader path used to define the shader code
  16430. * It can be modified to trigger a new compilation
  16431. */
  16432. set shaderPath(shaderPath: any);
  16433. /**
  16434. * Gets the options used to compile the shader.
  16435. * They can be modified to trigger a new compilation
  16436. */
  16437. get options(): IShaderMaterialOptions;
  16438. /**
  16439. * Gets the current class name of the material e.g. "ShaderMaterial"
  16440. * Mainly use in serialization.
  16441. * @returns the class name
  16442. */
  16443. getClassName(): string;
  16444. /**
  16445. * Specifies if the material will require alpha blending
  16446. * @returns a boolean specifying if alpha blending is needed
  16447. */
  16448. needAlphaBlending(): boolean;
  16449. /**
  16450. * Specifies if this material should be rendered in alpha test mode
  16451. * @returns a boolean specifying if an alpha test is needed.
  16452. */
  16453. needAlphaTesting(): boolean;
  16454. private _checkUniform;
  16455. /**
  16456. * Set a texture in the shader.
  16457. * @param name Define the name of the uniform samplers as defined in the shader
  16458. * @param texture Define the texture to bind to this sampler
  16459. * @return the material itself allowing "fluent" like uniform updates
  16460. */
  16461. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16462. /**
  16463. * Set a texture array in the shader.
  16464. * @param name Define the name of the uniform sampler array as defined in the shader
  16465. * @param textures Define the list of textures to bind to this sampler
  16466. * @return the material itself allowing "fluent" like uniform updates
  16467. */
  16468. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16469. /**
  16470. * Set a float in the shader.
  16471. * @param name Define the name of the uniform as defined in the shader
  16472. * @param value Define the value to give to the uniform
  16473. * @return the material itself allowing "fluent" like uniform updates
  16474. */
  16475. setFloat(name: string, value: number): ShaderMaterial;
  16476. /**
  16477. * Set a int in the shader.
  16478. * @param name Define the name of the uniform as defined in the shader
  16479. * @param value Define the value to give to the uniform
  16480. * @return the material itself allowing "fluent" like uniform updates
  16481. */
  16482. setInt(name: string, value: number): ShaderMaterial;
  16483. /**
  16484. * Set an array of floats in the shader.
  16485. * @param name Define the name of the uniform as defined in the shader
  16486. * @param value Define the value to give to the uniform
  16487. * @return the material itself allowing "fluent" like uniform updates
  16488. */
  16489. setFloats(name: string, value: number[]): ShaderMaterial;
  16490. /**
  16491. * Set a vec3 in the shader from a Color3.
  16492. * @param name Define the name of the uniform as defined in the shader
  16493. * @param value Define the value to give to the uniform
  16494. * @return the material itself allowing "fluent" like uniform updates
  16495. */
  16496. setColor3(name: string, value: Color3): ShaderMaterial;
  16497. /**
  16498. * Set a vec3 array in the shader from a Color3 array.
  16499. * @param name Define the name of the uniform as defined in the shader
  16500. * @param value Define the value to give to the uniform
  16501. * @return the material itself allowing "fluent" like uniform updates
  16502. */
  16503. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16504. /**
  16505. * Set a vec4 in the shader from a Color4.
  16506. * @param name Define the name of the uniform as defined in the shader
  16507. * @param value Define the value to give to the uniform
  16508. * @return the material itself allowing "fluent" like uniform updates
  16509. */
  16510. setColor4(name: string, value: Color4): ShaderMaterial;
  16511. /**
  16512. * Set a vec4 array in the shader from a Color4 array.
  16513. * @param name Define the name of the uniform as defined in the shader
  16514. * @param value Define the value to give to the uniform
  16515. * @return the material itself allowing "fluent" like uniform updates
  16516. */
  16517. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16518. /**
  16519. * Set a vec2 in the shader from a Vector2.
  16520. * @param name Define the name of the uniform as defined in the shader
  16521. * @param value Define the value to give to the uniform
  16522. * @return the material itself allowing "fluent" like uniform updates
  16523. */
  16524. setVector2(name: string, value: Vector2): ShaderMaterial;
  16525. /**
  16526. * Set a vec3 in the shader from a Vector3.
  16527. * @param name Define the name of the uniform as defined in the shader
  16528. * @param value Define the value to give to the uniform
  16529. * @return the material itself allowing "fluent" like uniform updates
  16530. */
  16531. setVector3(name: string, value: Vector3): ShaderMaterial;
  16532. /**
  16533. * Set a vec4 in the shader from a Vector4.
  16534. * @param name Define the name of the uniform as defined in the shader
  16535. * @param value Define the value to give to the uniform
  16536. * @return the material itself allowing "fluent" like uniform updates
  16537. */
  16538. setVector4(name: string, value: Vector4): ShaderMaterial;
  16539. /**
  16540. * Set a mat4 in the shader from a Matrix.
  16541. * @param name Define the name of the uniform as defined in the shader
  16542. * @param value Define the value to give to the uniform
  16543. * @return the material itself allowing "fluent" like uniform updates
  16544. */
  16545. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16546. /**
  16547. * Set a float32Array in the shader from a matrix array.
  16548. * @param name Define the name of the uniform as defined in the shader
  16549. * @param value Define the value to give to the uniform
  16550. * @return the material itself allowing "fluent" like uniform updates
  16551. */
  16552. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16553. /**
  16554. * Set a mat3 in the shader from a Float32Array.
  16555. * @param name Define the name of the uniform as defined in the shader
  16556. * @param value Define the value to give to the uniform
  16557. * @return the material itself allowing "fluent" like uniform updates
  16558. */
  16559. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16560. /**
  16561. * Set a mat2 in the shader from a Float32Array.
  16562. * @param name Define the name of the uniform as defined in the shader
  16563. * @param value Define the value to give to the uniform
  16564. * @return the material itself allowing "fluent" like uniform updates
  16565. */
  16566. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16567. /**
  16568. * Set a vec2 array in the shader from a number array.
  16569. * @param name Define the name of the uniform as defined in the shader
  16570. * @param value Define the value to give to the uniform
  16571. * @return the material itself allowing "fluent" like uniform updates
  16572. */
  16573. setArray2(name: string, value: number[]): ShaderMaterial;
  16574. /**
  16575. * Set a vec3 array in the shader from a number array.
  16576. * @param name Define the name of the uniform as defined in the shader
  16577. * @param value Define the value to give to the uniform
  16578. * @return the material itself allowing "fluent" like uniform updates
  16579. */
  16580. setArray3(name: string, value: number[]): ShaderMaterial;
  16581. /**
  16582. * Set a vec4 array in the shader from a number array.
  16583. * @param name Define the name of the uniform as defined in the shader
  16584. * @param value Define the value to give to the uniform
  16585. * @return the material itself allowing "fluent" like uniform updates
  16586. */
  16587. setArray4(name: string, value: number[]): ShaderMaterial;
  16588. private _checkCache;
  16589. /**
  16590. * Specifies that the submesh is ready to be used
  16591. * @param mesh defines the mesh to check
  16592. * @param subMesh defines which submesh to check
  16593. * @param useInstances specifies that instances should be used
  16594. * @returns a boolean indicating that the submesh is ready or not
  16595. */
  16596. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16597. /**
  16598. * Checks if the material is ready to render the requested mesh
  16599. * @param mesh Define the mesh to render
  16600. * @param useInstances Define whether or not the material is used with instances
  16601. * @returns true if ready, otherwise false
  16602. */
  16603. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16604. /**
  16605. * Binds the world matrix to the material
  16606. * @param world defines the world transformation matrix
  16607. * @param effectOverride - If provided, use this effect instead of internal effect
  16608. */
  16609. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16610. /**
  16611. * Binds the submesh to this material by preparing the effect and shader to draw
  16612. * @param world defines the world transformation matrix
  16613. * @param mesh defines the mesh containing the submesh
  16614. * @param subMesh defines the submesh to bind the material to
  16615. */
  16616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16617. /**
  16618. * Binds the material to the mesh
  16619. * @param world defines the world transformation matrix
  16620. * @param mesh defines the mesh to bind the material to
  16621. * @param effectOverride - If provided, use this effect instead of internal effect
  16622. */
  16623. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16624. protected _afterBind(mesh?: Mesh): void;
  16625. /**
  16626. * Gets the active textures from the material
  16627. * @returns an array of textures
  16628. */
  16629. getActiveTextures(): BaseTexture[];
  16630. /**
  16631. * Specifies if the material uses a texture
  16632. * @param texture defines the texture to check against the material
  16633. * @returns a boolean specifying if the material uses the texture
  16634. */
  16635. hasTexture(texture: BaseTexture): boolean;
  16636. /**
  16637. * Makes a duplicate of the material, and gives it a new name
  16638. * @param name defines the new name for the duplicated material
  16639. * @returns the cloned material
  16640. */
  16641. clone(name: string): ShaderMaterial;
  16642. /**
  16643. * Disposes the material
  16644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16647. */
  16648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16649. /**
  16650. * Serializes this material in a JSON representation
  16651. * @returns the serialized material object
  16652. */
  16653. serialize(): any;
  16654. /**
  16655. * Creates a shader material from parsed shader material data
  16656. * @param source defines the JSON represnetation of the material
  16657. * @param scene defines the hosting scene
  16658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16659. * @returns a new material
  16660. */
  16661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16662. /**
  16663. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16664. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16665. * @param url defines the url to load from
  16666. * @param scene defines the hosting scene
  16667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16668. * @returns a promise that will resolve to the new ShaderMaterial
  16669. */
  16670. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16671. /**
  16672. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16673. * @param snippetId defines the snippet to load
  16674. * @param scene defines the hosting scene
  16675. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16676. * @returns a promise that will resolve to the new ShaderMaterial
  16677. */
  16678. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16679. }
  16680. }
  16681. declare module BABYLON {
  16682. /** @hidden */
  16683. export var colorPixelShader: {
  16684. name: string;
  16685. shader: string;
  16686. };
  16687. }
  16688. declare module BABYLON {
  16689. /** @hidden */
  16690. export var colorVertexShader: {
  16691. name: string;
  16692. shader: string;
  16693. };
  16694. }
  16695. declare module BABYLON {
  16696. /**
  16697. * Line mesh
  16698. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16699. */
  16700. export class LinesMesh extends Mesh {
  16701. /**
  16702. * If vertex color should be applied to the mesh
  16703. */
  16704. readonly useVertexColor?: boolean | undefined;
  16705. /**
  16706. * If vertex alpha should be applied to the mesh
  16707. */
  16708. readonly useVertexAlpha?: boolean | undefined;
  16709. /**
  16710. * Color of the line (Default: White)
  16711. */
  16712. color: Color3;
  16713. /**
  16714. * Alpha of the line (Default: 1)
  16715. */
  16716. alpha: number;
  16717. /**
  16718. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16719. * This margin is expressed in world space coordinates, so its value may vary.
  16720. * Default value is 0.1
  16721. */
  16722. intersectionThreshold: number;
  16723. private _colorShader;
  16724. private color4;
  16725. /**
  16726. * Creates a new LinesMesh
  16727. * @param name defines the name
  16728. * @param scene defines the hosting scene
  16729. * @param parent defines the parent mesh if any
  16730. * @param source defines the optional source LinesMesh used to clone data from
  16731. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16732. * When false, achieved by calling a clone(), also passing False.
  16733. * This will make creation of children, recursive.
  16734. * @param useVertexColor defines if this LinesMesh supports vertex color
  16735. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16736. */
  16737. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16738. /**
  16739. * If vertex color should be applied to the mesh
  16740. */
  16741. useVertexColor?: boolean | undefined,
  16742. /**
  16743. * If vertex alpha should be applied to the mesh
  16744. */
  16745. useVertexAlpha?: boolean | undefined);
  16746. private _addClipPlaneDefine;
  16747. private _removeClipPlaneDefine;
  16748. isReady(): boolean;
  16749. /**
  16750. * Returns the string "LineMesh"
  16751. */
  16752. getClassName(): string;
  16753. /**
  16754. * @hidden
  16755. */
  16756. get material(): Material;
  16757. /**
  16758. * @hidden
  16759. */
  16760. set material(value: Material);
  16761. /**
  16762. * @hidden
  16763. */
  16764. get checkCollisions(): boolean;
  16765. /** @hidden */
  16766. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16767. /** @hidden */
  16768. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16769. /**
  16770. * Disposes of the line mesh
  16771. * @param doNotRecurse If children should be disposed
  16772. */
  16773. dispose(doNotRecurse?: boolean): void;
  16774. /**
  16775. * Returns a new LineMesh object cloned from the current one.
  16776. */
  16777. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16778. /**
  16779. * Creates a new InstancedLinesMesh object from the mesh model.
  16780. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16781. * @param name defines the name of the new instance
  16782. * @returns a new InstancedLinesMesh
  16783. */
  16784. createInstance(name: string): InstancedLinesMesh;
  16785. }
  16786. /**
  16787. * Creates an instance based on a source LinesMesh
  16788. */
  16789. export class InstancedLinesMesh extends InstancedMesh {
  16790. /**
  16791. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16792. * This margin is expressed in world space coordinates, so its value may vary.
  16793. * Initilized with the intersectionThreshold value of the source LinesMesh
  16794. */
  16795. intersectionThreshold: number;
  16796. constructor(name: string, source: LinesMesh);
  16797. /**
  16798. * Returns the string "InstancedLinesMesh".
  16799. */
  16800. getClassName(): string;
  16801. }
  16802. }
  16803. declare module BABYLON {
  16804. /** @hidden */
  16805. export var linePixelShader: {
  16806. name: string;
  16807. shader: string;
  16808. };
  16809. }
  16810. declare module BABYLON {
  16811. /** @hidden */
  16812. export var lineVertexShader: {
  16813. name: string;
  16814. shader: string;
  16815. };
  16816. }
  16817. declare module BABYLON {
  16818. interface Scene {
  16819. /** @hidden */
  16820. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16821. }
  16822. interface AbstractMesh {
  16823. /**
  16824. * Gets the edgesRenderer associated with the mesh
  16825. */
  16826. edgesRenderer: Nullable<EdgesRenderer>;
  16827. }
  16828. interface LinesMesh {
  16829. /**
  16830. * Enables the edge rendering mode on the mesh.
  16831. * This mode makes the mesh edges visible
  16832. * @param epsilon defines the maximal distance between two angles to detect a face
  16833. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16834. * @returns the currentAbstractMesh
  16835. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16836. */
  16837. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16838. }
  16839. interface InstancedLinesMesh {
  16840. /**
  16841. * Enables the edge rendering mode on the mesh.
  16842. * This mode makes the mesh edges visible
  16843. * @param epsilon defines the maximal distance between two angles to detect a face
  16844. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16845. * @returns the current InstancedLinesMesh
  16846. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16847. */
  16848. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16849. }
  16850. /**
  16851. * Defines the minimum contract an Edges renderer should follow.
  16852. */
  16853. export interface IEdgesRenderer extends IDisposable {
  16854. /**
  16855. * Gets or sets a boolean indicating if the edgesRenderer is active
  16856. */
  16857. isEnabled: boolean;
  16858. /**
  16859. * Renders the edges of the attached mesh,
  16860. */
  16861. render(): void;
  16862. /**
  16863. * Checks wether or not the edges renderer is ready to render.
  16864. * @return true if ready, otherwise false.
  16865. */
  16866. isReady(): boolean;
  16867. /**
  16868. * List of instances to render in case the source mesh has instances
  16869. */
  16870. customInstances: SmartArray<Matrix>;
  16871. }
  16872. /**
  16873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16874. */
  16875. export class EdgesRenderer implements IEdgesRenderer {
  16876. /**
  16877. * Define the size of the edges with an orthographic camera
  16878. */
  16879. edgesWidthScalerForOrthographic: number;
  16880. /**
  16881. * Define the size of the edges with a perspective camera
  16882. */
  16883. edgesWidthScalerForPerspective: number;
  16884. protected _source: AbstractMesh;
  16885. protected _linesPositions: number[];
  16886. protected _linesNormals: number[];
  16887. protected _linesIndices: number[];
  16888. protected _epsilon: number;
  16889. protected _indicesCount: number;
  16890. protected _lineShader: ShaderMaterial;
  16891. protected _ib: DataBuffer;
  16892. protected _buffers: {
  16893. [key: string]: Nullable<VertexBuffer>;
  16894. };
  16895. protected _buffersForInstances: {
  16896. [key: string]: Nullable<VertexBuffer>;
  16897. };
  16898. protected _checkVerticesInsteadOfIndices: boolean;
  16899. private _meshRebuildObserver;
  16900. private _meshDisposeObserver;
  16901. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16902. isEnabled: boolean;
  16903. /**
  16904. * List of instances to render in case the source mesh has instances
  16905. */
  16906. customInstances: SmartArray<Matrix>;
  16907. private static GetShader;
  16908. /**
  16909. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16910. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16911. * @param source Mesh used to create edges
  16912. * @param epsilon sum of angles in adjacency to check for edge
  16913. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16914. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16915. */
  16916. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16917. protected _prepareRessources(): void;
  16918. /** @hidden */
  16919. _rebuild(): void;
  16920. /**
  16921. * Releases the required resources for the edges renderer
  16922. */
  16923. dispose(): void;
  16924. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16925. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16926. /**
  16927. * Checks if the pair of p0 and p1 is en edge
  16928. * @param faceIndex
  16929. * @param edge
  16930. * @param faceNormals
  16931. * @param p0
  16932. * @param p1
  16933. * @private
  16934. */
  16935. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16936. /**
  16937. * push line into the position, normal and index buffer
  16938. * @protected
  16939. */
  16940. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16941. /**
  16942. * Generates lines edges from adjacencjes
  16943. * @private
  16944. */
  16945. _generateEdgesLines(): void;
  16946. /**
  16947. * Checks wether or not the edges renderer is ready to render.
  16948. * @return true if ready, otherwise false.
  16949. */
  16950. isReady(): boolean;
  16951. /**
  16952. * Renders the edges of the attached mesh,
  16953. */
  16954. render(): void;
  16955. }
  16956. /**
  16957. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16958. */
  16959. export class LineEdgesRenderer extends EdgesRenderer {
  16960. /**
  16961. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16962. * @param source LineMesh used to generate edges
  16963. * @param epsilon not important (specified angle for edge detection)
  16964. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16965. */
  16966. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16967. /**
  16968. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16969. */
  16970. _generateEdgesLines(): void;
  16971. }
  16972. }
  16973. declare module BABYLON {
  16974. /**
  16975. * This represents the object necessary to create a rendering group.
  16976. * This is exclusively used and created by the rendering manager.
  16977. * To modify the behavior, you use the available helpers in your scene or meshes.
  16978. * @hidden
  16979. */
  16980. export class RenderingGroup {
  16981. index: number;
  16982. private static _zeroVector;
  16983. private _scene;
  16984. private _opaqueSubMeshes;
  16985. private _transparentSubMeshes;
  16986. private _alphaTestSubMeshes;
  16987. private _depthOnlySubMeshes;
  16988. private _particleSystems;
  16989. private _spriteManagers;
  16990. private _opaqueSortCompareFn;
  16991. private _alphaTestSortCompareFn;
  16992. private _transparentSortCompareFn;
  16993. private _renderOpaque;
  16994. private _renderAlphaTest;
  16995. private _renderTransparent;
  16996. /** @hidden */
  16997. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16998. onBeforeTransparentRendering: () => void;
  16999. /**
  17000. * Set the opaque sort comparison function.
  17001. * If null the sub meshes will be render in the order they were created
  17002. */
  17003. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17004. /**
  17005. * Set the alpha test sort comparison function.
  17006. * If null the sub meshes will be render in the order they were created
  17007. */
  17008. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17009. /**
  17010. * Set the transparent sort comparison function.
  17011. * If null the sub meshes will be render in the order they were created
  17012. */
  17013. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17014. /**
  17015. * Creates a new rendering group.
  17016. * @param index The rendering group index
  17017. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17018. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17019. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17020. */
  17021. 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>);
  17022. /**
  17023. * Render all the sub meshes contained in the group.
  17024. * @param customRenderFunction Used to override the default render behaviour of the group.
  17025. * @returns true if rendered some submeshes.
  17026. */
  17027. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17028. /**
  17029. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17030. * @param subMeshes The submeshes to render
  17031. */
  17032. private renderOpaqueSorted;
  17033. /**
  17034. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17035. * @param subMeshes The submeshes to render
  17036. */
  17037. private renderAlphaTestSorted;
  17038. /**
  17039. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17040. * @param subMeshes The submeshes to render
  17041. */
  17042. private renderTransparentSorted;
  17043. /**
  17044. * Renders the submeshes in a specified order.
  17045. * @param subMeshes The submeshes to sort before render
  17046. * @param sortCompareFn The comparison function use to sort
  17047. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17048. * @param transparent Specifies to activate blending if true
  17049. */
  17050. private static renderSorted;
  17051. /**
  17052. * Renders the submeshes in the order they were dispatched (no sort applied).
  17053. * @param subMeshes The submeshes to render
  17054. */
  17055. private static renderUnsorted;
  17056. /**
  17057. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17058. * are rendered back to front if in the same alpha index.
  17059. *
  17060. * @param a The first submesh
  17061. * @param b The second submesh
  17062. * @returns The result of the comparison
  17063. */
  17064. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17065. /**
  17066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17067. * are rendered back to front.
  17068. *
  17069. * @param a The first submesh
  17070. * @param b The second submesh
  17071. * @returns The result of the comparison
  17072. */
  17073. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17074. /**
  17075. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17076. * are rendered front to back (prevent overdraw).
  17077. *
  17078. * @param a The first submesh
  17079. * @param b The second submesh
  17080. * @returns The result of the comparison
  17081. */
  17082. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17083. /**
  17084. * Resets the different lists of submeshes to prepare a new frame.
  17085. */
  17086. prepare(): void;
  17087. dispose(): void;
  17088. /**
  17089. * Inserts the submesh in its correct queue depending on its material.
  17090. * @param subMesh The submesh to dispatch
  17091. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17092. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17093. */
  17094. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17095. dispatchSprites(spriteManager: ISpriteManager): void;
  17096. dispatchParticles(particleSystem: IParticleSystem): void;
  17097. private _renderParticles;
  17098. private _renderSprites;
  17099. }
  17100. }
  17101. declare module BABYLON {
  17102. /**
  17103. * Interface describing the different options available in the rendering manager
  17104. * regarding Auto Clear between groups.
  17105. */
  17106. export interface IRenderingManagerAutoClearSetup {
  17107. /**
  17108. * Defines whether or not autoclear is enable.
  17109. */
  17110. autoClear: boolean;
  17111. /**
  17112. * Defines whether or not to autoclear the depth buffer.
  17113. */
  17114. depth: boolean;
  17115. /**
  17116. * Defines whether or not to autoclear the stencil buffer.
  17117. */
  17118. stencil: boolean;
  17119. }
  17120. /**
  17121. * This class is used by the onRenderingGroupObservable
  17122. */
  17123. export class RenderingGroupInfo {
  17124. /**
  17125. * The Scene that being rendered
  17126. */
  17127. scene: Scene;
  17128. /**
  17129. * The camera currently used for the rendering pass
  17130. */
  17131. camera: Nullable<Camera>;
  17132. /**
  17133. * The ID of the renderingGroup being processed
  17134. */
  17135. renderingGroupId: number;
  17136. }
  17137. /**
  17138. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17139. * It is enable to manage the different groups as well as the different necessary sort functions.
  17140. * This should not be used directly aside of the few static configurations
  17141. */
  17142. export class RenderingManager {
  17143. /**
  17144. * The max id used for rendering groups (not included)
  17145. */
  17146. static MAX_RENDERINGGROUPS: number;
  17147. /**
  17148. * The min id used for rendering groups (included)
  17149. */
  17150. static MIN_RENDERINGGROUPS: number;
  17151. /**
  17152. * Used to globally prevent autoclearing scenes.
  17153. */
  17154. static AUTOCLEAR: boolean;
  17155. /**
  17156. * @hidden
  17157. */
  17158. _useSceneAutoClearSetup: boolean;
  17159. private _scene;
  17160. private _renderingGroups;
  17161. private _depthStencilBufferAlreadyCleaned;
  17162. private _autoClearDepthStencil;
  17163. private _customOpaqueSortCompareFn;
  17164. private _customAlphaTestSortCompareFn;
  17165. private _customTransparentSortCompareFn;
  17166. private _renderingGroupInfo;
  17167. /**
  17168. * Instantiates a new rendering group for a particular scene
  17169. * @param scene Defines the scene the groups belongs to
  17170. */
  17171. constructor(scene: Scene);
  17172. private _clearDepthStencilBuffer;
  17173. /**
  17174. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17175. * @hidden
  17176. */
  17177. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17178. /**
  17179. * Resets the different information of the group to prepare a new frame
  17180. * @hidden
  17181. */
  17182. reset(): void;
  17183. /**
  17184. * Dispose and release the group and its associated resources.
  17185. * @hidden
  17186. */
  17187. dispose(): void;
  17188. /**
  17189. * Clear the info related to rendering groups preventing retention points during dispose.
  17190. */
  17191. freeRenderingGroups(): void;
  17192. private _prepareRenderingGroup;
  17193. /**
  17194. * Add a sprite manager to the rendering manager in order to render it this frame.
  17195. * @param spriteManager Define the sprite manager to render
  17196. */
  17197. dispatchSprites(spriteManager: ISpriteManager): void;
  17198. /**
  17199. * Add a particle system to the rendering manager in order to render it this frame.
  17200. * @param particleSystem Define the particle system to render
  17201. */
  17202. dispatchParticles(particleSystem: IParticleSystem): void;
  17203. /**
  17204. * Add a submesh to the manager in order to render it this frame
  17205. * @param subMesh The submesh to dispatch
  17206. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17207. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17208. */
  17209. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17210. /**
  17211. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17212. * This allowed control for front to back rendering or reversly depending of the special needs.
  17213. *
  17214. * @param renderingGroupId The rendering group id corresponding to its index
  17215. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17216. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17217. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17218. */
  17219. 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;
  17220. /**
  17221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17222. *
  17223. * @param renderingGroupId The rendering group id corresponding to its index
  17224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17225. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17226. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17227. */
  17228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17229. /**
  17230. * Gets the current auto clear configuration for one rendering group of the rendering
  17231. * manager.
  17232. * @param index the rendering group index to get the information for
  17233. * @returns The auto clear setup for the requested rendering group
  17234. */
  17235. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17236. }
  17237. }
  17238. declare module BABYLON {
  17239. /**
  17240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17241. */
  17242. export interface ICustomShaderOptions {
  17243. /**
  17244. * Gets or sets the custom shader name to use
  17245. */
  17246. shaderName: string;
  17247. /**
  17248. * The list of attribute names used in the shader
  17249. */
  17250. attributes?: string[];
  17251. /**
  17252. * The list of unifrom names used in the shader
  17253. */
  17254. uniforms?: string[];
  17255. /**
  17256. * The list of sampler names used in the shader
  17257. */
  17258. samplers?: string[];
  17259. /**
  17260. * The list of defines used in the shader
  17261. */
  17262. defines?: string[];
  17263. }
  17264. /**
  17265. * Interface to implement to create a shadow generator compatible with BJS.
  17266. */
  17267. export interface IShadowGenerator {
  17268. /**
  17269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17270. * @returns The render target texture if present otherwise, null
  17271. */
  17272. getShadowMap(): Nullable<RenderTargetTexture>;
  17273. /**
  17274. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17275. * @param subMesh The submesh we want to render in the shadow map
  17276. * @param useInstances Defines wether will draw in the map using instances
  17277. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17278. * @returns true if ready otherwise, false
  17279. */
  17280. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17281. /**
  17282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17283. * @param defines Defines of the material we want to update
  17284. * @param lightIndex Index of the light in the enabled light list of the material
  17285. */
  17286. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17287. /**
  17288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17289. * defined in the generator but impacting the effect).
  17290. * It implies the unifroms available on the materials are the standard BJS ones.
  17291. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17292. * @param effect The effect we are binfing the information for
  17293. */
  17294. bindShadowLight(lightIndex: string, effect: Effect): void;
  17295. /**
  17296. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17297. * (eq to shadow prjection matrix * light transform matrix)
  17298. * @returns The transform matrix used to create the shadow map
  17299. */
  17300. getTransformMatrix(): Matrix;
  17301. /**
  17302. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17303. * Cube and 2D textures for instance.
  17304. */
  17305. recreateShadowMap(): void;
  17306. /**
  17307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17308. * @param onCompiled Callback triggered at the and of the effects compilation
  17309. * @param options Sets of optional options forcing the compilation with different modes
  17310. */
  17311. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17312. useInstances: boolean;
  17313. }>): void;
  17314. /**
  17315. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17316. * @param options Sets of optional options forcing the compilation with different modes
  17317. * @returns A promise that resolves when the compilation completes
  17318. */
  17319. forceCompilationAsync(options?: Partial<{
  17320. useInstances: boolean;
  17321. }>): Promise<void>;
  17322. /**
  17323. * Serializes the shadow generator setup to a json object.
  17324. * @returns The serialized JSON object
  17325. */
  17326. serialize(): any;
  17327. /**
  17328. * Disposes the Shadow map and related Textures and effects.
  17329. */
  17330. dispose(): void;
  17331. }
  17332. /**
  17333. * Default implementation IShadowGenerator.
  17334. * This is the main object responsible of generating shadows in the framework.
  17335. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17336. */
  17337. export class ShadowGenerator implements IShadowGenerator {
  17338. /**
  17339. * Name of the shadow generator class
  17340. */
  17341. static CLASSNAME: string;
  17342. /**
  17343. * Shadow generator mode None: no filtering applied.
  17344. */
  17345. static readonly FILTER_NONE: number;
  17346. /**
  17347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17349. */
  17350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17351. /**
  17352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17354. */
  17355. static readonly FILTER_POISSONSAMPLING: number;
  17356. /**
  17357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17359. */
  17360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17361. /**
  17362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17363. * edge artifacts on steep falloff.
  17364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17365. */
  17366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17367. /**
  17368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17369. * edge artifacts on steep falloff.
  17370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17371. */
  17372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17373. /**
  17374. * Shadow generator mode PCF: Percentage Closer Filtering
  17375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17377. */
  17378. static readonly FILTER_PCF: number;
  17379. /**
  17380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17382. * Contact Hardening
  17383. */
  17384. static readonly FILTER_PCSS: number;
  17385. /**
  17386. * Reserved for PCF and PCSS
  17387. * Highest Quality.
  17388. *
  17389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17390. *
  17391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17392. */
  17393. static readonly QUALITY_HIGH: number;
  17394. /**
  17395. * Reserved for PCF and PCSS
  17396. * Good tradeoff for quality/perf cross devices
  17397. *
  17398. * Execute PCF on a 3*3 kernel.
  17399. *
  17400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17401. */
  17402. static readonly QUALITY_MEDIUM: number;
  17403. /**
  17404. * Reserved for PCF and PCSS
  17405. * The lowest quality but the fastest.
  17406. *
  17407. * Execute PCF on a 1*1 kernel.
  17408. *
  17409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17410. */
  17411. static readonly QUALITY_LOW: number;
  17412. /** Gets or sets the custom shader name to use */
  17413. customShaderOptions: ICustomShaderOptions;
  17414. /**
  17415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17416. */
  17417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17418. /**
  17419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17420. */
  17421. onAfterShadowMapRenderObservable: Observable<Effect>;
  17422. /**
  17423. * Observable triggered before a mesh is rendered in the shadow map.
  17424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17425. */
  17426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17427. /**
  17428. * Observable triggered after a mesh is rendered in the shadow map.
  17429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17430. */
  17431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17432. protected _bias: number;
  17433. /**
  17434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17435. */
  17436. get bias(): number;
  17437. /**
  17438. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17439. */
  17440. set bias(bias: number);
  17441. protected _normalBias: number;
  17442. /**
  17443. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17444. */
  17445. get normalBias(): number;
  17446. /**
  17447. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17448. */
  17449. set normalBias(normalBias: number);
  17450. protected _blurBoxOffset: number;
  17451. /**
  17452. * Gets the blur box offset: offset applied during the blur pass.
  17453. * Only useful if useKernelBlur = false
  17454. */
  17455. get blurBoxOffset(): number;
  17456. /**
  17457. * Sets the blur box offset: offset applied during the blur pass.
  17458. * Only useful if useKernelBlur = false
  17459. */
  17460. set blurBoxOffset(value: number);
  17461. protected _blurScale: number;
  17462. /**
  17463. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17464. * 2 means half of the size.
  17465. */
  17466. get blurScale(): number;
  17467. /**
  17468. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17469. * 2 means half of the size.
  17470. */
  17471. set blurScale(value: number);
  17472. protected _blurKernel: number;
  17473. /**
  17474. * Gets the blur kernel: kernel size of the blur pass.
  17475. * Only useful if useKernelBlur = true
  17476. */
  17477. get blurKernel(): number;
  17478. /**
  17479. * Sets the blur kernel: kernel size of the blur pass.
  17480. * Only useful if useKernelBlur = true
  17481. */
  17482. set blurKernel(value: number);
  17483. protected _useKernelBlur: boolean;
  17484. /**
  17485. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17486. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17487. */
  17488. get useKernelBlur(): boolean;
  17489. /**
  17490. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17491. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17492. */
  17493. set useKernelBlur(value: boolean);
  17494. protected _depthScale: number;
  17495. /**
  17496. * Gets the depth scale used in ESM mode.
  17497. */
  17498. get depthScale(): number;
  17499. /**
  17500. * Sets the depth scale used in ESM mode.
  17501. * This can override the scale stored on the light.
  17502. */
  17503. set depthScale(value: number);
  17504. protected _validateFilter(filter: number): number;
  17505. protected _filter: number;
  17506. /**
  17507. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17508. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17509. */
  17510. get filter(): number;
  17511. /**
  17512. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17513. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17514. */
  17515. set filter(value: number);
  17516. /**
  17517. * Gets if the current filter is set to Poisson Sampling.
  17518. */
  17519. get usePoissonSampling(): boolean;
  17520. /**
  17521. * Sets the current filter to Poisson Sampling.
  17522. */
  17523. set usePoissonSampling(value: boolean);
  17524. /**
  17525. * Gets if the current filter is set to ESM.
  17526. */
  17527. get useExponentialShadowMap(): boolean;
  17528. /**
  17529. * Sets the current filter is to ESM.
  17530. */
  17531. set useExponentialShadowMap(value: boolean);
  17532. /**
  17533. * Gets if the current filter is set to filtered ESM.
  17534. */
  17535. get useBlurExponentialShadowMap(): boolean;
  17536. /**
  17537. * Gets if the current filter is set to filtered ESM.
  17538. */
  17539. set useBlurExponentialShadowMap(value: boolean);
  17540. /**
  17541. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17542. * exponential to prevent steep falloff artifacts).
  17543. */
  17544. get useCloseExponentialShadowMap(): boolean;
  17545. /**
  17546. * Sets the current filter to "close ESM" (using the inverse of the
  17547. * exponential to prevent steep falloff artifacts).
  17548. */
  17549. set useCloseExponentialShadowMap(value: boolean);
  17550. /**
  17551. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17552. * exponential to prevent steep falloff artifacts).
  17553. */
  17554. get useBlurCloseExponentialShadowMap(): boolean;
  17555. /**
  17556. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17557. * exponential to prevent steep falloff artifacts).
  17558. */
  17559. set useBlurCloseExponentialShadowMap(value: boolean);
  17560. /**
  17561. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17562. */
  17563. get usePercentageCloserFiltering(): boolean;
  17564. /**
  17565. * Sets the current filter to "PCF" (percentage closer filtering).
  17566. */
  17567. set usePercentageCloserFiltering(value: boolean);
  17568. protected _filteringQuality: number;
  17569. /**
  17570. * Gets the PCF or PCSS Quality.
  17571. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17572. */
  17573. get filteringQuality(): number;
  17574. /**
  17575. * Sets the PCF or PCSS Quality.
  17576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17577. */
  17578. set filteringQuality(filteringQuality: number);
  17579. /**
  17580. * Gets if the current filter is set to "PCSS" (contact hardening).
  17581. */
  17582. get useContactHardeningShadow(): boolean;
  17583. /**
  17584. * Sets the current filter to "PCSS" (contact hardening).
  17585. */
  17586. set useContactHardeningShadow(value: boolean);
  17587. protected _contactHardeningLightSizeUVRatio: number;
  17588. /**
  17589. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17590. * Using a ratio helps keeping shape stability independently of the map size.
  17591. *
  17592. * It does not account for the light projection as it was having too much
  17593. * instability during the light setup or during light position changes.
  17594. *
  17595. * Only valid if useContactHardeningShadow is true.
  17596. */
  17597. get contactHardeningLightSizeUVRatio(): number;
  17598. /**
  17599. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17600. * Using a ratio helps keeping shape stability independently of the map size.
  17601. *
  17602. * It does not account for the light projection as it was having too much
  17603. * instability during the light setup or during light position changes.
  17604. *
  17605. * Only valid if useContactHardeningShadow is true.
  17606. */
  17607. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17608. protected _darkness: number;
  17609. /** Gets or sets the actual darkness of a shadow */
  17610. get darkness(): number;
  17611. set darkness(value: number);
  17612. /**
  17613. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17614. * 0 means strongest and 1 would means no shadow.
  17615. * @returns the darkness.
  17616. */
  17617. getDarkness(): number;
  17618. /**
  17619. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17620. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17621. * @returns the shadow generator allowing fluent coding.
  17622. */
  17623. setDarkness(darkness: number): ShadowGenerator;
  17624. protected _transparencyShadow: boolean;
  17625. /** Gets or sets the ability to have transparent shadow */
  17626. get transparencyShadow(): boolean;
  17627. set transparencyShadow(value: boolean);
  17628. /**
  17629. * Sets the ability to have transparent shadow (boolean).
  17630. * @param transparent True if transparent else False
  17631. * @returns the shadow generator allowing fluent coding
  17632. */
  17633. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17634. /**
  17635. * Enables or disables shadows with varying strength based on the transparency
  17636. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17637. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17638. * mesh.visibility * alphaTexture.a
  17639. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17640. */
  17641. enableSoftTransparentShadow: boolean;
  17642. protected _shadowMap: Nullable<RenderTargetTexture>;
  17643. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17644. /**
  17645. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17646. * @returns The render target texture if present otherwise, null
  17647. */
  17648. getShadowMap(): Nullable<RenderTargetTexture>;
  17649. /**
  17650. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17651. * @returns The render target texture if the shadow map is present otherwise, null
  17652. */
  17653. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17654. /**
  17655. * Gets the class name of that object
  17656. * @returns "ShadowGenerator"
  17657. */
  17658. getClassName(): string;
  17659. /**
  17660. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17661. * @param mesh Mesh to add
  17662. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17663. * @returns the Shadow Generator itself
  17664. */
  17665. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17666. /**
  17667. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17668. * @param mesh Mesh to remove
  17669. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17670. * @returns the Shadow Generator itself
  17671. */
  17672. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17673. /**
  17674. * Controls the extent to which the shadows fade out at the edge of the frustum
  17675. */
  17676. frustumEdgeFalloff: number;
  17677. protected _light: IShadowLight;
  17678. /**
  17679. * Returns the associated light object.
  17680. * @returns the light generating the shadow
  17681. */
  17682. getLight(): IShadowLight;
  17683. /**
  17684. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17685. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17686. * It might on the other hand introduce peter panning.
  17687. */
  17688. forceBackFacesOnly: boolean;
  17689. protected _scene: Scene;
  17690. protected _lightDirection: Vector3;
  17691. protected _effect: Effect;
  17692. protected _viewMatrix: Matrix;
  17693. protected _projectionMatrix: Matrix;
  17694. protected _transformMatrix: Matrix;
  17695. protected _cachedPosition: Vector3;
  17696. protected _cachedDirection: Vector3;
  17697. protected _cachedDefines: string;
  17698. protected _currentRenderID: number;
  17699. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17700. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17701. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17702. protected _blurPostProcesses: PostProcess[];
  17703. protected _mapSize: number;
  17704. protected _currentFaceIndex: number;
  17705. protected _currentFaceIndexCache: number;
  17706. protected _textureType: number;
  17707. protected _defaultTextureMatrix: Matrix;
  17708. protected _storedUniqueId: Nullable<number>;
  17709. /** @hidden */
  17710. static _SceneComponentInitialization: (scene: Scene) => void;
  17711. /**
  17712. * Creates a ShadowGenerator object.
  17713. * A ShadowGenerator is the required tool to use the shadows.
  17714. * Each light casting shadows needs to use its own ShadowGenerator.
  17715. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17716. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17717. * @param light The light object generating the shadows.
  17718. * @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.
  17719. */
  17720. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17721. protected _initializeGenerator(): void;
  17722. protected _createTargetRenderTexture(): void;
  17723. protected _initializeShadowMap(): void;
  17724. protected _initializeBlurRTTAndPostProcesses(): void;
  17725. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17726. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17727. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17728. protected _applyFilterValues(): void;
  17729. /**
  17730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17731. * @param onCompiled Callback triggered at the and of the effects compilation
  17732. * @param options Sets of optional options forcing the compilation with different modes
  17733. */
  17734. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17735. useInstances: boolean;
  17736. }>): void;
  17737. /**
  17738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17739. * @param options Sets of optional options forcing the compilation with different modes
  17740. * @returns A promise that resolves when the compilation completes
  17741. */
  17742. forceCompilationAsync(options?: Partial<{
  17743. useInstances: boolean;
  17744. }>): Promise<void>;
  17745. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17746. private _prepareShadowDefines;
  17747. /**
  17748. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17749. * @param subMesh The submesh we want to render in the shadow map
  17750. * @param useInstances Defines wether will draw in the map using instances
  17751. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17752. * @returns true if ready otherwise, false
  17753. */
  17754. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17755. /**
  17756. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17757. * @param defines Defines of the material we want to update
  17758. * @param lightIndex Index of the light in the enabled light list of the material
  17759. */
  17760. prepareDefines(defines: any, lightIndex: number): void;
  17761. /**
  17762. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17763. * defined in the generator but impacting the effect).
  17764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17765. * @param effect The effect we are binfing the information for
  17766. */
  17767. bindShadowLight(lightIndex: string, effect: Effect): void;
  17768. /**
  17769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17770. * (eq to shadow prjection matrix * light transform matrix)
  17771. * @returns The transform matrix used to create the shadow map
  17772. */
  17773. getTransformMatrix(): Matrix;
  17774. /**
  17775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17776. * Cube and 2D textures for instance.
  17777. */
  17778. recreateShadowMap(): void;
  17779. protected _disposeBlurPostProcesses(): void;
  17780. protected _disposeRTTandPostProcesses(): void;
  17781. /**
  17782. * Disposes the ShadowGenerator.
  17783. * Returns nothing.
  17784. */
  17785. dispose(): void;
  17786. /**
  17787. * Serializes the shadow generator setup to a json object.
  17788. * @returns The serialized JSON object
  17789. */
  17790. serialize(): any;
  17791. /**
  17792. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17793. * @param parsedShadowGenerator The JSON object to parse
  17794. * @param scene The scene to create the shadow map for
  17795. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17796. * @returns The parsed shadow generator
  17797. */
  17798. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17799. }
  17800. }
  17801. declare module BABYLON {
  17802. /**
  17803. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17804. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17805. * 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.
  17806. */
  17807. export abstract class Light extends Node {
  17808. /**
  17809. * Falloff Default: light is falling off following the material specification:
  17810. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17811. */
  17812. static readonly FALLOFF_DEFAULT: number;
  17813. /**
  17814. * Falloff Physical: light is falling off following the inverse squared distance law.
  17815. */
  17816. static readonly FALLOFF_PHYSICAL: number;
  17817. /**
  17818. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17819. * to enhance interoperability with other engines.
  17820. */
  17821. static readonly FALLOFF_GLTF: number;
  17822. /**
  17823. * Falloff Standard: light is falling off like in the standard material
  17824. * to enhance interoperability with other materials.
  17825. */
  17826. static readonly FALLOFF_STANDARD: number;
  17827. /**
  17828. * If every light affecting the material is in this lightmapMode,
  17829. * material.lightmapTexture adds or multiplies
  17830. * (depends on material.useLightmapAsShadowmap)
  17831. * after every other light calculations.
  17832. */
  17833. static readonly LIGHTMAP_DEFAULT: number;
  17834. /**
  17835. * material.lightmapTexture as only diffuse lighting from this light
  17836. * adds only specular lighting from this light
  17837. * adds dynamic shadows
  17838. */
  17839. static readonly LIGHTMAP_SPECULAR: number;
  17840. /**
  17841. * material.lightmapTexture as only lighting
  17842. * no light calculation from this light
  17843. * only adds dynamic shadows from this light
  17844. */
  17845. static readonly LIGHTMAP_SHADOWSONLY: number;
  17846. /**
  17847. * Each light type uses the default quantity according to its type:
  17848. * point/spot lights use luminous intensity
  17849. * directional lights use illuminance
  17850. */
  17851. static readonly INTENSITYMODE_AUTOMATIC: number;
  17852. /**
  17853. * lumen (lm)
  17854. */
  17855. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17856. /**
  17857. * candela (lm/sr)
  17858. */
  17859. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17860. /**
  17861. * lux (lm/m^2)
  17862. */
  17863. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17864. /**
  17865. * nit (cd/m^2)
  17866. */
  17867. static readonly INTENSITYMODE_LUMINANCE: number;
  17868. /**
  17869. * Light type const id of the point light.
  17870. */
  17871. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17872. /**
  17873. * Light type const id of the directional light.
  17874. */
  17875. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17876. /**
  17877. * Light type const id of the spot light.
  17878. */
  17879. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17880. /**
  17881. * Light type const id of the hemispheric light.
  17882. */
  17883. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17884. /**
  17885. * Diffuse gives the basic color to an object.
  17886. */
  17887. diffuse: Color3;
  17888. /**
  17889. * Specular produces a highlight color on an object.
  17890. * Note: This is note affecting PBR materials.
  17891. */
  17892. specular: Color3;
  17893. /**
  17894. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17895. * falling off base on range or angle.
  17896. * This can be set to any values in Light.FALLOFF_x.
  17897. *
  17898. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17899. * other types of materials.
  17900. */
  17901. falloffType: number;
  17902. /**
  17903. * Strength of the light.
  17904. * Note: By default it is define in the framework own unit.
  17905. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17906. */
  17907. intensity: number;
  17908. private _range;
  17909. protected _inverseSquaredRange: number;
  17910. /**
  17911. * Defines how far from the source the light is impacting in scene units.
  17912. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17913. */
  17914. get range(): number;
  17915. /**
  17916. * Defines how far from the source the light is impacting in scene units.
  17917. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17918. */
  17919. set range(value: number);
  17920. /**
  17921. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17922. * of light.
  17923. */
  17924. private _photometricScale;
  17925. private _intensityMode;
  17926. /**
  17927. * Gets the photometric scale used to interpret the intensity.
  17928. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17929. */
  17930. get intensityMode(): number;
  17931. /**
  17932. * Sets the photometric scale used to interpret the intensity.
  17933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17934. */
  17935. set intensityMode(value: number);
  17936. private _radius;
  17937. /**
  17938. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17939. */
  17940. get radius(): number;
  17941. /**
  17942. * sets the light radius used by PBR Materials to simulate soft area lights.
  17943. */
  17944. set radius(value: number);
  17945. private _renderPriority;
  17946. /**
  17947. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17948. * exceeding the number allowed of the materials.
  17949. */
  17950. renderPriority: number;
  17951. private _shadowEnabled;
  17952. /**
  17953. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17954. * the current shadow generator.
  17955. */
  17956. get shadowEnabled(): boolean;
  17957. /**
  17958. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17959. * the current shadow generator.
  17960. */
  17961. set shadowEnabled(value: boolean);
  17962. private _includedOnlyMeshes;
  17963. /**
  17964. * Gets the only meshes impacted by this light.
  17965. */
  17966. get includedOnlyMeshes(): AbstractMesh[];
  17967. /**
  17968. * Sets the only meshes impacted by this light.
  17969. */
  17970. set includedOnlyMeshes(value: AbstractMesh[]);
  17971. private _excludedMeshes;
  17972. /**
  17973. * Gets the meshes not impacted by this light.
  17974. */
  17975. get excludedMeshes(): AbstractMesh[];
  17976. /**
  17977. * Sets the meshes not impacted by this light.
  17978. */
  17979. set excludedMeshes(value: AbstractMesh[]);
  17980. private _excludeWithLayerMask;
  17981. /**
  17982. * Gets the layer id use to find what meshes are not impacted by the light.
  17983. * Inactive if 0
  17984. */
  17985. get excludeWithLayerMask(): number;
  17986. /**
  17987. * Sets the layer id use to find what meshes are not impacted by the light.
  17988. * Inactive if 0
  17989. */
  17990. set excludeWithLayerMask(value: number);
  17991. private _includeOnlyWithLayerMask;
  17992. /**
  17993. * Gets the layer id use to find what meshes are impacted by the light.
  17994. * Inactive if 0
  17995. */
  17996. get includeOnlyWithLayerMask(): number;
  17997. /**
  17998. * Sets the layer id use to find what meshes are impacted by the light.
  17999. * Inactive if 0
  18000. */
  18001. set includeOnlyWithLayerMask(value: number);
  18002. private _lightmapMode;
  18003. /**
  18004. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18005. */
  18006. get lightmapMode(): number;
  18007. /**
  18008. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18009. */
  18010. set lightmapMode(value: number);
  18011. /**
  18012. * Shadow generator associted to the light.
  18013. * @hidden Internal use only.
  18014. */
  18015. _shadowGenerator: Nullable<IShadowGenerator>;
  18016. /**
  18017. * @hidden Internal use only.
  18018. */
  18019. _excludedMeshesIds: string[];
  18020. /**
  18021. * @hidden Internal use only.
  18022. */
  18023. _includedOnlyMeshesIds: string[];
  18024. /**
  18025. * The current light unifom buffer.
  18026. * @hidden Internal use only.
  18027. */
  18028. _uniformBuffer: UniformBuffer;
  18029. /** @hidden */
  18030. _renderId: number;
  18031. /**
  18032. * Creates a Light object in the scene.
  18033. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18034. * @param name The firendly name of the light
  18035. * @param scene The scene the light belongs too
  18036. */
  18037. constructor(name: string, scene: Scene);
  18038. protected abstract _buildUniformLayout(): void;
  18039. /**
  18040. * Sets the passed Effect "effect" with the Light information.
  18041. * @param effect The effect to update
  18042. * @param lightIndex The index of the light in the effect to update
  18043. * @returns The light
  18044. */
  18045. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18046. /**
  18047. * Sets the passed Effect "effect" with the Light textures.
  18048. * @param effect The effect to update
  18049. * @param lightIndex The index of the light in the effect to update
  18050. * @returns The light
  18051. */
  18052. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18053. /**
  18054. * Binds the lights information from the scene to the effect for the given mesh.
  18055. * @param lightIndex Light index
  18056. * @param scene The scene where the light belongs to
  18057. * @param effect The effect we are binding the data to
  18058. * @param useSpecular Defines if specular is supported
  18059. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18060. */
  18061. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18062. /**
  18063. * Sets the passed Effect "effect" with the Light information.
  18064. * @param effect The effect to update
  18065. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18066. * @returns The light
  18067. */
  18068. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18069. /**
  18070. * Returns the string "Light".
  18071. * @returns the class name
  18072. */
  18073. getClassName(): string;
  18074. /** @hidden */
  18075. readonly _isLight: boolean;
  18076. /**
  18077. * Converts the light information to a readable string for debug purpose.
  18078. * @param fullDetails Supports for multiple levels of logging within scene loading
  18079. * @returns the human readable light info
  18080. */
  18081. toString(fullDetails?: boolean): string;
  18082. /** @hidden */
  18083. protected _syncParentEnabledState(): void;
  18084. /**
  18085. * Set the enabled state of this node.
  18086. * @param value - the new enabled state
  18087. */
  18088. setEnabled(value: boolean): void;
  18089. /**
  18090. * Returns the Light associated shadow generator if any.
  18091. * @return the associated shadow generator.
  18092. */
  18093. getShadowGenerator(): Nullable<IShadowGenerator>;
  18094. /**
  18095. * Returns a Vector3, the absolute light position in the World.
  18096. * @returns the world space position of the light
  18097. */
  18098. getAbsolutePosition(): Vector3;
  18099. /**
  18100. * Specifies if the light will affect the passed mesh.
  18101. * @param mesh The mesh to test against the light
  18102. * @return true the mesh is affected otherwise, false.
  18103. */
  18104. canAffectMesh(mesh: AbstractMesh): boolean;
  18105. /**
  18106. * Sort function to order lights for rendering.
  18107. * @param a First Light object to compare to second.
  18108. * @param b Second Light object to compare first.
  18109. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18110. */
  18111. static CompareLightsPriority(a: Light, b: Light): number;
  18112. /**
  18113. * Releases resources associated with this node.
  18114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18116. */
  18117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18118. /**
  18119. * Returns the light type ID (integer).
  18120. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18121. */
  18122. getTypeID(): number;
  18123. /**
  18124. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18125. * @returns the scaled intensity in intensity mode unit
  18126. */
  18127. getScaledIntensity(): number;
  18128. /**
  18129. * Returns a new Light object, named "name", from the current one.
  18130. * @param name The name of the cloned light
  18131. * @param newParent The parent of this light, if it has one
  18132. * @returns the new created light
  18133. */
  18134. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18135. /**
  18136. * Serializes the current light into a Serialization object.
  18137. * @returns the serialized object.
  18138. */
  18139. serialize(): any;
  18140. /**
  18141. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18142. * This new light is named "name" and added to the passed scene.
  18143. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18144. * @param name The friendly name of the light
  18145. * @param scene The scene the new light will belong to
  18146. * @returns the constructor function
  18147. */
  18148. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18149. /**
  18150. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18151. * @param parsedLight The JSON representation of the light
  18152. * @param scene The scene to create the parsed light in
  18153. * @returns the created light after parsing
  18154. */
  18155. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18156. private _hookArrayForExcluded;
  18157. private _hookArrayForIncludedOnly;
  18158. private _resyncMeshes;
  18159. /**
  18160. * Forces the meshes to update their light related information in their rendering used effects
  18161. * @hidden Internal Use Only
  18162. */
  18163. _markMeshesAsLightDirty(): void;
  18164. /**
  18165. * Recomputes the cached photometric scale if needed.
  18166. */
  18167. private _computePhotometricScale;
  18168. /**
  18169. * Returns the Photometric Scale according to the light type and intensity mode.
  18170. */
  18171. private _getPhotometricScale;
  18172. /**
  18173. * Reorder the light in the scene according to their defined priority.
  18174. * @hidden Internal Use Only
  18175. */
  18176. _reorderLightsInScene(): void;
  18177. /**
  18178. * Prepares the list of defines specific to the light type.
  18179. * @param defines the list of defines
  18180. * @param lightIndex defines the index of the light for the effect
  18181. */
  18182. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18183. }
  18184. }
  18185. declare module BABYLON {
  18186. /**
  18187. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18188. * This is the base of the follow, arc rotate cameras and Free camera
  18189. * @see http://doc.babylonjs.com/features/cameras
  18190. */
  18191. export class TargetCamera extends Camera {
  18192. private static _RigCamTransformMatrix;
  18193. private static _TargetTransformMatrix;
  18194. private static _TargetFocalPoint;
  18195. /**
  18196. * Define the current direction the camera is moving to
  18197. */
  18198. cameraDirection: Vector3;
  18199. /**
  18200. * Define the current rotation the camera is rotating to
  18201. */
  18202. cameraRotation: Vector2;
  18203. /**
  18204. * When set, the up vector of the camera will be updated by the rotation of the camera
  18205. */
  18206. updateUpVectorFromRotation: boolean;
  18207. private _tmpQuaternion;
  18208. /**
  18209. * Define the current rotation of the camera
  18210. */
  18211. rotation: Vector3;
  18212. /**
  18213. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18214. */
  18215. rotationQuaternion: Quaternion;
  18216. /**
  18217. * Define the current speed of the camera
  18218. */
  18219. speed: number;
  18220. /**
  18221. * Add constraint to the camera to prevent it to move freely in all directions and
  18222. * around all axis.
  18223. */
  18224. noRotationConstraint: boolean;
  18225. /**
  18226. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18227. * panning
  18228. */
  18229. invertRotation: boolean;
  18230. /**
  18231. * Speed multiplier for inverse camera panning
  18232. */
  18233. inverseRotationSpeed: number;
  18234. /**
  18235. * Define the current target of the camera as an object or a position.
  18236. */
  18237. lockedTarget: any;
  18238. /** @hidden */
  18239. _currentTarget: Vector3;
  18240. /** @hidden */
  18241. _initialFocalDistance: number;
  18242. /** @hidden */
  18243. _viewMatrix: Matrix;
  18244. /** @hidden */
  18245. _camMatrix: Matrix;
  18246. /** @hidden */
  18247. _cameraTransformMatrix: Matrix;
  18248. /** @hidden */
  18249. _cameraRotationMatrix: Matrix;
  18250. /** @hidden */
  18251. _referencePoint: Vector3;
  18252. /** @hidden */
  18253. _transformedReferencePoint: Vector3;
  18254. /** @hidden */
  18255. _reset: () => void;
  18256. private _defaultUp;
  18257. /**
  18258. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18259. * This is the base of the follow, arc rotate cameras and Free camera
  18260. * @see http://doc.babylonjs.com/features/cameras
  18261. * @param name Defines the name of the camera in the scene
  18262. * @param position Defines the start position of the camera in the scene
  18263. * @param scene Defines the scene the camera belongs to
  18264. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18265. */
  18266. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18267. /**
  18268. * Gets the position in front of the camera at a given distance.
  18269. * @param distance The distance from the camera we want the position to be
  18270. * @returns the position
  18271. */
  18272. getFrontPosition(distance: number): Vector3;
  18273. /** @hidden */
  18274. _getLockedTargetPosition(): Nullable<Vector3>;
  18275. private _storedPosition;
  18276. private _storedRotation;
  18277. private _storedRotationQuaternion;
  18278. /**
  18279. * Store current camera state of the camera (fov, position, rotation, etc..)
  18280. * @returns the camera
  18281. */
  18282. storeState(): Camera;
  18283. /**
  18284. * Restored camera state. You must call storeState() first
  18285. * @returns whether it was successful or not
  18286. * @hidden
  18287. */
  18288. _restoreStateValues(): boolean;
  18289. /** @hidden */
  18290. _initCache(): void;
  18291. /** @hidden */
  18292. _updateCache(ignoreParentClass?: boolean): void;
  18293. /** @hidden */
  18294. _isSynchronizedViewMatrix(): boolean;
  18295. /** @hidden */
  18296. _computeLocalCameraSpeed(): number;
  18297. /**
  18298. * Defines the target the camera should look at.
  18299. * @param target Defines the new target as a Vector or a mesh
  18300. */
  18301. setTarget(target: Vector3): void;
  18302. /**
  18303. * Return the current target position of the camera. This value is expressed in local space.
  18304. * @returns the target position
  18305. */
  18306. getTarget(): Vector3;
  18307. /** @hidden */
  18308. _decideIfNeedsToMove(): boolean;
  18309. /** @hidden */
  18310. _updatePosition(): void;
  18311. /** @hidden */
  18312. _checkInputs(): void;
  18313. protected _updateCameraRotationMatrix(): void;
  18314. /**
  18315. * 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)
  18316. * @returns the current camera
  18317. */
  18318. private _rotateUpVectorWithCameraRotationMatrix;
  18319. private _cachedRotationZ;
  18320. private _cachedQuaternionRotationZ;
  18321. /** @hidden */
  18322. _getViewMatrix(): Matrix;
  18323. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18324. /**
  18325. * @hidden
  18326. */
  18327. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18328. /**
  18329. * @hidden
  18330. */
  18331. _updateRigCameras(): void;
  18332. private _getRigCamPositionAndTarget;
  18333. /**
  18334. * Gets the current object class name.
  18335. * @return the class name
  18336. */
  18337. getClassName(): string;
  18338. }
  18339. }
  18340. declare module BABYLON {
  18341. /**
  18342. * Gather the list of keyboard event types as constants.
  18343. */
  18344. export class KeyboardEventTypes {
  18345. /**
  18346. * The keydown event is fired when a key becomes active (pressed).
  18347. */
  18348. static readonly KEYDOWN: number;
  18349. /**
  18350. * The keyup event is fired when a key has been released.
  18351. */
  18352. static readonly KEYUP: number;
  18353. }
  18354. /**
  18355. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18356. */
  18357. export class KeyboardInfo {
  18358. /**
  18359. * Defines the type of event (KeyboardEventTypes)
  18360. */
  18361. type: number;
  18362. /**
  18363. * Defines the related dom event
  18364. */
  18365. event: KeyboardEvent;
  18366. /**
  18367. * Instantiates a new keyboard info.
  18368. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18369. * @param type Defines the type of event (KeyboardEventTypes)
  18370. * @param event Defines the related dom event
  18371. */
  18372. constructor(
  18373. /**
  18374. * Defines the type of event (KeyboardEventTypes)
  18375. */
  18376. type: number,
  18377. /**
  18378. * Defines the related dom event
  18379. */
  18380. event: KeyboardEvent);
  18381. }
  18382. /**
  18383. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18384. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18385. */
  18386. export class KeyboardInfoPre extends KeyboardInfo {
  18387. /**
  18388. * Defines the type of event (KeyboardEventTypes)
  18389. */
  18390. type: number;
  18391. /**
  18392. * Defines the related dom event
  18393. */
  18394. event: KeyboardEvent;
  18395. /**
  18396. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18397. */
  18398. skipOnPointerObservable: boolean;
  18399. /**
  18400. * Instantiates a new keyboard pre info.
  18401. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18402. * @param type Defines the type of event (KeyboardEventTypes)
  18403. * @param event Defines the related dom event
  18404. */
  18405. constructor(
  18406. /**
  18407. * Defines the type of event (KeyboardEventTypes)
  18408. */
  18409. type: number,
  18410. /**
  18411. * Defines the related dom event
  18412. */
  18413. event: KeyboardEvent);
  18414. }
  18415. }
  18416. declare module BABYLON {
  18417. /**
  18418. * Manage the keyboard inputs to control the movement of a free camera.
  18419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18420. */
  18421. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18422. /**
  18423. * Defines the camera the input is attached to.
  18424. */
  18425. camera: FreeCamera;
  18426. /**
  18427. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18428. */
  18429. keysUp: number[];
  18430. /**
  18431. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18432. */
  18433. keysUpward: number[];
  18434. /**
  18435. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18436. */
  18437. keysDown: number[];
  18438. /**
  18439. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18440. */
  18441. keysDownward: number[];
  18442. /**
  18443. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18444. */
  18445. keysLeft: number[];
  18446. /**
  18447. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18448. */
  18449. keysRight: number[];
  18450. private _keys;
  18451. private _onCanvasBlurObserver;
  18452. private _onKeyboardObserver;
  18453. private _engine;
  18454. private _scene;
  18455. /**
  18456. * Attach the input controls to a specific dom element to get the input from.
  18457. * @param element Defines the element the controls should be listened from
  18458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18459. */
  18460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18461. /**
  18462. * Detach the current controls from the specified dom element.
  18463. * @param element Defines the element to stop listening the inputs from
  18464. */
  18465. detachControl(element: Nullable<HTMLElement>): void;
  18466. /**
  18467. * Update the current camera state depending on the inputs that have been used this frame.
  18468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18469. */
  18470. checkInputs(): void;
  18471. /**
  18472. * Gets the class name of the current intput.
  18473. * @returns the class name
  18474. */
  18475. getClassName(): string;
  18476. /** @hidden */
  18477. _onLostFocus(): void;
  18478. /**
  18479. * Get the friendly name associated with the input class.
  18480. * @returns the input friendly name
  18481. */
  18482. getSimpleName(): string;
  18483. }
  18484. }
  18485. declare module BABYLON {
  18486. /**
  18487. * Gather the list of pointer event types as constants.
  18488. */
  18489. export class PointerEventTypes {
  18490. /**
  18491. * 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.
  18492. */
  18493. static readonly POINTERDOWN: number;
  18494. /**
  18495. * The pointerup event is fired when a pointer is no longer active.
  18496. */
  18497. static readonly POINTERUP: number;
  18498. /**
  18499. * The pointermove event is fired when a pointer changes coordinates.
  18500. */
  18501. static readonly POINTERMOVE: number;
  18502. /**
  18503. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18504. */
  18505. static readonly POINTERWHEEL: number;
  18506. /**
  18507. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18508. */
  18509. static readonly POINTERPICK: number;
  18510. /**
  18511. * The pointertap event is fired when a the object has been touched and released without drag.
  18512. */
  18513. static readonly POINTERTAP: number;
  18514. /**
  18515. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18516. */
  18517. static readonly POINTERDOUBLETAP: number;
  18518. }
  18519. /**
  18520. * Base class of pointer info types.
  18521. */
  18522. export class PointerInfoBase {
  18523. /**
  18524. * Defines the type of event (PointerEventTypes)
  18525. */
  18526. type: number;
  18527. /**
  18528. * Defines the related dom event
  18529. */
  18530. event: PointerEvent | MouseWheelEvent;
  18531. /**
  18532. * Instantiates the base class of pointers info.
  18533. * @param type Defines the type of event (PointerEventTypes)
  18534. * @param event Defines the related dom event
  18535. */
  18536. constructor(
  18537. /**
  18538. * Defines the type of event (PointerEventTypes)
  18539. */
  18540. type: number,
  18541. /**
  18542. * Defines the related dom event
  18543. */
  18544. event: PointerEvent | MouseWheelEvent);
  18545. }
  18546. /**
  18547. * This class is used to store pointer related info for the onPrePointerObservable event.
  18548. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18549. */
  18550. export class PointerInfoPre extends PointerInfoBase {
  18551. /**
  18552. * Ray from a pointer if availible (eg. 6dof controller)
  18553. */
  18554. ray: Nullable<Ray>;
  18555. /**
  18556. * Defines the local position of the pointer on the canvas.
  18557. */
  18558. localPosition: Vector2;
  18559. /**
  18560. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18561. */
  18562. skipOnPointerObservable: boolean;
  18563. /**
  18564. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18565. * @param type Defines the type of event (PointerEventTypes)
  18566. * @param event Defines the related dom event
  18567. * @param localX Defines the local x coordinates of the pointer when the event occured
  18568. * @param localY Defines the local y coordinates of the pointer when the event occured
  18569. */
  18570. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18571. }
  18572. /**
  18573. * This type contains all the data related to a pointer event in Babylon.js.
  18574. * 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.
  18575. */
  18576. export class PointerInfo extends PointerInfoBase {
  18577. /**
  18578. * Defines the picking info associated to the info (if any)\
  18579. */
  18580. pickInfo: Nullable<PickingInfo>;
  18581. /**
  18582. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18583. * @param type Defines the type of event (PointerEventTypes)
  18584. * @param event Defines the related dom event
  18585. * @param pickInfo Defines the picking info associated to the info (if any)\
  18586. */
  18587. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18588. /**
  18589. * Defines the picking info associated to the info (if any)\
  18590. */
  18591. pickInfo: Nullable<PickingInfo>);
  18592. }
  18593. /**
  18594. * Data relating to a touch event on the screen.
  18595. */
  18596. export interface PointerTouch {
  18597. /**
  18598. * X coordinate of touch.
  18599. */
  18600. x: number;
  18601. /**
  18602. * Y coordinate of touch.
  18603. */
  18604. y: number;
  18605. /**
  18606. * Id of touch. Unique for each finger.
  18607. */
  18608. pointerId: number;
  18609. /**
  18610. * Event type passed from DOM.
  18611. */
  18612. type: any;
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /**
  18617. * Manage the mouse inputs to control the movement of a free camera.
  18618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18619. */
  18620. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18621. /**
  18622. * Define if touch is enabled in the mouse input
  18623. */
  18624. touchEnabled: boolean;
  18625. /**
  18626. * Defines the camera the input is attached to.
  18627. */
  18628. camera: FreeCamera;
  18629. /**
  18630. * Defines the buttons associated with the input to handle camera move.
  18631. */
  18632. buttons: number[];
  18633. /**
  18634. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18635. */
  18636. angularSensibility: number;
  18637. private _pointerInput;
  18638. private _onMouseMove;
  18639. private _observer;
  18640. private previousPosition;
  18641. /**
  18642. * Observable for when a pointer move event occurs containing the move offset
  18643. */
  18644. onPointerMovedObservable: Observable<{
  18645. offsetX: number;
  18646. offsetY: number;
  18647. }>;
  18648. /**
  18649. * @hidden
  18650. * If the camera should be rotated automatically based on pointer movement
  18651. */
  18652. _allowCameraRotation: boolean;
  18653. /**
  18654. * Manage the mouse inputs to control the movement of a free camera.
  18655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18656. * @param touchEnabled Defines if touch is enabled or not
  18657. */
  18658. constructor(
  18659. /**
  18660. * Define if touch is enabled in the mouse input
  18661. */
  18662. touchEnabled?: boolean);
  18663. /**
  18664. * Attach the input controls to a specific dom element to get the input from.
  18665. * @param element Defines the element the controls should be listened from
  18666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18667. */
  18668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18669. /**
  18670. * Called on JS contextmenu event.
  18671. * Override this method to provide functionality.
  18672. */
  18673. protected onContextMenu(evt: PointerEvent): void;
  18674. /**
  18675. * Detach the current controls from the specified dom element.
  18676. * @param element Defines the element to stop listening the inputs from
  18677. */
  18678. detachControl(element: Nullable<HTMLElement>): void;
  18679. /**
  18680. * Gets the class name of the current intput.
  18681. * @returns the class name
  18682. */
  18683. getClassName(): string;
  18684. /**
  18685. * Get the friendly name associated with the input class.
  18686. * @returns the input friendly name
  18687. */
  18688. getSimpleName(): string;
  18689. }
  18690. }
  18691. declare module BABYLON {
  18692. /**
  18693. * Manage the touch inputs to control the movement of a free camera.
  18694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18695. */
  18696. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18697. /**
  18698. * Defines the camera the input is attached to.
  18699. */
  18700. camera: FreeCamera;
  18701. /**
  18702. * Defines the touch sensibility for rotation.
  18703. * The higher the faster.
  18704. */
  18705. touchAngularSensibility: number;
  18706. /**
  18707. * Defines the touch sensibility for move.
  18708. * The higher the faster.
  18709. */
  18710. touchMoveSensibility: number;
  18711. private _offsetX;
  18712. private _offsetY;
  18713. private _pointerPressed;
  18714. private _pointerInput;
  18715. private _observer;
  18716. private _onLostFocus;
  18717. /**
  18718. * Attach the input controls to a specific dom element to get the input from.
  18719. * @param element Defines the element the controls should be listened from
  18720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18721. */
  18722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18723. /**
  18724. * Detach the current controls from the specified dom element.
  18725. * @param element Defines the element to stop listening the inputs from
  18726. */
  18727. detachControl(element: Nullable<HTMLElement>): void;
  18728. /**
  18729. * Update the current camera state depending on the inputs that have been used this frame.
  18730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18731. */
  18732. checkInputs(): void;
  18733. /**
  18734. * Gets the class name of the current intput.
  18735. * @returns the class name
  18736. */
  18737. getClassName(): string;
  18738. /**
  18739. * Get the friendly name associated with the input class.
  18740. * @returns the input friendly name
  18741. */
  18742. getSimpleName(): string;
  18743. }
  18744. }
  18745. declare module BABYLON {
  18746. /**
  18747. * Default Inputs manager for the FreeCamera.
  18748. * It groups all the default supported inputs for ease of use.
  18749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18750. */
  18751. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18752. /**
  18753. * @hidden
  18754. */
  18755. _mouseInput: Nullable<FreeCameraMouseInput>;
  18756. /**
  18757. * Instantiates a new FreeCameraInputsManager.
  18758. * @param camera Defines the camera the inputs belong to
  18759. */
  18760. constructor(camera: FreeCamera);
  18761. /**
  18762. * Add keyboard input support to the input manager.
  18763. * @returns the current input manager
  18764. */
  18765. addKeyboard(): FreeCameraInputsManager;
  18766. /**
  18767. * Add mouse input support to the input manager.
  18768. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18769. * @returns the current input manager
  18770. */
  18771. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18772. /**
  18773. * Removes the mouse input support from the manager
  18774. * @returns the current input manager
  18775. */
  18776. removeMouse(): FreeCameraInputsManager;
  18777. /**
  18778. * Add touch input support to the input manager.
  18779. * @returns the current input manager
  18780. */
  18781. addTouch(): FreeCameraInputsManager;
  18782. /**
  18783. * Remove all attached input methods from a camera
  18784. */
  18785. clear(): void;
  18786. }
  18787. }
  18788. declare module BABYLON {
  18789. /**
  18790. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18791. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18793. */
  18794. export class FreeCamera extends TargetCamera {
  18795. /**
  18796. * Define the collision ellipsoid of the camera.
  18797. * This is helpful to simulate a camera body like the player body around the camera
  18798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18799. */
  18800. ellipsoid: Vector3;
  18801. /**
  18802. * Define an offset for the position of the ellipsoid around the camera.
  18803. * This can be helpful to determine the center of the body near the gravity center of the body
  18804. * instead of its head.
  18805. */
  18806. ellipsoidOffset: Vector3;
  18807. /**
  18808. * Enable or disable collisions of the camera with the rest of the scene objects.
  18809. */
  18810. checkCollisions: boolean;
  18811. /**
  18812. * Enable or disable gravity on the camera.
  18813. */
  18814. applyGravity: boolean;
  18815. /**
  18816. * Define the input manager associated to the camera.
  18817. */
  18818. inputs: FreeCameraInputsManager;
  18819. /**
  18820. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18821. * Higher values reduce sensitivity.
  18822. */
  18823. get angularSensibility(): number;
  18824. /**
  18825. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18826. * Higher values reduce sensitivity.
  18827. */
  18828. set angularSensibility(value: number);
  18829. /**
  18830. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18831. */
  18832. get keysUp(): number[];
  18833. set keysUp(value: number[]);
  18834. /**
  18835. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18836. */
  18837. get keysUpward(): number[];
  18838. set keysUpward(value: number[]);
  18839. /**
  18840. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18841. */
  18842. get keysDown(): number[];
  18843. set keysDown(value: number[]);
  18844. /**
  18845. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18846. */
  18847. get keysDownward(): number[];
  18848. set keysDownward(value: number[]);
  18849. /**
  18850. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18851. */
  18852. get keysLeft(): number[];
  18853. set keysLeft(value: number[]);
  18854. /**
  18855. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18856. */
  18857. get keysRight(): number[];
  18858. set keysRight(value: number[]);
  18859. /**
  18860. * Event raised when the camera collide with a mesh in the scene.
  18861. */
  18862. onCollide: (collidedMesh: AbstractMesh) => void;
  18863. private _collider;
  18864. private _needMoveForGravity;
  18865. private _oldPosition;
  18866. private _diffPosition;
  18867. private _newPosition;
  18868. /** @hidden */
  18869. _localDirection: Vector3;
  18870. /** @hidden */
  18871. _transformedDirection: Vector3;
  18872. /**
  18873. * Instantiates a Free Camera.
  18874. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18875. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18877. * @param name Define the name of the camera in the scene
  18878. * @param position Define the start position of the camera in the scene
  18879. * @param scene Define the scene the camera belongs to
  18880. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18881. */
  18882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18883. /**
  18884. * Attached controls to the current camera.
  18885. * @param element Defines the element the controls should be listened from
  18886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18887. */
  18888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18889. /**
  18890. * Detach the current controls from the camera.
  18891. * The camera will stop reacting to inputs.
  18892. * @param element Defines the element to stop listening the inputs from
  18893. */
  18894. detachControl(element: HTMLElement): void;
  18895. private _collisionMask;
  18896. /**
  18897. * Define a collision mask to limit the list of object the camera can collide with
  18898. */
  18899. get collisionMask(): number;
  18900. set collisionMask(mask: number);
  18901. /** @hidden */
  18902. _collideWithWorld(displacement: Vector3): void;
  18903. private _onCollisionPositionChange;
  18904. /** @hidden */
  18905. _checkInputs(): void;
  18906. /** @hidden */
  18907. _decideIfNeedsToMove(): boolean;
  18908. /** @hidden */
  18909. _updatePosition(): void;
  18910. /**
  18911. * Destroy the camera and release the current resources hold by it.
  18912. */
  18913. dispose(): void;
  18914. /**
  18915. * Gets the current object class name.
  18916. * @return the class name
  18917. */
  18918. getClassName(): string;
  18919. }
  18920. }
  18921. declare module BABYLON {
  18922. /**
  18923. * Represents a gamepad control stick position
  18924. */
  18925. export class StickValues {
  18926. /**
  18927. * The x component of the control stick
  18928. */
  18929. x: number;
  18930. /**
  18931. * The y component of the control stick
  18932. */
  18933. y: number;
  18934. /**
  18935. * Initializes the gamepad x and y control stick values
  18936. * @param x The x component of the gamepad control stick value
  18937. * @param y The y component of the gamepad control stick value
  18938. */
  18939. constructor(
  18940. /**
  18941. * The x component of the control stick
  18942. */
  18943. x: number,
  18944. /**
  18945. * The y component of the control stick
  18946. */
  18947. y: number);
  18948. }
  18949. /**
  18950. * An interface which manages callbacks for gamepad button changes
  18951. */
  18952. export interface GamepadButtonChanges {
  18953. /**
  18954. * Called when a gamepad has been changed
  18955. */
  18956. changed: boolean;
  18957. /**
  18958. * Called when a gamepad press event has been triggered
  18959. */
  18960. pressChanged: boolean;
  18961. /**
  18962. * Called when a touch event has been triggered
  18963. */
  18964. touchChanged: boolean;
  18965. /**
  18966. * Called when a value has changed
  18967. */
  18968. valueChanged: boolean;
  18969. }
  18970. /**
  18971. * Represents a gamepad
  18972. */
  18973. export class Gamepad {
  18974. /**
  18975. * The id of the gamepad
  18976. */
  18977. id: string;
  18978. /**
  18979. * The index of the gamepad
  18980. */
  18981. index: number;
  18982. /**
  18983. * The browser gamepad
  18984. */
  18985. browserGamepad: any;
  18986. /**
  18987. * Specifies what type of gamepad this represents
  18988. */
  18989. type: number;
  18990. private _leftStick;
  18991. private _rightStick;
  18992. /** @hidden */
  18993. _isConnected: boolean;
  18994. private _leftStickAxisX;
  18995. private _leftStickAxisY;
  18996. private _rightStickAxisX;
  18997. private _rightStickAxisY;
  18998. /**
  18999. * Triggered when the left control stick has been changed
  19000. */
  19001. private _onleftstickchanged;
  19002. /**
  19003. * Triggered when the right control stick has been changed
  19004. */
  19005. private _onrightstickchanged;
  19006. /**
  19007. * Represents a gamepad controller
  19008. */
  19009. static GAMEPAD: number;
  19010. /**
  19011. * Represents a generic controller
  19012. */
  19013. static GENERIC: number;
  19014. /**
  19015. * Represents an XBox controller
  19016. */
  19017. static XBOX: number;
  19018. /**
  19019. * Represents a pose-enabled controller
  19020. */
  19021. static POSE_ENABLED: number;
  19022. /**
  19023. * Represents an Dual Shock controller
  19024. */
  19025. static DUALSHOCK: number;
  19026. /**
  19027. * Specifies whether the left control stick should be Y-inverted
  19028. */
  19029. protected _invertLeftStickY: boolean;
  19030. /**
  19031. * Specifies if the gamepad has been connected
  19032. */
  19033. get isConnected(): boolean;
  19034. /**
  19035. * Initializes the gamepad
  19036. * @param id The id of the gamepad
  19037. * @param index The index of the gamepad
  19038. * @param browserGamepad The browser gamepad
  19039. * @param leftStickX The x component of the left joystick
  19040. * @param leftStickY The y component of the left joystick
  19041. * @param rightStickX The x component of the right joystick
  19042. * @param rightStickY The y component of the right joystick
  19043. */
  19044. constructor(
  19045. /**
  19046. * The id of the gamepad
  19047. */
  19048. id: string,
  19049. /**
  19050. * The index of the gamepad
  19051. */
  19052. index: number,
  19053. /**
  19054. * The browser gamepad
  19055. */
  19056. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19057. /**
  19058. * Callback triggered when the left joystick has changed
  19059. * @param callback
  19060. */
  19061. onleftstickchanged(callback: (values: StickValues) => void): void;
  19062. /**
  19063. * Callback triggered when the right joystick has changed
  19064. * @param callback
  19065. */
  19066. onrightstickchanged(callback: (values: StickValues) => void): void;
  19067. /**
  19068. * Gets the left joystick
  19069. */
  19070. get leftStick(): StickValues;
  19071. /**
  19072. * Sets the left joystick values
  19073. */
  19074. set leftStick(newValues: StickValues);
  19075. /**
  19076. * Gets the right joystick
  19077. */
  19078. get rightStick(): StickValues;
  19079. /**
  19080. * Sets the right joystick value
  19081. */
  19082. set rightStick(newValues: StickValues);
  19083. /**
  19084. * Updates the gamepad joystick positions
  19085. */
  19086. update(): void;
  19087. /**
  19088. * Disposes the gamepad
  19089. */
  19090. dispose(): void;
  19091. }
  19092. /**
  19093. * Represents a generic gamepad
  19094. */
  19095. export class GenericPad extends Gamepad {
  19096. private _buttons;
  19097. private _onbuttondown;
  19098. private _onbuttonup;
  19099. /**
  19100. * Observable triggered when a button has been pressed
  19101. */
  19102. onButtonDownObservable: Observable<number>;
  19103. /**
  19104. * Observable triggered when a button has been released
  19105. */
  19106. onButtonUpObservable: Observable<number>;
  19107. /**
  19108. * Callback triggered when a button has been pressed
  19109. * @param callback Called when a button has been pressed
  19110. */
  19111. onbuttondown(callback: (buttonPressed: number) => void): void;
  19112. /**
  19113. * Callback triggered when a button has been released
  19114. * @param callback Called when a button has been released
  19115. */
  19116. onbuttonup(callback: (buttonReleased: number) => void): void;
  19117. /**
  19118. * Initializes the generic gamepad
  19119. * @param id The id of the generic gamepad
  19120. * @param index The index of the generic gamepad
  19121. * @param browserGamepad The browser gamepad
  19122. */
  19123. constructor(id: string, index: number, browserGamepad: any);
  19124. private _setButtonValue;
  19125. /**
  19126. * Updates the generic gamepad
  19127. */
  19128. update(): void;
  19129. /**
  19130. * Disposes the generic gamepad
  19131. */
  19132. dispose(): void;
  19133. }
  19134. }
  19135. declare module BABYLON {
  19136. /**
  19137. * Defines the types of pose enabled controllers that are supported
  19138. */
  19139. export enum PoseEnabledControllerType {
  19140. /**
  19141. * HTC Vive
  19142. */
  19143. VIVE = 0,
  19144. /**
  19145. * Oculus Rift
  19146. */
  19147. OCULUS = 1,
  19148. /**
  19149. * Windows mixed reality
  19150. */
  19151. WINDOWS = 2,
  19152. /**
  19153. * Samsung gear VR
  19154. */
  19155. GEAR_VR = 3,
  19156. /**
  19157. * Google Daydream
  19158. */
  19159. DAYDREAM = 4,
  19160. /**
  19161. * Generic
  19162. */
  19163. GENERIC = 5
  19164. }
  19165. /**
  19166. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19167. */
  19168. export interface MutableGamepadButton {
  19169. /**
  19170. * Value of the button/trigger
  19171. */
  19172. value: number;
  19173. /**
  19174. * If the button/trigger is currently touched
  19175. */
  19176. touched: boolean;
  19177. /**
  19178. * If the button/trigger is currently pressed
  19179. */
  19180. pressed: boolean;
  19181. }
  19182. /**
  19183. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19184. * @hidden
  19185. */
  19186. export interface ExtendedGamepadButton extends GamepadButton {
  19187. /**
  19188. * If the button/trigger is currently pressed
  19189. */
  19190. readonly pressed: boolean;
  19191. /**
  19192. * If the button/trigger is currently touched
  19193. */
  19194. readonly touched: boolean;
  19195. /**
  19196. * Value of the button/trigger
  19197. */
  19198. readonly value: number;
  19199. }
  19200. /** @hidden */
  19201. export interface _GamePadFactory {
  19202. /**
  19203. * Returns whether or not the current gamepad can be created for this type of controller.
  19204. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19205. * @returns true if it can be created, otherwise false
  19206. */
  19207. canCreate(gamepadInfo: any): boolean;
  19208. /**
  19209. * Creates a new instance of the Gamepad.
  19210. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19211. * @returns the new gamepad instance
  19212. */
  19213. create(gamepadInfo: any): Gamepad;
  19214. }
  19215. /**
  19216. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19217. */
  19218. export class PoseEnabledControllerHelper {
  19219. /** @hidden */
  19220. static _ControllerFactories: _GamePadFactory[];
  19221. /** @hidden */
  19222. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19223. /**
  19224. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19225. * @param vrGamepad the gamepad to initialized
  19226. * @returns a vr controller of the type the gamepad identified as
  19227. */
  19228. static InitiateController(vrGamepad: any): Gamepad;
  19229. }
  19230. /**
  19231. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19232. */
  19233. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19234. /**
  19235. * If the controller is used in a webXR session
  19236. */
  19237. isXR: boolean;
  19238. private _deviceRoomPosition;
  19239. private _deviceRoomRotationQuaternion;
  19240. /**
  19241. * The device position in babylon space
  19242. */
  19243. devicePosition: Vector3;
  19244. /**
  19245. * The device rotation in babylon space
  19246. */
  19247. deviceRotationQuaternion: Quaternion;
  19248. /**
  19249. * The scale factor of the device in babylon space
  19250. */
  19251. deviceScaleFactor: number;
  19252. /**
  19253. * (Likely devicePosition should be used instead) The device position in its room space
  19254. */
  19255. position: Vector3;
  19256. /**
  19257. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19258. */
  19259. rotationQuaternion: Quaternion;
  19260. /**
  19261. * The type of controller (Eg. Windows mixed reality)
  19262. */
  19263. controllerType: PoseEnabledControllerType;
  19264. protected _calculatedPosition: Vector3;
  19265. private _calculatedRotation;
  19266. /**
  19267. * The raw pose from the device
  19268. */
  19269. rawPose: DevicePose;
  19270. private _trackPosition;
  19271. private _maxRotationDistFromHeadset;
  19272. private _draggedRoomRotation;
  19273. /**
  19274. * @hidden
  19275. */
  19276. _disableTrackPosition(fixedPosition: Vector3): void;
  19277. /**
  19278. * Internal, the mesh attached to the controller
  19279. * @hidden
  19280. */
  19281. _mesh: Nullable<AbstractMesh>;
  19282. private _poseControlledCamera;
  19283. private _leftHandSystemQuaternion;
  19284. /**
  19285. * Internal, matrix used to convert room space to babylon space
  19286. * @hidden
  19287. */
  19288. _deviceToWorld: Matrix;
  19289. /**
  19290. * Node to be used when casting a ray from the controller
  19291. * @hidden
  19292. */
  19293. _pointingPoseNode: Nullable<TransformNode>;
  19294. /**
  19295. * Name of the child mesh that can be used to cast a ray from the controller
  19296. */
  19297. static readonly POINTING_POSE: string;
  19298. /**
  19299. * Creates a new PoseEnabledController from a gamepad
  19300. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19301. */
  19302. constructor(browserGamepad: any);
  19303. private _workingMatrix;
  19304. /**
  19305. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19306. */
  19307. update(): void;
  19308. /**
  19309. * Updates only the pose device and mesh without doing any button event checking
  19310. */
  19311. protected _updatePoseAndMesh(): void;
  19312. /**
  19313. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19314. * @param poseData raw pose fromthe device
  19315. */
  19316. updateFromDevice(poseData: DevicePose): void;
  19317. /**
  19318. * @hidden
  19319. */
  19320. _meshAttachedObservable: Observable<AbstractMesh>;
  19321. /**
  19322. * Attaches a mesh to the controller
  19323. * @param mesh the mesh to be attached
  19324. */
  19325. attachToMesh(mesh: AbstractMesh): void;
  19326. /**
  19327. * Attaches the controllers mesh to a camera
  19328. * @param camera the camera the mesh should be attached to
  19329. */
  19330. attachToPoseControlledCamera(camera: TargetCamera): void;
  19331. /**
  19332. * Disposes of the controller
  19333. */
  19334. dispose(): void;
  19335. /**
  19336. * The mesh that is attached to the controller
  19337. */
  19338. get mesh(): Nullable<AbstractMesh>;
  19339. /**
  19340. * Gets the ray of the controller in the direction the controller is pointing
  19341. * @param length the length the resulting ray should be
  19342. * @returns a ray in the direction the controller is pointing
  19343. */
  19344. getForwardRay(length?: number): Ray;
  19345. }
  19346. }
  19347. declare module BABYLON {
  19348. /**
  19349. * Defines the WebVRController object that represents controllers tracked in 3D space
  19350. */
  19351. export abstract class WebVRController extends PoseEnabledController {
  19352. /**
  19353. * Internal, the default controller model for the controller
  19354. */
  19355. protected _defaultModel: Nullable<AbstractMesh>;
  19356. /**
  19357. * Fired when the trigger state has changed
  19358. */
  19359. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19360. /**
  19361. * Fired when the main button state has changed
  19362. */
  19363. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19364. /**
  19365. * Fired when the secondary button state has changed
  19366. */
  19367. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19368. /**
  19369. * Fired when the pad state has changed
  19370. */
  19371. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19372. /**
  19373. * Fired when controllers stick values have changed
  19374. */
  19375. onPadValuesChangedObservable: Observable<StickValues>;
  19376. /**
  19377. * Array of button availible on the controller
  19378. */
  19379. protected _buttons: Array<MutableGamepadButton>;
  19380. private _onButtonStateChange;
  19381. /**
  19382. * Fired when a controller button's state has changed
  19383. * @param callback the callback containing the button that was modified
  19384. */
  19385. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19386. /**
  19387. * X and Y axis corresponding to the controllers joystick
  19388. */
  19389. pad: StickValues;
  19390. /**
  19391. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19392. */
  19393. hand: string;
  19394. /**
  19395. * The default controller model for the controller
  19396. */
  19397. get defaultModel(): Nullable<AbstractMesh>;
  19398. /**
  19399. * Creates a new WebVRController from a gamepad
  19400. * @param vrGamepad the gamepad that the WebVRController should be created from
  19401. */
  19402. constructor(vrGamepad: any);
  19403. /**
  19404. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19405. */
  19406. update(): void;
  19407. /**
  19408. * Function to be called when a button is modified
  19409. */
  19410. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19411. /**
  19412. * Loads a mesh and attaches it to the controller
  19413. * @param scene the scene the mesh should be added to
  19414. * @param meshLoaded callback for when the mesh has been loaded
  19415. */
  19416. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19417. private _setButtonValue;
  19418. private _changes;
  19419. private _checkChanges;
  19420. /**
  19421. * Disposes of th webVRCOntroller
  19422. */
  19423. dispose(): void;
  19424. }
  19425. }
  19426. declare module BABYLON {
  19427. /**
  19428. * The HemisphericLight simulates the ambient environment light,
  19429. * so the passed direction is the light reflection direction, not the incoming direction.
  19430. */
  19431. export class HemisphericLight extends Light {
  19432. /**
  19433. * The groundColor is the light in the opposite direction to the one specified during creation.
  19434. * 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.
  19435. */
  19436. groundColor: Color3;
  19437. /**
  19438. * The light reflection direction, not the incoming direction.
  19439. */
  19440. direction: Vector3;
  19441. /**
  19442. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19443. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19444. * The HemisphericLight can't cast shadows.
  19445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19446. * @param name The friendly name of the light
  19447. * @param direction The direction of the light reflection
  19448. * @param scene The scene the light belongs to
  19449. */
  19450. constructor(name: string, direction: Vector3, scene: Scene);
  19451. protected _buildUniformLayout(): void;
  19452. /**
  19453. * Returns the string "HemisphericLight".
  19454. * @return The class name
  19455. */
  19456. getClassName(): string;
  19457. /**
  19458. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19459. * Returns the updated direction.
  19460. * @param target The target the direction should point to
  19461. * @return The computed direction
  19462. */
  19463. setDirectionToTarget(target: Vector3): Vector3;
  19464. /**
  19465. * Returns the shadow generator associated to the light.
  19466. * @returns Always null for hemispheric lights because it does not support shadows.
  19467. */
  19468. getShadowGenerator(): Nullable<IShadowGenerator>;
  19469. /**
  19470. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19471. * @param effect The effect to update
  19472. * @param lightIndex The index of the light in the effect to update
  19473. * @returns The hemispheric light
  19474. */
  19475. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19476. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19477. /**
  19478. * Computes the world matrix of the node
  19479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19480. * @param useWasUpdatedFlag defines a reserved property
  19481. * @returns the world matrix
  19482. */
  19483. computeWorldMatrix(): Matrix;
  19484. /**
  19485. * Returns the integer 3.
  19486. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19487. */
  19488. getTypeID(): number;
  19489. /**
  19490. * Prepares the list of defines specific to the light type.
  19491. * @param defines the list of defines
  19492. * @param lightIndex defines the index of the light for the effect
  19493. */
  19494. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19495. }
  19496. }
  19497. declare module BABYLON {
  19498. /** @hidden */
  19499. export var vrMultiviewToSingleviewPixelShader: {
  19500. name: string;
  19501. shader: string;
  19502. };
  19503. }
  19504. declare module BABYLON {
  19505. /**
  19506. * Renders to multiple views with a single draw call
  19507. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19508. */
  19509. export class MultiviewRenderTarget extends RenderTargetTexture {
  19510. /**
  19511. * Creates a multiview render target
  19512. * @param scene scene used with the render target
  19513. * @param size the size of the render target (used for each view)
  19514. */
  19515. constructor(scene: Scene, size?: number | {
  19516. width: number;
  19517. height: number;
  19518. } | {
  19519. ratio: number;
  19520. });
  19521. /**
  19522. * @hidden
  19523. * @param faceIndex the face index, if its a cube texture
  19524. */
  19525. _bindFrameBuffer(faceIndex?: number): void;
  19526. /**
  19527. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19528. * @returns the view count
  19529. */
  19530. getViewCount(): number;
  19531. }
  19532. }
  19533. declare module BABYLON {
  19534. interface Engine {
  19535. /**
  19536. * Creates a new multiview render target
  19537. * @param width defines the width of the texture
  19538. * @param height defines the height of the texture
  19539. * @returns the created multiview texture
  19540. */
  19541. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19542. /**
  19543. * Binds a multiview framebuffer to be drawn to
  19544. * @param multiviewTexture texture to bind
  19545. */
  19546. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19547. }
  19548. interface Camera {
  19549. /**
  19550. * @hidden
  19551. * 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)
  19552. */
  19553. _useMultiviewToSingleView: boolean;
  19554. /**
  19555. * @hidden
  19556. * 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)
  19557. */
  19558. _multiviewTexture: Nullable<RenderTargetTexture>;
  19559. /**
  19560. * @hidden
  19561. * ensures the multiview texture of the camera exists and has the specified width/height
  19562. * @param width height to set on the multiview texture
  19563. * @param height width to set on the multiview texture
  19564. */
  19565. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19566. }
  19567. interface Scene {
  19568. /** @hidden */
  19569. _transformMatrixR: Matrix;
  19570. /** @hidden */
  19571. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19572. /** @hidden */
  19573. _createMultiviewUbo(): void;
  19574. /** @hidden */
  19575. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19576. /** @hidden */
  19577. _renderMultiviewToSingleView(camera: Camera): void;
  19578. }
  19579. }
  19580. declare module BABYLON {
  19581. /**
  19582. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19583. * This will not be used for webXR as it supports displaying texture arrays directly
  19584. */
  19585. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19586. /**
  19587. * Initializes a VRMultiviewToSingleview
  19588. * @param name name of the post process
  19589. * @param camera camera to be applied to
  19590. * @param scaleFactor scaling factor to the size of the output texture
  19591. */
  19592. constructor(name: string, camera: Camera, scaleFactor: number);
  19593. }
  19594. }
  19595. declare module BABYLON {
  19596. /**
  19597. * Interface used to define additional presentation attributes
  19598. */
  19599. export interface IVRPresentationAttributes {
  19600. /**
  19601. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19602. */
  19603. highRefreshRate: boolean;
  19604. /**
  19605. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19606. */
  19607. foveationLevel: number;
  19608. }
  19609. interface Engine {
  19610. /** @hidden */
  19611. _vrDisplay: any;
  19612. /** @hidden */
  19613. _vrSupported: boolean;
  19614. /** @hidden */
  19615. _oldSize: Size;
  19616. /** @hidden */
  19617. _oldHardwareScaleFactor: number;
  19618. /** @hidden */
  19619. _vrExclusivePointerMode: boolean;
  19620. /** @hidden */
  19621. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19622. /** @hidden */
  19623. _onVRDisplayPointerRestricted: () => void;
  19624. /** @hidden */
  19625. _onVRDisplayPointerUnrestricted: () => void;
  19626. /** @hidden */
  19627. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19628. /** @hidden */
  19629. _onVrDisplayDisconnect: Nullable<() => void>;
  19630. /** @hidden */
  19631. _onVrDisplayPresentChange: Nullable<() => void>;
  19632. /**
  19633. * Observable signaled when VR display mode changes
  19634. */
  19635. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19636. /**
  19637. * Observable signaled when VR request present is complete
  19638. */
  19639. onVRRequestPresentComplete: Observable<boolean>;
  19640. /**
  19641. * Observable signaled when VR request present starts
  19642. */
  19643. onVRRequestPresentStart: Observable<Engine>;
  19644. /**
  19645. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19646. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19647. */
  19648. isInVRExclusivePointerMode: boolean;
  19649. /**
  19650. * Gets a boolean indicating if a webVR device was detected
  19651. * @returns true if a webVR device was detected
  19652. */
  19653. isVRDevicePresent(): boolean;
  19654. /**
  19655. * Gets the current webVR device
  19656. * @returns the current webVR device (or null)
  19657. */
  19658. getVRDevice(): any;
  19659. /**
  19660. * Initializes a webVR display and starts listening to display change events
  19661. * The onVRDisplayChangedObservable will be notified upon these changes
  19662. * @returns A promise containing a VRDisplay and if vr is supported
  19663. */
  19664. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19665. /** @hidden */
  19666. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19667. /**
  19668. * Gets or sets the presentation attributes used to configure VR rendering
  19669. */
  19670. vrPresentationAttributes?: IVRPresentationAttributes;
  19671. /**
  19672. * Call this function to switch to webVR mode
  19673. * Will do nothing if webVR is not supported or if there is no webVR device
  19674. * @param options the webvr options provided to the camera. mainly used for multiview
  19675. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19676. */
  19677. enableVR(options: WebVROptions): void;
  19678. /** @hidden */
  19679. _onVRFullScreenTriggered(): void;
  19680. }
  19681. }
  19682. declare module BABYLON {
  19683. /**
  19684. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19685. * IMPORTANT!! The data is right-hand data.
  19686. * @export
  19687. * @interface DevicePose
  19688. */
  19689. export interface DevicePose {
  19690. /**
  19691. * The position of the device, values in array are [x,y,z].
  19692. */
  19693. readonly position: Nullable<Float32Array>;
  19694. /**
  19695. * The linearVelocity of the device, values in array are [x,y,z].
  19696. */
  19697. readonly linearVelocity: Nullable<Float32Array>;
  19698. /**
  19699. * The linearAcceleration of the device, values in array are [x,y,z].
  19700. */
  19701. readonly linearAcceleration: Nullable<Float32Array>;
  19702. /**
  19703. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19704. */
  19705. readonly orientation: Nullable<Float32Array>;
  19706. /**
  19707. * The angularVelocity of the device, values in array are [x,y,z].
  19708. */
  19709. readonly angularVelocity: Nullable<Float32Array>;
  19710. /**
  19711. * The angularAcceleration of the device, values in array are [x,y,z].
  19712. */
  19713. readonly angularAcceleration: Nullable<Float32Array>;
  19714. }
  19715. /**
  19716. * Interface representing a pose controlled object in Babylon.
  19717. * A pose controlled object has both regular pose values as well as pose values
  19718. * from an external device such as a VR head mounted display
  19719. */
  19720. export interface PoseControlled {
  19721. /**
  19722. * The position of the object in babylon space.
  19723. */
  19724. position: Vector3;
  19725. /**
  19726. * The rotation quaternion of the object in babylon space.
  19727. */
  19728. rotationQuaternion: Quaternion;
  19729. /**
  19730. * The position of the device in babylon space.
  19731. */
  19732. devicePosition?: Vector3;
  19733. /**
  19734. * The rotation quaternion of the device in babylon space.
  19735. */
  19736. deviceRotationQuaternion: Quaternion;
  19737. /**
  19738. * The raw pose coming from the device.
  19739. */
  19740. rawPose: Nullable<DevicePose>;
  19741. /**
  19742. * The scale of the device to be used when translating from device space to babylon space.
  19743. */
  19744. deviceScaleFactor: number;
  19745. /**
  19746. * Updates the poseControlled values based on the input device pose.
  19747. * @param poseData the pose data to update the object with
  19748. */
  19749. updateFromDevice(poseData: DevicePose): void;
  19750. }
  19751. /**
  19752. * Set of options to customize the webVRCamera
  19753. */
  19754. export interface WebVROptions {
  19755. /**
  19756. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19757. */
  19758. trackPosition?: boolean;
  19759. /**
  19760. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19761. */
  19762. positionScale?: number;
  19763. /**
  19764. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19765. */
  19766. displayName?: string;
  19767. /**
  19768. * Should the native controller meshes be initialized. (default: true)
  19769. */
  19770. controllerMeshes?: boolean;
  19771. /**
  19772. * Creating a default HemiLight only on controllers. (default: true)
  19773. */
  19774. defaultLightingOnControllers?: boolean;
  19775. /**
  19776. * If you don't want to use the default VR button of the helper. (default: false)
  19777. */
  19778. useCustomVRButton?: boolean;
  19779. /**
  19780. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19781. */
  19782. customVRButton?: HTMLButtonElement;
  19783. /**
  19784. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19785. */
  19786. rayLength?: number;
  19787. /**
  19788. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19789. */
  19790. defaultHeight?: number;
  19791. /**
  19792. * If multiview should be used if availible (default: false)
  19793. */
  19794. useMultiview?: boolean;
  19795. }
  19796. /**
  19797. * This represents a WebVR camera.
  19798. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19799. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19800. */
  19801. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19802. private webVROptions;
  19803. /**
  19804. * @hidden
  19805. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19806. */
  19807. _vrDevice: any;
  19808. /**
  19809. * The rawPose of the vrDevice.
  19810. */
  19811. rawPose: Nullable<DevicePose>;
  19812. private _onVREnabled;
  19813. private _specsVersion;
  19814. private _attached;
  19815. private _frameData;
  19816. protected _descendants: Array<Node>;
  19817. private _deviceRoomPosition;
  19818. /** @hidden */
  19819. _deviceRoomRotationQuaternion: Quaternion;
  19820. private _standingMatrix;
  19821. /**
  19822. * Represents device position in babylon space.
  19823. */
  19824. devicePosition: Vector3;
  19825. /**
  19826. * Represents device rotation in babylon space.
  19827. */
  19828. deviceRotationQuaternion: Quaternion;
  19829. /**
  19830. * The scale of the device to be used when translating from device space to babylon space.
  19831. */
  19832. deviceScaleFactor: number;
  19833. private _deviceToWorld;
  19834. private _worldToDevice;
  19835. /**
  19836. * References to the webVR controllers for the vrDevice.
  19837. */
  19838. controllers: Array<WebVRController>;
  19839. /**
  19840. * Emits an event when a controller is attached.
  19841. */
  19842. onControllersAttachedObservable: Observable<WebVRController[]>;
  19843. /**
  19844. * Emits an event when a controller's mesh has been loaded;
  19845. */
  19846. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19847. /**
  19848. * Emits an event when the HMD's pose has been updated.
  19849. */
  19850. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19851. private _poseSet;
  19852. /**
  19853. * If the rig cameras be used as parent instead of this camera.
  19854. */
  19855. rigParenting: boolean;
  19856. private _lightOnControllers;
  19857. private _defaultHeight?;
  19858. /**
  19859. * Instantiates a WebVRFreeCamera.
  19860. * @param name The name of the WebVRFreeCamera
  19861. * @param position The starting anchor position for the camera
  19862. * @param scene The scene the camera belongs to
  19863. * @param webVROptions a set of customizable options for the webVRCamera
  19864. */
  19865. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19866. /**
  19867. * Gets the device distance from the ground in meters.
  19868. * @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.
  19869. */
  19870. deviceDistanceToRoomGround(): number;
  19871. /**
  19872. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19873. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19874. */
  19875. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19876. /**
  19877. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19878. * @returns A promise with a boolean set to if the standing matrix is supported.
  19879. */
  19880. useStandingMatrixAsync(): Promise<boolean>;
  19881. /**
  19882. * Disposes the camera
  19883. */
  19884. dispose(): void;
  19885. /**
  19886. * Gets a vrController by name.
  19887. * @param name The name of the controller to retreive
  19888. * @returns the controller matching the name specified or null if not found
  19889. */
  19890. getControllerByName(name: string): Nullable<WebVRController>;
  19891. private _leftController;
  19892. /**
  19893. * The controller corresponding to the users left hand.
  19894. */
  19895. get leftController(): Nullable<WebVRController>;
  19896. private _rightController;
  19897. /**
  19898. * The controller corresponding to the users right hand.
  19899. */
  19900. get rightController(): Nullable<WebVRController>;
  19901. /**
  19902. * Casts a ray forward from the vrCamera's gaze.
  19903. * @param length Length of the ray (default: 100)
  19904. * @returns the ray corresponding to the gaze
  19905. */
  19906. getForwardRay(length?: number): Ray;
  19907. /**
  19908. * @hidden
  19909. * Updates the camera based on device's frame data
  19910. */
  19911. _checkInputs(): void;
  19912. /**
  19913. * Updates the poseControlled values based on the input device pose.
  19914. * @param poseData Pose coming from the device
  19915. */
  19916. updateFromDevice(poseData: DevicePose): void;
  19917. private _htmlElementAttached;
  19918. private _detachIfAttached;
  19919. /**
  19920. * WebVR's attach control will start broadcasting frames to the device.
  19921. * Note that in certain browsers (chrome for example) this function must be called
  19922. * within a user-interaction callback. Example:
  19923. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19924. *
  19925. * @param element html element to attach the vrDevice to
  19926. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19927. */
  19928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19929. /**
  19930. * Detaches the camera from the html element and disables VR
  19931. *
  19932. * @param element html element to detach from
  19933. */
  19934. detachControl(element: HTMLElement): void;
  19935. /**
  19936. * @returns the name of this class
  19937. */
  19938. getClassName(): string;
  19939. /**
  19940. * Calls resetPose on the vrDisplay
  19941. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19942. */
  19943. resetToCurrentRotation(): void;
  19944. /**
  19945. * @hidden
  19946. * Updates the rig cameras (left and right eye)
  19947. */
  19948. _updateRigCameras(): void;
  19949. private _workingVector;
  19950. private _oneVector;
  19951. private _workingMatrix;
  19952. private updateCacheCalled;
  19953. private _correctPositionIfNotTrackPosition;
  19954. /**
  19955. * @hidden
  19956. * Updates the cached values of the camera
  19957. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19958. */
  19959. _updateCache(ignoreParentClass?: boolean): void;
  19960. /**
  19961. * @hidden
  19962. * Get current device position in babylon world
  19963. */
  19964. _computeDevicePosition(): void;
  19965. /**
  19966. * Updates the current device position and rotation in the babylon world
  19967. */
  19968. update(): void;
  19969. /**
  19970. * @hidden
  19971. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19972. * @returns an identity matrix
  19973. */
  19974. _getViewMatrix(): Matrix;
  19975. private _tmpMatrix;
  19976. /**
  19977. * This function is called by the two RIG cameras.
  19978. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19979. * @hidden
  19980. */
  19981. _getWebVRViewMatrix(): Matrix;
  19982. /** @hidden */
  19983. _getWebVRProjectionMatrix(): Matrix;
  19984. private _onGamepadConnectedObserver;
  19985. private _onGamepadDisconnectedObserver;
  19986. private _updateCacheWhenTrackingDisabledObserver;
  19987. /**
  19988. * Initializes the controllers and their meshes
  19989. */
  19990. initControllers(): void;
  19991. }
  19992. }
  19993. declare module BABYLON {
  19994. /**
  19995. * "Static Class" containing the most commonly used helper while dealing with material for
  19996. * rendering purpose.
  19997. *
  19998. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19999. *
  20000. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20001. */
  20002. export class MaterialHelper {
  20003. /**
  20004. * Bind the current view position to an effect.
  20005. * @param effect The effect to be bound
  20006. * @param scene The scene the eyes position is used from
  20007. * @param variableName name of the shader variable that will hold the eye position
  20008. */
  20009. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20010. /**
  20011. * Helps preparing the defines values about the UVs in used in the effect.
  20012. * UVs are shared as much as we can accross channels in the shaders.
  20013. * @param texture The texture we are preparing the UVs for
  20014. * @param defines The defines to update
  20015. * @param key The channel key "diffuse", "specular"... used in the shader
  20016. */
  20017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20018. /**
  20019. * Binds a texture matrix value to its corrsponding uniform
  20020. * @param texture The texture to bind the matrix for
  20021. * @param uniformBuffer The uniform buffer receivin the data
  20022. * @param key The channel key "diffuse", "specular"... used in the shader
  20023. */
  20024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20025. /**
  20026. * Gets the current status of the fog (should it be enabled?)
  20027. * @param mesh defines the mesh to evaluate for fog support
  20028. * @param scene defines the hosting scene
  20029. * @returns true if fog must be enabled
  20030. */
  20031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20032. /**
  20033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20034. * @param mesh defines the current mesh
  20035. * @param scene defines the current scene
  20036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20037. * @param pointsCloud defines if point cloud rendering has to be turned on
  20038. * @param fogEnabled defines if fog has to be turned on
  20039. * @param alphaTest defines if alpha testing has to be turned on
  20040. * @param defines defines the current list of defines
  20041. */
  20042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20043. /**
  20044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20045. * @param scene defines the current scene
  20046. * @param engine defines the current engine
  20047. * @param defines specifies the list of active defines
  20048. * @param useInstances defines if instances have to be turned on
  20049. * @param useClipPlane defines if clip plane have to be turned on
  20050. * @param useInstances defines if instances have to be turned on
  20051. * @param useThinInstances defines if thin instances have to be turned on
  20052. */
  20053. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20054. /**
  20055. * Prepares the defines for bones
  20056. * @param mesh The mesh containing the geometry data we will draw
  20057. * @param defines The defines to update
  20058. */
  20059. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20060. /**
  20061. * Prepares the defines for morph targets
  20062. * @param mesh The mesh containing the geometry data we will draw
  20063. * @param defines The defines to update
  20064. */
  20065. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20066. /**
  20067. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20068. * @param mesh The mesh containing the geometry data we will draw
  20069. * @param defines The defines to update
  20070. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20071. * @param useBones Precise whether bones should be used or not (override mesh info)
  20072. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20073. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20074. * @returns false if defines are considered not dirty and have not been checked
  20075. */
  20076. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20077. /**
  20078. * Prepares the defines related to multiview
  20079. * @param scene The scene we are intending to draw
  20080. * @param defines The defines to update
  20081. */
  20082. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20083. /**
  20084. * Prepares the defines related to the light information passed in parameter
  20085. * @param scene The scene we are intending to draw
  20086. * @param mesh The mesh the effect is compiling for
  20087. * @param light The light the effect is compiling for
  20088. * @param lightIndex The index of the light
  20089. * @param defines The defines to update
  20090. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20091. * @param state Defines the current state regarding what is needed (normals, etc...)
  20092. */
  20093. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20094. needNormals: boolean;
  20095. needRebuild: boolean;
  20096. shadowEnabled: boolean;
  20097. specularEnabled: boolean;
  20098. lightmapMode: boolean;
  20099. }): void;
  20100. /**
  20101. * Prepares the defines related to the light information passed in parameter
  20102. * @param scene The scene we are intending to draw
  20103. * @param mesh The mesh the effect is compiling for
  20104. * @param defines The defines to update
  20105. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20106. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20107. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20108. * @returns true if normals will be required for the rest of the effect
  20109. */
  20110. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20111. /**
  20112. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20113. * @param lightIndex defines the light index
  20114. * @param uniformsList The uniform list
  20115. * @param samplersList The sampler list
  20116. * @param projectedLightTexture defines if projected texture must be used
  20117. * @param uniformBuffersList defines an optional list of uniform buffers
  20118. */
  20119. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20120. /**
  20121. * Prepares the uniforms and samplers list to be used in the effect
  20122. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20123. * @param samplersList The sampler list
  20124. * @param defines The defines helping in the list generation
  20125. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20126. */
  20127. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20128. /**
  20129. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20130. * @param defines The defines to update while falling back
  20131. * @param fallbacks The authorized effect fallbacks
  20132. * @param maxSimultaneousLights The maximum number of lights allowed
  20133. * @param rank the current rank of the Effect
  20134. * @returns The newly affected rank
  20135. */
  20136. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20137. private static _TmpMorphInfluencers;
  20138. /**
  20139. * Prepares the list of attributes required for morph targets according to the effect defines.
  20140. * @param attribs The current list of supported attribs
  20141. * @param mesh The mesh to prepare the morph targets attributes for
  20142. * @param influencers The number of influencers
  20143. */
  20144. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20145. /**
  20146. * Prepares the list of attributes required for morph targets according to the effect defines.
  20147. * @param attribs The current list of supported attribs
  20148. * @param mesh The mesh to prepare the morph targets attributes for
  20149. * @param defines The current Defines of the effect
  20150. */
  20151. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20152. /**
  20153. * Prepares the list of attributes required for bones according to the effect defines.
  20154. * @param attribs The current list of supported attribs
  20155. * @param mesh The mesh to prepare the bones attributes for
  20156. * @param defines The current Defines of the effect
  20157. * @param fallbacks The current efffect fallback strategy
  20158. */
  20159. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20160. /**
  20161. * Check and prepare the list of attributes required for instances according to the effect defines.
  20162. * @param attribs The current list of supported attribs
  20163. * @param defines The current MaterialDefines of the effect
  20164. */
  20165. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20166. /**
  20167. * Add the list of attributes required for instances to the attribs array.
  20168. * @param attribs The current list of supported attribs
  20169. */
  20170. static PushAttributesForInstances(attribs: string[]): void;
  20171. /**
  20172. * Binds the light information to the effect.
  20173. * @param light The light containing the generator
  20174. * @param effect The effect we are binding the data to
  20175. * @param lightIndex The light index in the effect used to render
  20176. */
  20177. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20178. /**
  20179. * Binds the lights information from the scene to the effect for the given mesh.
  20180. * @param light Light to bind
  20181. * @param lightIndex Light index
  20182. * @param scene The scene where the light belongs to
  20183. * @param effect The effect we are binding the data to
  20184. * @param useSpecular Defines if specular is supported
  20185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20186. */
  20187. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20188. /**
  20189. * Binds the lights information from the scene to the effect for the given mesh.
  20190. * @param scene The scene the lights belongs to
  20191. * @param mesh The mesh we are binding the information to render
  20192. * @param effect The effect we are binding the data to
  20193. * @param defines The generated defines for the effect
  20194. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20196. */
  20197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20198. private static _tempFogColor;
  20199. /**
  20200. * Binds the fog information from the scene to the effect for the given mesh.
  20201. * @param scene The scene the lights belongs to
  20202. * @param mesh The mesh we are binding the information to render
  20203. * @param effect The effect we are binding the data to
  20204. * @param linearSpace Defines if the fog effect is applied in linear space
  20205. */
  20206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20207. /**
  20208. * Binds the bones information from the mesh to the effect.
  20209. * @param mesh The mesh we are binding the information to render
  20210. * @param effect The effect we are binding the data to
  20211. */
  20212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20213. /**
  20214. * Binds the morph targets information from the mesh to the effect.
  20215. * @param abstractMesh The mesh we are binding the information to render
  20216. * @param effect The effect we are binding the data to
  20217. */
  20218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20219. /**
  20220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20221. * @param defines The generated defines used in the effect
  20222. * @param effect The effect we are binding the data to
  20223. * @param scene The scene we are willing to render with logarithmic scale for
  20224. */
  20225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20226. /**
  20227. * Binds the clip plane information from the scene to the effect.
  20228. * @param scene The scene the clip plane information are extracted from
  20229. * @param effect The effect we are binding the data to
  20230. */
  20231. static BindClipPlane(effect: Effect, scene: Scene): void;
  20232. }
  20233. }
  20234. declare module BABYLON {
  20235. /**
  20236. * Block used to expose an input value
  20237. */
  20238. export class InputBlock extends NodeMaterialBlock {
  20239. private _mode;
  20240. private _associatedVariableName;
  20241. private _storedValue;
  20242. private _valueCallback;
  20243. private _type;
  20244. private _animationType;
  20245. /** Gets or set a value used to limit the range of float values */
  20246. min: number;
  20247. /** Gets or set a value used to limit the range of float values */
  20248. max: number;
  20249. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20250. isBoolean: boolean;
  20251. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20252. matrixMode: number;
  20253. /** @hidden */
  20254. _systemValue: Nullable<NodeMaterialSystemValues>;
  20255. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20256. visibleInInspector: boolean;
  20257. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20258. isConstant: boolean;
  20259. /** Gets or sets the group to use to display this block in the Inspector */
  20260. groupInInspector: string;
  20261. /** Gets an observable raised when the value is changed */
  20262. onValueChangedObservable: Observable<InputBlock>;
  20263. /**
  20264. * Gets or sets the connection point type (default is float)
  20265. */
  20266. get type(): NodeMaterialBlockConnectionPointTypes;
  20267. /**
  20268. * Creates a new InputBlock
  20269. * @param name defines the block name
  20270. * @param target defines the target of that block (Vertex by default)
  20271. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20272. */
  20273. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20274. /**
  20275. * Gets the output component
  20276. */
  20277. get output(): NodeMaterialConnectionPoint;
  20278. /**
  20279. * Set the source of this connection point to a vertex attribute
  20280. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20281. * @returns the current connection point
  20282. */
  20283. setAsAttribute(attributeName?: string): InputBlock;
  20284. /**
  20285. * Set the source of this connection point to a system value
  20286. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20287. * @returns the current connection point
  20288. */
  20289. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20290. /**
  20291. * Gets or sets the value of that point.
  20292. * Please note that this value will be ignored if valueCallback is defined
  20293. */
  20294. get value(): any;
  20295. set value(value: any);
  20296. /**
  20297. * Gets or sets a callback used to get the value of that point.
  20298. * Please note that setting this value will force the connection point to ignore the value property
  20299. */
  20300. get valueCallback(): () => any;
  20301. set valueCallback(value: () => any);
  20302. /**
  20303. * Gets or sets the associated variable name in the shader
  20304. */
  20305. get associatedVariableName(): string;
  20306. set associatedVariableName(value: string);
  20307. /** Gets or sets the type of animation applied to the input */
  20308. get animationType(): AnimatedInputBlockTypes;
  20309. set animationType(value: AnimatedInputBlockTypes);
  20310. /**
  20311. * Gets a boolean indicating that this connection point not defined yet
  20312. */
  20313. get isUndefined(): boolean;
  20314. /**
  20315. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20316. * In this case the connection point name must be the name of the uniform to use.
  20317. * Can only be set on inputs
  20318. */
  20319. get isUniform(): boolean;
  20320. set isUniform(value: boolean);
  20321. /**
  20322. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20323. * In this case the connection point name must be the name of the attribute to use
  20324. * Can only be set on inputs
  20325. */
  20326. get isAttribute(): boolean;
  20327. set isAttribute(value: boolean);
  20328. /**
  20329. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20330. * Can only be set on exit points
  20331. */
  20332. get isVarying(): boolean;
  20333. set isVarying(value: boolean);
  20334. /**
  20335. * Gets a boolean indicating that the current connection point is a system value
  20336. */
  20337. get isSystemValue(): boolean;
  20338. /**
  20339. * Gets or sets the current well known value or null if not defined as a system value
  20340. */
  20341. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20342. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20343. /**
  20344. * Gets the current class name
  20345. * @returns the class name
  20346. */
  20347. getClassName(): string;
  20348. /**
  20349. * Animate the input if animationType !== None
  20350. * @param scene defines the rendering scene
  20351. */
  20352. animate(scene: Scene): void;
  20353. private _emitDefine;
  20354. initialize(state: NodeMaterialBuildState): void;
  20355. /**
  20356. * Set the input block to its default value (based on its type)
  20357. */
  20358. setDefaultValue(): void;
  20359. private _emitConstant;
  20360. /** @hidden */
  20361. get _noContextSwitch(): boolean;
  20362. private _emit;
  20363. /** @hidden */
  20364. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20365. /** @hidden */
  20366. _transmit(effect: Effect, scene: Scene): void;
  20367. protected _buildBlock(state: NodeMaterialBuildState): void;
  20368. protected _dumpPropertiesCode(): string;
  20369. dispose(): void;
  20370. serialize(): any;
  20371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20372. }
  20373. }
  20374. declare module BABYLON {
  20375. /**
  20376. * Enum used to define the compatibility state between two connection points
  20377. */
  20378. export enum NodeMaterialConnectionPointCompatibilityStates {
  20379. /** Points are compatibles */
  20380. Compatible = 0,
  20381. /** Points are incompatible because of their types */
  20382. TypeIncompatible = 1,
  20383. /** Points are incompatible because of their targets (vertex vs fragment) */
  20384. TargetIncompatible = 2
  20385. }
  20386. /**
  20387. * Defines the direction of a connection point
  20388. */
  20389. export enum NodeMaterialConnectionPointDirection {
  20390. /** Input */
  20391. Input = 0,
  20392. /** Output */
  20393. Output = 1
  20394. }
  20395. /**
  20396. * Defines a connection point for a block
  20397. */
  20398. export class NodeMaterialConnectionPoint {
  20399. /** @hidden */
  20400. _ownerBlock: NodeMaterialBlock;
  20401. /** @hidden */
  20402. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20403. private _endpoints;
  20404. private _associatedVariableName;
  20405. private _direction;
  20406. /** @hidden */
  20407. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20408. /** @hidden */
  20409. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20410. private _type;
  20411. /** @hidden */
  20412. _enforceAssociatedVariableName: boolean;
  20413. /** Gets the direction of the point */
  20414. get direction(): NodeMaterialConnectionPointDirection;
  20415. /** Indicates that this connection point needs dual validation before being connected to another point */
  20416. needDualDirectionValidation: boolean;
  20417. /**
  20418. * Gets or sets the additional types supported by this connection point
  20419. */
  20420. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20421. /**
  20422. * Gets or sets the additional types excluded by this connection point
  20423. */
  20424. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20425. /**
  20426. * Observable triggered when this point is connected
  20427. */
  20428. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20429. /**
  20430. * Gets or sets the associated variable name in the shader
  20431. */
  20432. get associatedVariableName(): string;
  20433. set associatedVariableName(value: string);
  20434. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20435. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20436. /**
  20437. * Gets or sets the connection point type (default is float)
  20438. */
  20439. get type(): NodeMaterialBlockConnectionPointTypes;
  20440. set type(value: NodeMaterialBlockConnectionPointTypes);
  20441. /**
  20442. * Gets or sets the connection point name
  20443. */
  20444. name: string;
  20445. /**
  20446. * Gets or sets the connection point name
  20447. */
  20448. displayName: string;
  20449. /**
  20450. * Gets or sets a boolean indicating that this connection point can be omitted
  20451. */
  20452. isOptional: boolean;
  20453. /**
  20454. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20455. */
  20456. isExposedOnFrame: boolean;
  20457. /**
  20458. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20459. */
  20460. define: string;
  20461. /** @hidden */
  20462. _prioritizeVertex: boolean;
  20463. private _target;
  20464. /** Gets or sets the target of that connection point */
  20465. get target(): NodeMaterialBlockTargets;
  20466. set target(value: NodeMaterialBlockTargets);
  20467. /**
  20468. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20469. */
  20470. get isConnected(): boolean;
  20471. /**
  20472. * Gets a boolean indicating that the current point is connected to an input block
  20473. */
  20474. get isConnectedToInputBlock(): boolean;
  20475. /**
  20476. * Gets a the connected input block (if any)
  20477. */
  20478. get connectInputBlock(): Nullable<InputBlock>;
  20479. /** Get the other side of the connection (if any) */
  20480. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20481. /** Get the block that owns this connection point */
  20482. get ownerBlock(): NodeMaterialBlock;
  20483. /** Get the block connected on the other side of this connection (if any) */
  20484. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20485. /** Get the block connected on the endpoints of this connection (if any) */
  20486. get connectedBlocks(): Array<NodeMaterialBlock>;
  20487. /** Gets the list of connected endpoints */
  20488. get endpoints(): NodeMaterialConnectionPoint[];
  20489. /** Gets a boolean indicating if that output point is connected to at least one input */
  20490. get hasEndpoints(): boolean;
  20491. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20492. get isConnectedInVertexShader(): boolean;
  20493. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20494. get isConnectedInFragmentShader(): boolean;
  20495. /**
  20496. * Creates a block suitable to be used as an input for this input point.
  20497. * If null is returned, a block based on the point type will be created.
  20498. * @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
  20499. */
  20500. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20501. /**
  20502. * Creates a new connection point
  20503. * @param name defines the connection point name
  20504. * @param ownerBlock defines the block hosting this connection point
  20505. * @param direction defines the direction of the connection point
  20506. */
  20507. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20508. /**
  20509. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20510. * @returns the class name
  20511. */
  20512. getClassName(): string;
  20513. /**
  20514. * Gets a boolean indicating if the current point can be connected to another point
  20515. * @param connectionPoint defines the other connection point
  20516. * @returns a boolean
  20517. */
  20518. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20519. /**
  20520. * Gets a number indicating if the current point can be connected to another point
  20521. * @param connectionPoint defines the other connection point
  20522. * @returns a number defining the compatibility state
  20523. */
  20524. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20525. /**
  20526. * Connect this point to another connection point
  20527. * @param connectionPoint defines the other connection point
  20528. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20529. * @returns the current connection point
  20530. */
  20531. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20532. /**
  20533. * Disconnect this point from one of his endpoint
  20534. * @param endpoint defines the other connection point
  20535. * @returns the current connection point
  20536. */
  20537. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20538. /**
  20539. * Serializes this point in a JSON representation
  20540. * @param isInput defines if the connection point is an input (default is true)
  20541. * @returns the serialized point object
  20542. */
  20543. serialize(isInput?: boolean): any;
  20544. /**
  20545. * Release resources
  20546. */
  20547. dispose(): void;
  20548. }
  20549. }
  20550. declare module BABYLON {
  20551. /**
  20552. * Enum used to define the material modes
  20553. */
  20554. export enum NodeMaterialModes {
  20555. /** Regular material */
  20556. Material = 0,
  20557. /** For post process */
  20558. PostProcess = 1,
  20559. /** For particle system */
  20560. Particle = 2
  20561. }
  20562. }
  20563. declare module BABYLON {
  20564. /**
  20565. * Block used to read a texture from a sampler
  20566. */
  20567. export class TextureBlock extends NodeMaterialBlock {
  20568. private _defineName;
  20569. private _linearDefineName;
  20570. private _gammaDefineName;
  20571. private _tempTextureRead;
  20572. private _samplerName;
  20573. private _transformedUVName;
  20574. private _textureTransformName;
  20575. private _textureInfoName;
  20576. private _mainUVName;
  20577. private _mainUVDefineName;
  20578. private _fragmentOnly;
  20579. /**
  20580. * Gets or sets the texture associated with the node
  20581. */
  20582. texture: Nullable<Texture>;
  20583. /**
  20584. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20585. */
  20586. convertToGammaSpace: boolean;
  20587. /**
  20588. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20589. */
  20590. convertToLinearSpace: boolean;
  20591. /**
  20592. * Create a new TextureBlock
  20593. * @param name defines the block name
  20594. */
  20595. constructor(name: string, fragmentOnly?: boolean);
  20596. /**
  20597. * Gets the current class name
  20598. * @returns the class name
  20599. */
  20600. getClassName(): string;
  20601. /**
  20602. * Gets the uv input component
  20603. */
  20604. get uv(): NodeMaterialConnectionPoint;
  20605. /**
  20606. * Gets the rgba output component
  20607. */
  20608. get rgba(): NodeMaterialConnectionPoint;
  20609. /**
  20610. * Gets the rgb output component
  20611. */
  20612. get rgb(): NodeMaterialConnectionPoint;
  20613. /**
  20614. * Gets the r output component
  20615. */
  20616. get r(): NodeMaterialConnectionPoint;
  20617. /**
  20618. * Gets the g output component
  20619. */
  20620. get g(): NodeMaterialConnectionPoint;
  20621. /**
  20622. * Gets the b output component
  20623. */
  20624. get b(): NodeMaterialConnectionPoint;
  20625. /**
  20626. * Gets the a output component
  20627. */
  20628. get a(): NodeMaterialConnectionPoint;
  20629. get target(): NodeMaterialBlockTargets;
  20630. autoConfigure(material: NodeMaterial): void;
  20631. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20633. isReady(): boolean;
  20634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20635. private get _isMixed();
  20636. private _injectVertexCode;
  20637. private _writeTextureRead;
  20638. private _writeOutput;
  20639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20640. protected _dumpPropertiesCode(): string;
  20641. serialize(): any;
  20642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20643. }
  20644. }
  20645. declare module BABYLON {
  20646. /** @hidden */
  20647. export var reflectionFunction: {
  20648. name: string;
  20649. shader: string;
  20650. };
  20651. }
  20652. declare module BABYLON {
  20653. /**
  20654. * Base block used to read a reflection texture from a sampler
  20655. */
  20656. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20657. /** @hidden */
  20658. _define3DName: string;
  20659. /** @hidden */
  20660. _defineCubicName: string;
  20661. /** @hidden */
  20662. _defineExplicitName: string;
  20663. /** @hidden */
  20664. _defineProjectionName: string;
  20665. /** @hidden */
  20666. _defineLocalCubicName: string;
  20667. /** @hidden */
  20668. _defineSphericalName: string;
  20669. /** @hidden */
  20670. _definePlanarName: string;
  20671. /** @hidden */
  20672. _defineEquirectangularName: string;
  20673. /** @hidden */
  20674. _defineMirroredEquirectangularFixedName: string;
  20675. /** @hidden */
  20676. _defineEquirectangularFixedName: string;
  20677. /** @hidden */
  20678. _defineSkyboxName: string;
  20679. /** @hidden */
  20680. _defineOppositeZ: string;
  20681. /** @hidden */
  20682. _cubeSamplerName: string;
  20683. /** @hidden */
  20684. _2DSamplerName: string;
  20685. protected _positionUVWName: string;
  20686. protected _directionWName: string;
  20687. protected _reflectionVectorName: string;
  20688. /** @hidden */
  20689. _reflectionCoordsName: string;
  20690. /** @hidden */
  20691. _reflectionMatrixName: string;
  20692. protected _reflectionColorName: string;
  20693. /**
  20694. * Gets or sets the texture associated with the node
  20695. */
  20696. texture: Nullable<BaseTexture>;
  20697. /**
  20698. * Create a new ReflectionTextureBaseBlock
  20699. * @param name defines the block name
  20700. */
  20701. constructor(name: string);
  20702. /**
  20703. * Gets the current class name
  20704. * @returns the class name
  20705. */
  20706. getClassName(): string;
  20707. /**
  20708. * Gets the world position input component
  20709. */
  20710. abstract get position(): NodeMaterialConnectionPoint;
  20711. /**
  20712. * Gets the world position input component
  20713. */
  20714. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20715. /**
  20716. * Gets the world normal input component
  20717. */
  20718. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20719. /**
  20720. * Gets the world input component
  20721. */
  20722. abstract get world(): NodeMaterialConnectionPoint;
  20723. /**
  20724. * Gets the camera (or eye) position component
  20725. */
  20726. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20727. /**
  20728. * Gets the view input component
  20729. */
  20730. abstract get view(): NodeMaterialConnectionPoint;
  20731. protected _getTexture(): Nullable<BaseTexture>;
  20732. autoConfigure(material: NodeMaterial): void;
  20733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20734. isReady(): boolean;
  20735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20736. /**
  20737. * Gets the code to inject in the vertex shader
  20738. * @param state current state of the node material building
  20739. * @returns the shader code
  20740. */
  20741. handleVertexSide(state: NodeMaterialBuildState): string;
  20742. /**
  20743. * Handles the inits for the fragment code path
  20744. * @param state node material build state
  20745. */
  20746. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20747. /**
  20748. * Generates the reflection coords code for the fragment code path
  20749. * @param worldNormalVarName name of the world normal variable
  20750. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20751. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20752. * @returns the shader code
  20753. */
  20754. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20755. /**
  20756. * Generates the reflection color code for the fragment code path
  20757. * @param lodVarName name of the lod variable
  20758. * @param swizzleLookupTexture swizzle to use for the final color variable
  20759. * @returns the shader code
  20760. */
  20761. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20762. /**
  20763. * Generates the code corresponding to the connected output points
  20764. * @param state node material build state
  20765. * @param varName name of the variable to output
  20766. * @returns the shader code
  20767. */
  20768. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20769. protected _buildBlock(state: NodeMaterialBuildState): this;
  20770. protected _dumpPropertiesCode(): string;
  20771. serialize(): any;
  20772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20773. }
  20774. }
  20775. declare module BABYLON {
  20776. /**
  20777. * Defines a connection point to be used for points with a custom object type
  20778. */
  20779. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20780. private _blockType;
  20781. private _blockName;
  20782. private _nameForCheking?;
  20783. /**
  20784. * Creates a new connection point
  20785. * @param name defines the connection point name
  20786. * @param ownerBlock defines the block hosting this connection point
  20787. * @param direction defines the direction of the connection point
  20788. */
  20789. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20790. /**
  20791. * Gets a number indicating if the current point can be connected to another point
  20792. * @param connectionPoint defines the other connection point
  20793. * @returns a number defining the compatibility state
  20794. */
  20795. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20796. /**
  20797. * Creates a block suitable to be used as an input for this input point.
  20798. * If null is returned, a block based on the point type will be created.
  20799. * @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
  20800. */
  20801. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20802. }
  20803. }
  20804. declare module BABYLON {
  20805. /**
  20806. * Enum defining the type of properties that can be edited in the property pages in the NME
  20807. */
  20808. export enum PropertyTypeForEdition {
  20809. /** property is a boolean */
  20810. Boolean = 0,
  20811. /** property is a float */
  20812. Float = 1,
  20813. /** property is a Vector2 */
  20814. Vector2 = 2,
  20815. /** property is a list of values */
  20816. List = 3
  20817. }
  20818. /**
  20819. * Interface that defines an option in a variable of type list
  20820. */
  20821. export interface IEditablePropertyListOption {
  20822. /** label of the option */
  20823. "label": string;
  20824. /** value of the option */
  20825. "value": number;
  20826. }
  20827. /**
  20828. * Interface that defines the options available for an editable property
  20829. */
  20830. export interface IEditablePropertyOption {
  20831. /** min value */
  20832. "min"?: number;
  20833. /** max value */
  20834. "max"?: number;
  20835. /** notifiers: indicates which actions to take when the property is changed */
  20836. "notifiers"?: {
  20837. /** the material should be rebuilt */
  20838. "rebuild"?: boolean;
  20839. /** the preview should be updated */
  20840. "update"?: boolean;
  20841. };
  20842. /** list of the options for a variable of type list */
  20843. "options"?: IEditablePropertyListOption[];
  20844. }
  20845. /**
  20846. * Interface that describes an editable property
  20847. */
  20848. export interface IPropertyDescriptionForEdition {
  20849. /** name of the property */
  20850. "propertyName": string;
  20851. /** display name of the property */
  20852. "displayName": string;
  20853. /** type of the property */
  20854. "type": PropertyTypeForEdition;
  20855. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20856. "groupName": string;
  20857. /** options for the property */
  20858. "options": IEditablePropertyOption;
  20859. }
  20860. /**
  20861. * Decorator that flags a property in a node material block as being editable
  20862. */
  20863. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20864. }
  20865. declare module BABYLON {
  20866. /**
  20867. * Block used to implement the refraction part of the sub surface module of the PBR material
  20868. */
  20869. export class RefractionBlock extends NodeMaterialBlock {
  20870. /** @hidden */
  20871. _define3DName: string;
  20872. /** @hidden */
  20873. _refractionMatrixName: string;
  20874. /** @hidden */
  20875. _defineLODRefractionAlpha: string;
  20876. /** @hidden */
  20877. _defineLinearSpecularRefraction: string;
  20878. /** @hidden */
  20879. _defineOppositeZ: string;
  20880. /** @hidden */
  20881. _cubeSamplerName: string;
  20882. /** @hidden */
  20883. _2DSamplerName: string;
  20884. /** @hidden */
  20885. _vRefractionMicrosurfaceInfosName: string;
  20886. /** @hidden */
  20887. _vRefractionInfosName: string;
  20888. private _scene;
  20889. /**
  20890. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20891. * Materials half opaque for instance using refraction could benefit from this control.
  20892. */
  20893. linkRefractionWithTransparency: boolean;
  20894. /**
  20895. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20896. */
  20897. invertRefractionY: boolean;
  20898. /**
  20899. * Gets or sets the texture associated with the node
  20900. */
  20901. texture: Nullable<BaseTexture>;
  20902. /**
  20903. * Create a new RefractionBlock
  20904. * @param name defines the block name
  20905. */
  20906. constructor(name: string);
  20907. /**
  20908. * Gets the current class name
  20909. * @returns the class name
  20910. */
  20911. getClassName(): string;
  20912. /**
  20913. * Gets the intensity input component
  20914. */
  20915. get intensity(): NodeMaterialConnectionPoint;
  20916. /**
  20917. * Gets the index of refraction input component
  20918. */
  20919. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20920. /**
  20921. * Gets the tint at distance input component
  20922. */
  20923. get tintAtDistance(): NodeMaterialConnectionPoint;
  20924. /**
  20925. * Gets the view input component
  20926. */
  20927. get view(): NodeMaterialConnectionPoint;
  20928. /**
  20929. * Gets the refraction object output component
  20930. */
  20931. get refraction(): NodeMaterialConnectionPoint;
  20932. /**
  20933. * Returns true if the block has a texture
  20934. */
  20935. get hasTexture(): boolean;
  20936. protected _getTexture(): Nullable<BaseTexture>;
  20937. autoConfigure(material: NodeMaterial): void;
  20938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20939. isReady(): boolean;
  20940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20941. /**
  20942. * Gets the main code of the block (fragment side)
  20943. * @param state current state of the node material building
  20944. * @returns the shader code
  20945. */
  20946. getCode(state: NodeMaterialBuildState): string;
  20947. protected _buildBlock(state: NodeMaterialBuildState): this;
  20948. protected _dumpPropertiesCode(): string;
  20949. serialize(): any;
  20950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20951. }
  20952. }
  20953. declare module BABYLON {
  20954. /**
  20955. * Base block used as input for post process
  20956. */
  20957. export class CurrentScreenBlock extends NodeMaterialBlock {
  20958. private _samplerName;
  20959. private _linearDefineName;
  20960. private _gammaDefineName;
  20961. private _mainUVName;
  20962. private _tempTextureRead;
  20963. /**
  20964. * Gets or sets the texture associated with the node
  20965. */
  20966. texture: Nullable<BaseTexture>;
  20967. /**
  20968. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20969. */
  20970. convertToGammaSpace: boolean;
  20971. /**
  20972. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20973. */
  20974. convertToLinearSpace: boolean;
  20975. /**
  20976. * Create a new CurrentScreenBlock
  20977. * @param name defines the block name
  20978. */
  20979. constructor(name: string);
  20980. /**
  20981. * Gets the current class name
  20982. * @returns the class name
  20983. */
  20984. getClassName(): string;
  20985. /**
  20986. * Gets the uv input component
  20987. */
  20988. get uv(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the rgba output component
  20991. */
  20992. get rgba(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the rgb output component
  20995. */
  20996. get rgb(): NodeMaterialConnectionPoint;
  20997. /**
  20998. * Gets the r output component
  20999. */
  21000. get r(): NodeMaterialConnectionPoint;
  21001. /**
  21002. * Gets the g output component
  21003. */
  21004. get g(): NodeMaterialConnectionPoint;
  21005. /**
  21006. * Gets the b output component
  21007. */
  21008. get b(): NodeMaterialConnectionPoint;
  21009. /**
  21010. * Gets the a output component
  21011. */
  21012. get a(): NodeMaterialConnectionPoint;
  21013. /**
  21014. * Initialize the block and prepare the context for build
  21015. * @param state defines the state that will be used for the build
  21016. */
  21017. initialize(state: NodeMaterialBuildState): void;
  21018. get target(): NodeMaterialBlockTargets;
  21019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21020. isReady(): boolean;
  21021. private _injectVertexCode;
  21022. private _writeTextureRead;
  21023. private _writeOutput;
  21024. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21025. serialize(): any;
  21026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21027. }
  21028. }
  21029. declare module BABYLON {
  21030. /**
  21031. * Base block used for the particle texture
  21032. */
  21033. export class ParticleTextureBlock extends NodeMaterialBlock {
  21034. private _samplerName;
  21035. private _linearDefineName;
  21036. private _gammaDefineName;
  21037. private _tempTextureRead;
  21038. /**
  21039. * Gets or sets the texture associated with the node
  21040. */
  21041. texture: Nullable<BaseTexture>;
  21042. /**
  21043. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21044. */
  21045. convertToGammaSpace: boolean;
  21046. /**
  21047. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21048. */
  21049. convertToLinearSpace: boolean;
  21050. /**
  21051. * Create a new ParticleTextureBlock
  21052. * @param name defines the block name
  21053. */
  21054. constructor(name: string);
  21055. /**
  21056. * Gets the current class name
  21057. * @returns the class name
  21058. */
  21059. getClassName(): string;
  21060. /**
  21061. * Gets the uv input component
  21062. */
  21063. get uv(): NodeMaterialConnectionPoint;
  21064. /**
  21065. * Gets the rgba output component
  21066. */
  21067. get rgba(): NodeMaterialConnectionPoint;
  21068. /**
  21069. * Gets the rgb output component
  21070. */
  21071. get rgb(): NodeMaterialConnectionPoint;
  21072. /**
  21073. * Gets the r output component
  21074. */
  21075. get r(): NodeMaterialConnectionPoint;
  21076. /**
  21077. * Gets the g output component
  21078. */
  21079. get g(): NodeMaterialConnectionPoint;
  21080. /**
  21081. * Gets the b output component
  21082. */
  21083. get b(): NodeMaterialConnectionPoint;
  21084. /**
  21085. * Gets the a output component
  21086. */
  21087. get a(): NodeMaterialConnectionPoint;
  21088. /**
  21089. * Initialize the block and prepare the context for build
  21090. * @param state defines the state that will be used for the build
  21091. */
  21092. initialize(state: NodeMaterialBuildState): void;
  21093. autoConfigure(material: NodeMaterial): void;
  21094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21095. isReady(): boolean;
  21096. private _writeOutput;
  21097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21098. serialize(): any;
  21099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21100. }
  21101. }
  21102. declare module BABYLON {
  21103. /**
  21104. * Class used to store shared data between 2 NodeMaterialBuildState
  21105. */
  21106. export class NodeMaterialBuildStateSharedData {
  21107. /**
  21108. * Gets the list of emitted varyings
  21109. */
  21110. temps: string[];
  21111. /**
  21112. * Gets the list of emitted varyings
  21113. */
  21114. varyings: string[];
  21115. /**
  21116. * Gets the varying declaration string
  21117. */
  21118. varyingDeclaration: string;
  21119. /**
  21120. * Input blocks
  21121. */
  21122. inputBlocks: InputBlock[];
  21123. /**
  21124. * Input blocks
  21125. */
  21126. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21127. /**
  21128. * Bindable blocks (Blocks that need to set data to the effect)
  21129. */
  21130. bindableBlocks: NodeMaterialBlock[];
  21131. /**
  21132. * List of blocks that can provide a compilation fallback
  21133. */
  21134. blocksWithFallbacks: NodeMaterialBlock[];
  21135. /**
  21136. * List of blocks that can provide a define update
  21137. */
  21138. blocksWithDefines: NodeMaterialBlock[];
  21139. /**
  21140. * List of blocks that can provide a repeatable content
  21141. */
  21142. repeatableContentBlocks: NodeMaterialBlock[];
  21143. /**
  21144. * List of blocks that can provide a dynamic list of uniforms
  21145. */
  21146. dynamicUniformBlocks: NodeMaterialBlock[];
  21147. /**
  21148. * List of blocks that can block the isReady function for the material
  21149. */
  21150. blockingBlocks: NodeMaterialBlock[];
  21151. /**
  21152. * Gets the list of animated inputs
  21153. */
  21154. animatedInputs: InputBlock[];
  21155. /**
  21156. * Build Id used to avoid multiple recompilations
  21157. */
  21158. buildId: number;
  21159. /** List of emitted variables */
  21160. variableNames: {
  21161. [key: string]: number;
  21162. };
  21163. /** List of emitted defines */
  21164. defineNames: {
  21165. [key: string]: number;
  21166. };
  21167. /** Should emit comments? */
  21168. emitComments: boolean;
  21169. /** Emit build activity */
  21170. verbose: boolean;
  21171. /** Gets or sets the hosting scene */
  21172. scene: Scene;
  21173. /**
  21174. * Gets the compilation hints emitted at compilation time
  21175. */
  21176. hints: {
  21177. needWorldViewMatrix: boolean;
  21178. needWorldViewProjectionMatrix: boolean;
  21179. needAlphaBlending: boolean;
  21180. needAlphaTesting: boolean;
  21181. };
  21182. /**
  21183. * List of compilation checks
  21184. */
  21185. checks: {
  21186. emitVertex: boolean;
  21187. emitFragment: boolean;
  21188. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21189. };
  21190. /**
  21191. * Is vertex program allowed to be empty?
  21192. */
  21193. allowEmptyVertexProgram: boolean;
  21194. /** Creates a new shared data */
  21195. constructor();
  21196. /**
  21197. * Emits console errors and exceptions if there is a failing check
  21198. */
  21199. emitErrors(): void;
  21200. }
  21201. }
  21202. declare module BABYLON {
  21203. /**
  21204. * Class used to store node based material build state
  21205. */
  21206. export class NodeMaterialBuildState {
  21207. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21208. supportUniformBuffers: boolean;
  21209. /**
  21210. * Gets the list of emitted attributes
  21211. */
  21212. attributes: string[];
  21213. /**
  21214. * Gets the list of emitted uniforms
  21215. */
  21216. uniforms: string[];
  21217. /**
  21218. * Gets the list of emitted constants
  21219. */
  21220. constants: string[];
  21221. /**
  21222. * Gets the list of emitted samplers
  21223. */
  21224. samplers: string[];
  21225. /**
  21226. * Gets the list of emitted functions
  21227. */
  21228. functions: {
  21229. [key: string]: string;
  21230. };
  21231. /**
  21232. * Gets the list of emitted extensions
  21233. */
  21234. extensions: {
  21235. [key: string]: string;
  21236. };
  21237. /**
  21238. * Gets the target of the compilation state
  21239. */
  21240. target: NodeMaterialBlockTargets;
  21241. /**
  21242. * Gets the list of emitted counters
  21243. */
  21244. counters: {
  21245. [key: string]: number;
  21246. };
  21247. /**
  21248. * Shared data between multiple NodeMaterialBuildState instances
  21249. */
  21250. sharedData: NodeMaterialBuildStateSharedData;
  21251. /** @hidden */
  21252. _vertexState: NodeMaterialBuildState;
  21253. /** @hidden */
  21254. _attributeDeclaration: string;
  21255. /** @hidden */
  21256. _uniformDeclaration: string;
  21257. /** @hidden */
  21258. _constantDeclaration: string;
  21259. /** @hidden */
  21260. _samplerDeclaration: string;
  21261. /** @hidden */
  21262. _varyingTransfer: string;
  21263. /** @hidden */
  21264. _injectAtEnd: string;
  21265. private _repeatableContentAnchorIndex;
  21266. /** @hidden */
  21267. _builtCompilationString: string;
  21268. /**
  21269. * Gets the emitted compilation strings
  21270. */
  21271. compilationString: string;
  21272. /**
  21273. * Finalize the compilation strings
  21274. * @param state defines the current compilation state
  21275. */
  21276. finalize(state: NodeMaterialBuildState): void;
  21277. /** @hidden */
  21278. get _repeatableContentAnchor(): string;
  21279. /** @hidden */
  21280. _getFreeVariableName(prefix: string): string;
  21281. /** @hidden */
  21282. _getFreeDefineName(prefix: string): string;
  21283. /** @hidden */
  21284. _excludeVariableName(name: string): void;
  21285. /** @hidden */
  21286. _emit2DSampler(name: string): void;
  21287. /** @hidden */
  21288. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21289. /** @hidden */
  21290. _emitExtension(name: string, extension: string, define?: string): void;
  21291. /** @hidden */
  21292. _emitFunction(name: string, code: string, comments: string): void;
  21293. /** @hidden */
  21294. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21295. replaceStrings?: {
  21296. search: RegExp;
  21297. replace: string;
  21298. }[];
  21299. repeatKey?: string;
  21300. }): string;
  21301. /** @hidden */
  21302. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21303. repeatKey?: string;
  21304. removeAttributes?: boolean;
  21305. removeUniforms?: boolean;
  21306. removeVaryings?: boolean;
  21307. removeIfDef?: boolean;
  21308. replaceStrings?: {
  21309. search: RegExp;
  21310. replace: string;
  21311. }[];
  21312. }, storeKey?: string): void;
  21313. /** @hidden */
  21314. _registerTempVariable(name: string): boolean;
  21315. /** @hidden */
  21316. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21317. /** @hidden */
  21318. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21319. /** @hidden */
  21320. _emitFloat(value: number): string;
  21321. }
  21322. }
  21323. declare module BABYLON {
  21324. /**
  21325. * Helper class used to generate session unique ID
  21326. */
  21327. export class UniqueIdGenerator {
  21328. private static _UniqueIdCounter;
  21329. /**
  21330. * Gets an unique (relatively to the current scene) Id
  21331. */
  21332. static get UniqueId(): number;
  21333. }
  21334. }
  21335. declare module BABYLON {
  21336. /**
  21337. * Defines a block that can be used inside a node based material
  21338. */
  21339. export class NodeMaterialBlock {
  21340. private _buildId;
  21341. private _buildTarget;
  21342. private _target;
  21343. private _isFinalMerger;
  21344. private _isInput;
  21345. protected _isUnique: boolean;
  21346. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21347. inputsAreExclusive: boolean;
  21348. /** @hidden */
  21349. _codeVariableName: string;
  21350. /** @hidden */
  21351. _inputs: NodeMaterialConnectionPoint[];
  21352. /** @hidden */
  21353. _outputs: NodeMaterialConnectionPoint[];
  21354. /** @hidden */
  21355. _preparationId: number;
  21356. /**
  21357. * Gets or sets the name of the block
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the unique id of the node
  21362. */
  21363. uniqueId: number;
  21364. /**
  21365. * Gets or sets the comments associated with this block
  21366. */
  21367. comments: string;
  21368. /**
  21369. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21370. */
  21371. get isUnique(): boolean;
  21372. /**
  21373. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21374. */
  21375. get isFinalMerger(): boolean;
  21376. /**
  21377. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21378. */
  21379. get isInput(): boolean;
  21380. /**
  21381. * Gets or sets the build Id
  21382. */
  21383. get buildId(): number;
  21384. set buildId(value: number);
  21385. /**
  21386. * Gets or sets the target of the block
  21387. */
  21388. get target(): NodeMaterialBlockTargets;
  21389. set target(value: NodeMaterialBlockTargets);
  21390. /**
  21391. * Gets the list of input points
  21392. */
  21393. get inputs(): NodeMaterialConnectionPoint[];
  21394. /** Gets the list of output points */
  21395. get outputs(): NodeMaterialConnectionPoint[];
  21396. /**
  21397. * Find an input by its name
  21398. * @param name defines the name of the input to look for
  21399. * @returns the input or null if not found
  21400. */
  21401. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21402. /**
  21403. * Find an output by its name
  21404. * @param name defines the name of the outputto look for
  21405. * @returns the output or null if not found
  21406. */
  21407. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21408. /**
  21409. * Creates a new NodeMaterialBlock
  21410. * @param name defines the block name
  21411. * @param target defines the target of that block (Vertex by default)
  21412. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21413. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21414. */
  21415. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21416. /**
  21417. * Initialize the block and prepare the context for build
  21418. * @param state defines the state that will be used for the build
  21419. */
  21420. initialize(state: NodeMaterialBuildState): void;
  21421. /**
  21422. * Bind data to effect. Will only be called for blocks with isBindable === true
  21423. * @param effect defines the effect to bind data to
  21424. * @param nodeMaterial defines the hosting NodeMaterial
  21425. * @param mesh defines the mesh that will be rendered
  21426. * @param subMesh defines the submesh that will be rendered
  21427. */
  21428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21429. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21430. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21431. protected _writeFloat(value: number): string;
  21432. /**
  21433. * Gets the current class name e.g. "NodeMaterialBlock"
  21434. * @returns the class name
  21435. */
  21436. getClassName(): string;
  21437. /**
  21438. * Register a new input. Must be called inside a block constructor
  21439. * @param name defines the connection point name
  21440. * @param type defines the connection point type
  21441. * @param isOptional defines a boolean indicating that this input can be omitted
  21442. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21443. * @param point an already created connection point. If not provided, create a new one
  21444. * @returns the current block
  21445. */
  21446. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21447. /**
  21448. * Register a new output. Must be called inside a block constructor
  21449. * @param name defines the connection point name
  21450. * @param type defines the connection point type
  21451. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21452. * @param point an already created connection point. If not provided, create a new one
  21453. * @returns the current block
  21454. */
  21455. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21456. /**
  21457. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21458. * @param forOutput defines an optional connection point to check compatibility with
  21459. * @returns the first available input or null
  21460. */
  21461. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21462. /**
  21463. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21464. * @param forBlock defines an optional block to check compatibility with
  21465. * @returns the first available input or null
  21466. */
  21467. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21468. /**
  21469. * Gets the sibling of the given output
  21470. * @param current defines the current output
  21471. * @returns the next output in the list or null
  21472. */
  21473. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21474. /**
  21475. * Connect current block with another block
  21476. * @param other defines the block to connect with
  21477. * @param options define the various options to help pick the right connections
  21478. * @returns the current block
  21479. */
  21480. connectTo(other: NodeMaterialBlock, options?: {
  21481. input?: string;
  21482. output?: string;
  21483. outputSwizzle?: string;
  21484. }): this | undefined;
  21485. protected _buildBlock(state: NodeMaterialBuildState): void;
  21486. /**
  21487. * Add uniforms, samplers and uniform buffers at compilation time
  21488. * @param state defines the state to update
  21489. * @param nodeMaterial defines the node material requesting the update
  21490. * @param defines defines the material defines to update
  21491. * @param uniformBuffers defines the list of uniform buffer names
  21492. */
  21493. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21494. /**
  21495. * Add potential fallbacks if shader compilation fails
  21496. * @param mesh defines the mesh to be rendered
  21497. * @param fallbacks defines the current prioritized list of fallbacks
  21498. */
  21499. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21500. /**
  21501. * Initialize defines for shader compilation
  21502. * @param mesh defines the mesh to be rendered
  21503. * @param nodeMaterial defines the node material requesting the update
  21504. * @param defines defines the material defines to update
  21505. * @param useInstances specifies that instances should be used
  21506. */
  21507. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21508. /**
  21509. * Update defines for shader compilation
  21510. * @param mesh defines the mesh to be rendered
  21511. * @param nodeMaterial defines the node material requesting the update
  21512. * @param defines defines the material defines to update
  21513. * @param useInstances specifies that instances should be used
  21514. * @param subMesh defines which submesh to render
  21515. */
  21516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21517. /**
  21518. * Lets the block try to connect some inputs automatically
  21519. * @param material defines the hosting NodeMaterial
  21520. */
  21521. autoConfigure(material: NodeMaterial): void;
  21522. /**
  21523. * Function called when a block is declared as repeatable content generator
  21524. * @param vertexShaderState defines the current compilation state for the vertex shader
  21525. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21526. * @param mesh defines the mesh to be rendered
  21527. * @param defines defines the material defines to update
  21528. */
  21529. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21530. /**
  21531. * Checks if the block is ready
  21532. * @param mesh defines the mesh to be rendered
  21533. * @param nodeMaterial defines the node material requesting the update
  21534. * @param defines defines the material defines to update
  21535. * @param useInstances specifies that instances should be used
  21536. * @returns true if the block is ready
  21537. */
  21538. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21539. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21540. private _processBuild;
  21541. /**
  21542. * Compile the current node and generate the shader code
  21543. * @param state defines the current compilation state (uniforms, samplers, current string)
  21544. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21545. * @returns true if already built
  21546. */
  21547. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21548. protected _inputRename(name: string): string;
  21549. protected _outputRename(name: string): string;
  21550. protected _dumpPropertiesCode(): string;
  21551. /** @hidden */
  21552. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21553. /** @hidden */
  21554. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21555. /**
  21556. * Clone the current block to a new identical block
  21557. * @param scene defines the hosting scene
  21558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21559. * @returns a copy of the current block
  21560. */
  21561. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21562. /**
  21563. * Serializes this block in a JSON representation
  21564. * @returns the serialized block object
  21565. */
  21566. serialize(): any;
  21567. /** @hidden */
  21568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21569. private _deserializePortDisplayNamesAndExposedOnFrame;
  21570. /**
  21571. * Release resources
  21572. */
  21573. dispose(): void;
  21574. }
  21575. }
  21576. declare module BABYLON {
  21577. /**
  21578. * Base class of materials working in push mode in babylon JS
  21579. * @hidden
  21580. */
  21581. export class PushMaterial extends Material {
  21582. protected _activeEffect: Effect;
  21583. protected _normalMatrix: Matrix;
  21584. constructor(name: string, scene: Scene);
  21585. getEffect(): Effect;
  21586. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21587. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21588. /**
  21589. * Binds the given world matrix to the active effect
  21590. *
  21591. * @param world the matrix to bind
  21592. */
  21593. bindOnlyWorldMatrix(world: Matrix): void;
  21594. /**
  21595. * Binds the given normal matrix to the active effect
  21596. *
  21597. * @param normalMatrix the matrix to bind
  21598. */
  21599. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21600. bind(world: Matrix, mesh?: Mesh): void;
  21601. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21602. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21603. }
  21604. }
  21605. declare module BABYLON {
  21606. /**
  21607. * Root class for all node material optimizers
  21608. */
  21609. export class NodeMaterialOptimizer {
  21610. /**
  21611. * Function used to optimize a NodeMaterial graph
  21612. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21613. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21614. */
  21615. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21616. }
  21617. }
  21618. declare module BABYLON {
  21619. /**
  21620. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21621. */
  21622. export class TransformBlock extends NodeMaterialBlock {
  21623. /**
  21624. * Defines the value to use to complement W value to transform it to a Vector4
  21625. */
  21626. complementW: number;
  21627. /**
  21628. * Defines the value to use to complement z value to transform it to a Vector4
  21629. */
  21630. complementZ: number;
  21631. /**
  21632. * Creates a new TransformBlock
  21633. * @param name defines the block name
  21634. */
  21635. constructor(name: string);
  21636. /**
  21637. * Gets the current class name
  21638. * @returns the class name
  21639. */
  21640. getClassName(): string;
  21641. /**
  21642. * Gets the vector input
  21643. */
  21644. get vector(): NodeMaterialConnectionPoint;
  21645. /**
  21646. * Gets the output component
  21647. */
  21648. get output(): NodeMaterialConnectionPoint;
  21649. /**
  21650. * Gets the xyz output component
  21651. */
  21652. get xyz(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the matrix transform input
  21655. */
  21656. get transform(): NodeMaterialConnectionPoint;
  21657. protected _buildBlock(state: NodeMaterialBuildState): this;
  21658. /**
  21659. * Update defines for shader compilation
  21660. * @param mesh defines the mesh to be rendered
  21661. * @param nodeMaterial defines the node material requesting the update
  21662. * @param defines defines the material defines to update
  21663. * @param useInstances specifies that instances should be used
  21664. * @param subMesh defines which submesh to render
  21665. */
  21666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21667. serialize(): any;
  21668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21669. protected _dumpPropertiesCode(): string;
  21670. }
  21671. }
  21672. declare module BABYLON {
  21673. /**
  21674. * Block used to output the vertex position
  21675. */
  21676. export class VertexOutputBlock extends NodeMaterialBlock {
  21677. /**
  21678. * Creates a new VertexOutputBlock
  21679. * @param name defines the block name
  21680. */
  21681. constructor(name: string);
  21682. /**
  21683. * Gets the current class name
  21684. * @returns the class name
  21685. */
  21686. getClassName(): string;
  21687. /**
  21688. * Gets the vector input component
  21689. */
  21690. get vector(): NodeMaterialConnectionPoint;
  21691. protected _buildBlock(state: NodeMaterialBuildState): this;
  21692. }
  21693. }
  21694. declare module BABYLON {
  21695. /**
  21696. * Block used to output the final color
  21697. */
  21698. export class FragmentOutputBlock extends NodeMaterialBlock {
  21699. /**
  21700. * Create a new FragmentOutputBlock
  21701. * @param name defines the block name
  21702. */
  21703. constructor(name: string);
  21704. /**
  21705. * Gets the current class name
  21706. * @returns the class name
  21707. */
  21708. getClassName(): string;
  21709. /**
  21710. * Gets the rgba input component
  21711. */
  21712. get rgba(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the rgb input component
  21715. */
  21716. get rgb(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the a input component
  21719. */
  21720. get a(): NodeMaterialConnectionPoint;
  21721. protected _buildBlock(state: NodeMaterialBuildState): this;
  21722. }
  21723. }
  21724. declare module BABYLON {
  21725. /**
  21726. * Block used for the particle ramp gradient section
  21727. */
  21728. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21729. /**
  21730. * Create a new ParticleRampGradientBlock
  21731. * @param name defines the block name
  21732. */
  21733. constructor(name: string);
  21734. /**
  21735. * Gets the current class name
  21736. * @returns the class name
  21737. */
  21738. getClassName(): string;
  21739. /**
  21740. * Gets the color input component
  21741. */
  21742. get color(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the rampColor output component
  21745. */
  21746. get rampColor(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Initialize the block and prepare the context for build
  21749. * @param state defines the state that will be used for the build
  21750. */
  21751. initialize(state: NodeMaterialBuildState): void;
  21752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21753. }
  21754. }
  21755. declare module BABYLON {
  21756. /**
  21757. * Block used for the particle blend multiply section
  21758. */
  21759. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21760. /**
  21761. * Create a new ParticleBlendMultiplyBlock
  21762. * @param name defines the block name
  21763. */
  21764. constructor(name: string);
  21765. /**
  21766. * Gets the current class name
  21767. * @returns the class name
  21768. */
  21769. getClassName(): string;
  21770. /**
  21771. * Gets the color input component
  21772. */
  21773. get color(): NodeMaterialConnectionPoint;
  21774. /**
  21775. * Gets the alphaTexture input component
  21776. */
  21777. get alphaTexture(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the alphaColor input component
  21780. */
  21781. get alphaColor(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the blendColor output component
  21784. */
  21785. get blendColor(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Initialize the block and prepare the context for build
  21788. * @param state defines the state that will be used for the build
  21789. */
  21790. initialize(state: NodeMaterialBuildState): void;
  21791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21792. }
  21793. }
  21794. declare module BABYLON {
  21795. /**
  21796. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21797. */
  21798. export class VectorMergerBlock extends NodeMaterialBlock {
  21799. /**
  21800. * Create a new VectorMergerBlock
  21801. * @param name defines the block name
  21802. */
  21803. constructor(name: string);
  21804. /**
  21805. * Gets the current class name
  21806. * @returns the class name
  21807. */
  21808. getClassName(): string;
  21809. /**
  21810. * Gets the xyz component (input)
  21811. */
  21812. get xyzIn(): NodeMaterialConnectionPoint;
  21813. /**
  21814. * Gets the xy component (input)
  21815. */
  21816. get xyIn(): NodeMaterialConnectionPoint;
  21817. /**
  21818. * Gets the x component (input)
  21819. */
  21820. get x(): NodeMaterialConnectionPoint;
  21821. /**
  21822. * Gets the y component (input)
  21823. */
  21824. get y(): NodeMaterialConnectionPoint;
  21825. /**
  21826. * Gets the z component (input)
  21827. */
  21828. get z(): NodeMaterialConnectionPoint;
  21829. /**
  21830. * Gets the w component (input)
  21831. */
  21832. get w(): NodeMaterialConnectionPoint;
  21833. /**
  21834. * Gets the xyzw component (output)
  21835. */
  21836. get xyzw(): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Gets the xyz component (output)
  21839. */
  21840. get xyzOut(): NodeMaterialConnectionPoint;
  21841. /**
  21842. * Gets the xy component (output)
  21843. */
  21844. get xyOut(): NodeMaterialConnectionPoint;
  21845. /**
  21846. * Gets the xy component (output)
  21847. * @deprecated Please use xyOut instead.
  21848. */
  21849. get xy(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the xyz component (output)
  21852. * @deprecated Please use xyzOut instead.
  21853. */
  21854. get xyz(): NodeMaterialConnectionPoint;
  21855. protected _buildBlock(state: NodeMaterialBuildState): this;
  21856. }
  21857. }
  21858. declare module BABYLON {
  21859. /**
  21860. * Block used to remap a float from a range to a new one
  21861. */
  21862. export class RemapBlock extends NodeMaterialBlock {
  21863. /**
  21864. * Gets or sets the source range
  21865. */
  21866. sourceRange: Vector2;
  21867. /**
  21868. * Gets or sets the target range
  21869. */
  21870. targetRange: Vector2;
  21871. /**
  21872. * Creates a new RemapBlock
  21873. * @param name defines the block name
  21874. */
  21875. constructor(name: string);
  21876. /**
  21877. * Gets the current class name
  21878. * @returns the class name
  21879. */
  21880. getClassName(): string;
  21881. /**
  21882. * Gets the input component
  21883. */
  21884. get input(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Gets the source min input component
  21887. */
  21888. get sourceMin(): NodeMaterialConnectionPoint;
  21889. /**
  21890. * Gets the source max input component
  21891. */
  21892. get sourceMax(): NodeMaterialConnectionPoint;
  21893. /**
  21894. * Gets the target min input component
  21895. */
  21896. get targetMin(): NodeMaterialConnectionPoint;
  21897. /**
  21898. * Gets the target max input component
  21899. */
  21900. get targetMax(): NodeMaterialConnectionPoint;
  21901. /**
  21902. * Gets the output component
  21903. */
  21904. get output(): NodeMaterialConnectionPoint;
  21905. protected _buildBlock(state: NodeMaterialBuildState): this;
  21906. protected _dumpPropertiesCode(): string;
  21907. serialize(): any;
  21908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21909. }
  21910. }
  21911. declare module BABYLON {
  21912. /**
  21913. * Block used to multiply 2 values
  21914. */
  21915. export class MultiplyBlock extends NodeMaterialBlock {
  21916. /**
  21917. * Creates a new MultiplyBlock
  21918. * @param name defines the block name
  21919. */
  21920. constructor(name: string);
  21921. /**
  21922. * Gets the current class name
  21923. * @returns the class name
  21924. */
  21925. getClassName(): string;
  21926. /**
  21927. * Gets the left operand input component
  21928. */
  21929. get left(): NodeMaterialConnectionPoint;
  21930. /**
  21931. * Gets the right operand input component
  21932. */
  21933. get right(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the output component
  21936. */
  21937. get output(): NodeMaterialConnectionPoint;
  21938. protected _buildBlock(state: NodeMaterialBuildState): this;
  21939. }
  21940. }
  21941. declare module BABYLON {
  21942. /**
  21943. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21944. */
  21945. export class ColorSplitterBlock extends NodeMaterialBlock {
  21946. /**
  21947. * Create a new ColorSplitterBlock
  21948. * @param name defines the block name
  21949. */
  21950. constructor(name: string);
  21951. /**
  21952. * Gets the current class name
  21953. * @returns the class name
  21954. */
  21955. getClassName(): string;
  21956. /**
  21957. * Gets the rgba component (input)
  21958. */
  21959. get rgba(): NodeMaterialConnectionPoint;
  21960. /**
  21961. * Gets the rgb component (input)
  21962. */
  21963. get rgbIn(): NodeMaterialConnectionPoint;
  21964. /**
  21965. * Gets the rgb component (output)
  21966. */
  21967. get rgbOut(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the r component (output)
  21970. */
  21971. get r(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the g component (output)
  21974. */
  21975. get g(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the b component (output)
  21978. */
  21979. get b(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Gets the a component (output)
  21982. */
  21983. get a(): NodeMaterialConnectionPoint;
  21984. protected _inputRename(name: string): string;
  21985. protected _outputRename(name: string): string;
  21986. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Interface used to configure the node material editor
  21992. */
  21993. export interface INodeMaterialEditorOptions {
  21994. /** Define the URl to load node editor script */
  21995. editorURL?: string;
  21996. }
  21997. /** @hidden */
  21998. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21999. NORMAL: boolean;
  22000. TANGENT: boolean;
  22001. UV1: boolean;
  22002. /** BONES */
  22003. NUM_BONE_INFLUENCERS: number;
  22004. BonesPerMesh: number;
  22005. BONETEXTURE: boolean;
  22006. /** MORPH TARGETS */
  22007. MORPHTARGETS: boolean;
  22008. MORPHTARGETS_NORMAL: boolean;
  22009. MORPHTARGETS_TANGENT: boolean;
  22010. MORPHTARGETS_UV: boolean;
  22011. NUM_MORPH_INFLUENCERS: number;
  22012. /** IMAGE PROCESSING */
  22013. IMAGEPROCESSING: boolean;
  22014. VIGNETTE: boolean;
  22015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22016. VIGNETTEBLENDMODEOPAQUE: boolean;
  22017. TONEMAPPING: boolean;
  22018. TONEMAPPING_ACES: boolean;
  22019. CONTRAST: boolean;
  22020. EXPOSURE: boolean;
  22021. COLORCURVES: boolean;
  22022. COLORGRADING: boolean;
  22023. COLORGRADING3D: boolean;
  22024. SAMPLER3DGREENDEPTH: boolean;
  22025. SAMPLER3DBGRMAP: boolean;
  22026. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22027. /** MISC. */
  22028. BUMPDIRECTUV: number;
  22029. constructor();
  22030. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22031. }
  22032. /**
  22033. * Class used to configure NodeMaterial
  22034. */
  22035. export interface INodeMaterialOptions {
  22036. /**
  22037. * Defines if blocks should emit comments
  22038. */
  22039. emitComments: boolean;
  22040. }
  22041. /**
  22042. * Class used to create a node based material built by assembling shader blocks
  22043. */
  22044. export class NodeMaterial extends PushMaterial {
  22045. private static _BuildIdGenerator;
  22046. private _options;
  22047. private _vertexCompilationState;
  22048. private _fragmentCompilationState;
  22049. private _sharedData;
  22050. private _buildId;
  22051. private _buildWasSuccessful;
  22052. private _cachedWorldViewMatrix;
  22053. private _cachedWorldViewProjectionMatrix;
  22054. private _optimizers;
  22055. private _animationFrame;
  22056. /** Define the Url to load node editor script */
  22057. static EditorURL: string;
  22058. /** Define the Url to load snippets */
  22059. static SnippetUrl: string;
  22060. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22061. static IgnoreTexturesAtLoadTime: boolean;
  22062. private BJSNODEMATERIALEDITOR;
  22063. /** Get the inspector from bundle or global */
  22064. private _getGlobalNodeMaterialEditor;
  22065. /**
  22066. * Snippet ID if the material was created from the snippet server
  22067. */
  22068. snippetId: string;
  22069. /**
  22070. * Gets or sets data used by visual editor
  22071. * @see https://nme.babylonjs.com
  22072. */
  22073. editorData: any;
  22074. /**
  22075. * 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)
  22076. */
  22077. ignoreAlpha: boolean;
  22078. /**
  22079. * Defines the maximum number of lights that can be used in the material
  22080. */
  22081. maxSimultaneousLights: number;
  22082. /**
  22083. * Observable raised when the material is built
  22084. */
  22085. onBuildObservable: Observable<NodeMaterial>;
  22086. /**
  22087. * Gets or sets the root nodes of the material vertex shader
  22088. */
  22089. _vertexOutputNodes: NodeMaterialBlock[];
  22090. /**
  22091. * Gets or sets the root nodes of the material fragment (pixel) shader
  22092. */
  22093. _fragmentOutputNodes: NodeMaterialBlock[];
  22094. /** Gets or sets options to control the node material overall behavior */
  22095. get options(): INodeMaterialOptions;
  22096. set options(options: INodeMaterialOptions);
  22097. /**
  22098. * Default configuration related to image processing available in the standard Material.
  22099. */
  22100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22101. /**
  22102. * Gets the image processing configuration used either in this material.
  22103. */
  22104. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22105. /**
  22106. * Sets the Default image processing configuration used either in the this material.
  22107. *
  22108. * If sets to null, the scene one is in use.
  22109. */
  22110. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22111. /**
  22112. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22113. */
  22114. attachedBlocks: NodeMaterialBlock[];
  22115. /**
  22116. * Specifies the mode of the node material
  22117. * @hidden
  22118. */
  22119. _mode: NodeMaterialModes;
  22120. /**
  22121. * Gets the mode property
  22122. */
  22123. get mode(): NodeMaterialModes;
  22124. /**
  22125. * Create a new node based material
  22126. * @param name defines the material name
  22127. * @param scene defines the hosting scene
  22128. * @param options defines creation option
  22129. */
  22130. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22131. /**
  22132. * Gets the current class name of the material e.g. "NodeMaterial"
  22133. * @returns the class name
  22134. */
  22135. getClassName(): string;
  22136. /**
  22137. * Keep track of the image processing observer to allow dispose and replace.
  22138. */
  22139. private _imageProcessingObserver;
  22140. /**
  22141. * Attaches a new image processing configuration to the Standard Material.
  22142. * @param configuration
  22143. */
  22144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22145. /**
  22146. * Get a block by its name
  22147. * @param name defines the name of the block to retrieve
  22148. * @returns the required block or null if not found
  22149. */
  22150. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22151. /**
  22152. * Get a block by its name
  22153. * @param predicate defines the predicate used to find the good candidate
  22154. * @returns the required block or null if not found
  22155. */
  22156. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22157. /**
  22158. * Get an input block by its name
  22159. * @param predicate defines the predicate used to find the good candidate
  22160. * @returns the required input block or null if not found
  22161. */
  22162. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22163. /**
  22164. * Gets the list of input blocks attached to this material
  22165. * @returns an array of InputBlocks
  22166. */
  22167. getInputBlocks(): InputBlock[];
  22168. /**
  22169. * Adds a new optimizer to the list of optimizers
  22170. * @param optimizer defines the optimizers to add
  22171. * @returns the current material
  22172. */
  22173. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22174. /**
  22175. * Remove an optimizer from the list of optimizers
  22176. * @param optimizer defines the optimizers to remove
  22177. * @returns the current material
  22178. */
  22179. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22180. /**
  22181. * Add a new block to the list of output nodes
  22182. * @param node defines the node to add
  22183. * @returns the current material
  22184. */
  22185. addOutputNode(node: NodeMaterialBlock): this;
  22186. /**
  22187. * Remove a block from the list of root nodes
  22188. * @param node defines the node to remove
  22189. * @returns the current material
  22190. */
  22191. removeOutputNode(node: NodeMaterialBlock): this;
  22192. private _addVertexOutputNode;
  22193. private _removeVertexOutputNode;
  22194. private _addFragmentOutputNode;
  22195. private _removeFragmentOutputNode;
  22196. /**
  22197. * Specifies if the material will require alpha blending
  22198. * @returns a boolean specifying if alpha blending is needed
  22199. */
  22200. needAlphaBlending(): boolean;
  22201. /**
  22202. * Specifies if this material should be rendered in alpha test mode
  22203. * @returns a boolean specifying if an alpha test is needed.
  22204. */
  22205. needAlphaTesting(): boolean;
  22206. private _initializeBlock;
  22207. private _resetDualBlocks;
  22208. /**
  22209. * Remove a block from the current node material
  22210. * @param block defines the block to remove
  22211. */
  22212. removeBlock(block: NodeMaterialBlock): void;
  22213. /**
  22214. * Build the material and generates the inner effect
  22215. * @param verbose defines if the build should log activity
  22216. */
  22217. build(verbose?: boolean): void;
  22218. /**
  22219. * Runs an otpimization phase to try to improve the shader code
  22220. */
  22221. optimize(): void;
  22222. private _prepareDefinesForAttributes;
  22223. /**
  22224. * Create a post process from the material
  22225. * @param camera The camera to apply the render pass to.
  22226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22228. * @param engine The engine which the post process will be applied. (default: current engine)
  22229. * @param reusable If the post process can be reused on the same frame. (default: false)
  22230. * @param textureType Type of textures used when performing the post process. (default: 0)
  22231. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22232. * @returns the post process created
  22233. */
  22234. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22235. /**
  22236. * Create the post process effect from the material
  22237. * @param postProcess The post process to create the effect for
  22238. */
  22239. createEffectForPostProcess(postProcess: PostProcess): void;
  22240. private _createEffectOrPostProcess;
  22241. private _createEffectForParticles;
  22242. /**
  22243. * Create the effect to be used as the custom effect for a particle system
  22244. * @param particleSystem Particle system to create the effect for
  22245. * @param onCompiled defines a function to call when the effect creation is successful
  22246. * @param onError defines a function to call when the effect creation has failed
  22247. */
  22248. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22249. private _processDefines;
  22250. /**
  22251. * Get if the submesh is ready to be used and all its information available.
  22252. * Child classes can use it to update shaders
  22253. * @param mesh defines the mesh to check
  22254. * @param subMesh defines which submesh to check
  22255. * @param useInstances specifies that instances should be used
  22256. * @returns a boolean indicating that the submesh is ready or not
  22257. */
  22258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22259. /**
  22260. * Get a string representing the shaders built by the current node graph
  22261. */
  22262. get compiledShaders(): string;
  22263. /**
  22264. * Binds the world matrix to the material
  22265. * @param world defines the world transformation matrix
  22266. */
  22267. bindOnlyWorldMatrix(world: Matrix): void;
  22268. /**
  22269. * Binds the submesh to this material by preparing the effect and shader to draw
  22270. * @param world defines the world transformation matrix
  22271. * @param mesh defines the mesh containing the submesh
  22272. * @param subMesh defines the submesh to bind the material to
  22273. */
  22274. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22275. /**
  22276. * Gets the active textures from the material
  22277. * @returns an array of textures
  22278. */
  22279. getActiveTextures(): BaseTexture[];
  22280. /**
  22281. * Gets the list of texture blocks
  22282. * @returns an array of texture blocks
  22283. */
  22284. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22285. /**
  22286. * Specifies if the material uses a texture
  22287. * @param texture defines the texture to check against the material
  22288. * @returns a boolean specifying if the material uses the texture
  22289. */
  22290. hasTexture(texture: BaseTexture): boolean;
  22291. /**
  22292. * Disposes the material
  22293. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22294. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22295. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22296. */
  22297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22298. /** Creates the node editor window. */
  22299. private _createNodeEditor;
  22300. /**
  22301. * Launch the node material editor
  22302. * @param config Define the configuration of the editor
  22303. * @return a promise fulfilled when the node editor is visible
  22304. */
  22305. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22306. /**
  22307. * Clear the current material
  22308. */
  22309. clear(): void;
  22310. /**
  22311. * Clear the current material and set it to a default state
  22312. */
  22313. setToDefault(): void;
  22314. /**
  22315. * Clear the current material and set it to a default state for post process
  22316. */
  22317. setToDefaultPostProcess(): void;
  22318. /**
  22319. * Clear the current material and set it to a default state for particle
  22320. */
  22321. setToDefaultParticle(): void;
  22322. /**
  22323. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22324. * @param url defines the url to load from
  22325. * @returns a promise that will fullfil when the material is fully loaded
  22326. */
  22327. loadAsync(url: string): Promise<void>;
  22328. private _gatherBlocks;
  22329. /**
  22330. * Generate a string containing the code declaration required to create an equivalent of this material
  22331. * @returns a string
  22332. */
  22333. generateCode(): string;
  22334. /**
  22335. * Serializes this material in a JSON representation
  22336. * @returns the serialized material object
  22337. */
  22338. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22339. private _restoreConnections;
  22340. /**
  22341. * Clear the current graph and load a new one from a serialization object
  22342. * @param source defines the JSON representation of the material
  22343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22344. */
  22345. loadFromSerialization(source: any, rootUrl?: string): void;
  22346. /**
  22347. * Makes a duplicate of the current material.
  22348. * @param name - name to use for the new material.
  22349. */
  22350. clone(name: string): NodeMaterial;
  22351. /**
  22352. * Creates a node material from parsed material data
  22353. * @param source defines the JSON representation of the material
  22354. * @param scene defines the hosting scene
  22355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22356. * @returns a new node material
  22357. */
  22358. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22359. /**
  22360. * Creates a node material from a snippet saved in a remote file
  22361. * @param name defines the name of the material to create
  22362. * @param url defines the url to load from
  22363. * @param scene defines the hosting scene
  22364. * @returns a promise that will resolve to the new node material
  22365. */
  22366. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22367. /**
  22368. * Creates a node material from a snippet saved by the node material editor
  22369. * @param snippetId defines the snippet to load
  22370. * @param scene defines the hosting scene
  22371. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22372. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22373. * @returns a promise that will resolve to the new node material
  22374. */
  22375. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22376. /**
  22377. * Creates a new node material set to default basic configuration
  22378. * @param name defines the name of the material
  22379. * @param scene defines the hosting scene
  22380. * @returns a new NodeMaterial
  22381. */
  22382. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22383. }
  22384. }
  22385. declare module BABYLON {
  22386. /**
  22387. * Size options for a post process
  22388. */
  22389. export type PostProcessOptions = {
  22390. width: number;
  22391. height: number;
  22392. };
  22393. /**
  22394. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22395. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22396. */
  22397. export class PostProcess {
  22398. /** Name of the PostProcess. */
  22399. name: string;
  22400. /**
  22401. * Gets or sets the unique id of the post process
  22402. */
  22403. uniqueId: number;
  22404. /**
  22405. * Width of the texture to apply the post process on
  22406. */
  22407. width: number;
  22408. /**
  22409. * Height of the texture to apply the post process on
  22410. */
  22411. height: number;
  22412. /**
  22413. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22414. */
  22415. nodeMaterialSource: Nullable<NodeMaterial>;
  22416. /**
  22417. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22418. * @hidden
  22419. */
  22420. _outputTexture: Nullable<InternalTexture>;
  22421. /**
  22422. * Sampling mode used by the shader
  22423. * See https://doc.babylonjs.com/classes/3.1/texture
  22424. */
  22425. renderTargetSamplingMode: number;
  22426. /**
  22427. * Clear color to use when screen clearing
  22428. */
  22429. clearColor: Color4;
  22430. /**
  22431. * If the buffer needs to be cleared before applying the post process. (default: true)
  22432. * Should be set to false if shader will overwrite all previous pixels.
  22433. */
  22434. autoClear: boolean;
  22435. /**
  22436. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22437. */
  22438. alphaMode: number;
  22439. /**
  22440. * Sets the setAlphaBlendConstants of the babylon engine
  22441. */
  22442. alphaConstants: Color4;
  22443. /**
  22444. * Animations to be used for the post processing
  22445. */
  22446. animations: Animation[];
  22447. /**
  22448. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22449. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22450. */
  22451. enablePixelPerfectMode: boolean;
  22452. /**
  22453. * Force the postprocess to be applied without taking in account viewport
  22454. */
  22455. forceFullscreenViewport: boolean;
  22456. /**
  22457. * List of inspectable custom properties (used by the Inspector)
  22458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22459. */
  22460. inspectableCustomProperties: IInspectable[];
  22461. /**
  22462. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22463. *
  22464. * | Value | Type | Description |
  22465. * | ----- | ----------------------------------- | ----------- |
  22466. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22467. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22468. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22469. *
  22470. */
  22471. scaleMode: number;
  22472. /**
  22473. * Force textures to be a power of two (default: false)
  22474. */
  22475. alwaysForcePOT: boolean;
  22476. private _samples;
  22477. /**
  22478. * Number of sample textures (default: 1)
  22479. */
  22480. get samples(): number;
  22481. set samples(n: number);
  22482. /**
  22483. * Modify the scale of the post process to be the same as the viewport (default: false)
  22484. */
  22485. adaptScaleToCurrentViewport: boolean;
  22486. private _camera;
  22487. private _scene;
  22488. private _engine;
  22489. private _options;
  22490. private _reusable;
  22491. private _textureType;
  22492. private _textureFormat;
  22493. /**
  22494. * Smart array of input and output textures for the post process.
  22495. * @hidden
  22496. */
  22497. _textures: SmartArray<InternalTexture>;
  22498. /**
  22499. * The index in _textures that corresponds to the output texture.
  22500. * @hidden
  22501. */
  22502. _currentRenderTextureInd: number;
  22503. private _effect;
  22504. private _samplers;
  22505. private _fragmentUrl;
  22506. private _vertexUrl;
  22507. private _parameters;
  22508. private _scaleRatio;
  22509. protected _indexParameters: any;
  22510. private _shareOutputWithPostProcess;
  22511. private _texelSize;
  22512. private _forcedOutputTexture;
  22513. /**
  22514. * Returns the fragment url or shader name used in the post process.
  22515. * @returns the fragment url or name in the shader store.
  22516. */
  22517. getEffectName(): string;
  22518. /**
  22519. * An event triggered when the postprocess is activated.
  22520. */
  22521. onActivateObservable: Observable<Camera>;
  22522. private _onActivateObserver;
  22523. /**
  22524. * A function that is added to the onActivateObservable
  22525. */
  22526. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22527. /**
  22528. * An event triggered when the postprocess changes its size.
  22529. */
  22530. onSizeChangedObservable: Observable<PostProcess>;
  22531. private _onSizeChangedObserver;
  22532. /**
  22533. * A function that is added to the onSizeChangedObservable
  22534. */
  22535. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22536. /**
  22537. * An event triggered when the postprocess applies its effect.
  22538. */
  22539. onApplyObservable: Observable<Effect>;
  22540. private _onApplyObserver;
  22541. /**
  22542. * A function that is added to the onApplyObservable
  22543. */
  22544. set onApply(callback: (effect: Effect) => void);
  22545. /**
  22546. * An event triggered before rendering the postprocess
  22547. */
  22548. onBeforeRenderObservable: Observable<Effect>;
  22549. private _onBeforeRenderObserver;
  22550. /**
  22551. * A function that is added to the onBeforeRenderObservable
  22552. */
  22553. set onBeforeRender(callback: (effect: Effect) => void);
  22554. /**
  22555. * An event triggered after rendering the postprocess
  22556. */
  22557. onAfterRenderObservable: Observable<Effect>;
  22558. private _onAfterRenderObserver;
  22559. /**
  22560. * A function that is added to the onAfterRenderObservable
  22561. */
  22562. set onAfterRender(callback: (efect: Effect) => void);
  22563. /**
  22564. * 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
  22565. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22566. */
  22567. get inputTexture(): InternalTexture;
  22568. set inputTexture(value: InternalTexture);
  22569. /**
  22570. * Gets the camera which post process is applied to.
  22571. * @returns The camera the post process is applied to.
  22572. */
  22573. getCamera(): Camera;
  22574. /**
  22575. * Gets the texel size of the postprocess.
  22576. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22577. */
  22578. get texelSize(): Vector2;
  22579. /**
  22580. * Creates a new instance PostProcess
  22581. * @param name The name of the PostProcess.
  22582. * @param fragmentUrl The url of the fragment shader to be used.
  22583. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22584. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22585. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22586. * @param camera The camera to apply the render pass to.
  22587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22588. * @param engine The engine which the post process will be applied. (default: current engine)
  22589. * @param reusable If the post process can be reused on the same frame. (default: false)
  22590. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22591. * @param textureType Type of textures used when performing the post process. (default: 0)
  22592. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22593. * @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
  22594. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22595. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22596. */
  22597. constructor(
  22598. /** Name of the PostProcess. */
  22599. 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);
  22600. /**
  22601. * Gets a string idenfifying the name of the class
  22602. * @returns "PostProcess" string
  22603. */
  22604. getClassName(): string;
  22605. /**
  22606. * Gets the engine which this post process belongs to.
  22607. * @returns The engine the post process was enabled with.
  22608. */
  22609. getEngine(): Engine;
  22610. /**
  22611. * The effect that is created when initializing the post process.
  22612. * @returns The created effect corresponding the the postprocess.
  22613. */
  22614. getEffect(): Effect;
  22615. /**
  22616. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22617. * @param postProcess The post process to share the output with.
  22618. * @returns This post process.
  22619. */
  22620. shareOutputWith(postProcess: PostProcess): PostProcess;
  22621. /**
  22622. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22623. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22624. */
  22625. useOwnOutput(): void;
  22626. /**
  22627. * Updates the effect with the current post process compile time values and recompiles the shader.
  22628. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22629. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22630. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22631. * @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
  22632. * @param onCompiled Called when the shader has been compiled.
  22633. * @param onError Called if there is an error when compiling a shader.
  22634. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22635. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22636. */
  22637. 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;
  22638. /**
  22639. * The post process is reusable if it can be used multiple times within one frame.
  22640. * @returns If the post process is reusable
  22641. */
  22642. isReusable(): boolean;
  22643. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22644. markTextureDirty(): void;
  22645. /**
  22646. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22647. * 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.
  22648. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22649. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22650. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22651. * @returns The target texture that was bound to be written to.
  22652. */
  22653. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22654. /**
  22655. * If the post process is supported.
  22656. */
  22657. get isSupported(): boolean;
  22658. /**
  22659. * The aspect ratio of the output texture.
  22660. */
  22661. get aspectRatio(): number;
  22662. /**
  22663. * Get a value indicating if the post-process is ready to be used
  22664. * @returns true if the post-process is ready (shader is compiled)
  22665. */
  22666. isReady(): boolean;
  22667. /**
  22668. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22669. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22670. */
  22671. apply(): Nullable<Effect>;
  22672. private _disposeTextures;
  22673. /**
  22674. * Disposes the post process.
  22675. * @param camera The camera to dispose the post process on.
  22676. */
  22677. dispose(camera?: Camera): void;
  22678. }
  22679. }
  22680. declare module BABYLON {
  22681. /** @hidden */
  22682. export var kernelBlurVaryingDeclaration: {
  22683. name: string;
  22684. shader: string;
  22685. };
  22686. }
  22687. declare module BABYLON {
  22688. /** @hidden */
  22689. export var kernelBlurFragment: {
  22690. name: string;
  22691. shader: string;
  22692. };
  22693. }
  22694. declare module BABYLON {
  22695. /** @hidden */
  22696. export var kernelBlurFragment2: {
  22697. name: string;
  22698. shader: string;
  22699. };
  22700. }
  22701. declare module BABYLON {
  22702. /** @hidden */
  22703. export var kernelBlurPixelShader: {
  22704. name: string;
  22705. shader: string;
  22706. };
  22707. }
  22708. declare module BABYLON {
  22709. /** @hidden */
  22710. export var kernelBlurVertex: {
  22711. name: string;
  22712. shader: string;
  22713. };
  22714. }
  22715. declare module BABYLON {
  22716. /** @hidden */
  22717. export var kernelBlurVertexShader: {
  22718. name: string;
  22719. shader: string;
  22720. };
  22721. }
  22722. declare module BABYLON {
  22723. /**
  22724. * The Blur Post Process which blurs an image based on a kernel and direction.
  22725. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22726. */
  22727. export class BlurPostProcess extends PostProcess {
  22728. /** The direction in which to blur the image. */
  22729. direction: Vector2;
  22730. private blockCompilation;
  22731. protected _kernel: number;
  22732. protected _idealKernel: number;
  22733. protected _packedFloat: boolean;
  22734. private _staticDefines;
  22735. /**
  22736. * Sets the length in pixels of the blur sample region
  22737. */
  22738. set kernel(v: number);
  22739. /**
  22740. * Gets the length in pixels of the blur sample region
  22741. */
  22742. get kernel(): number;
  22743. /**
  22744. * Sets wether or not the blur needs to unpack/repack floats
  22745. */
  22746. set packedFloat(v: boolean);
  22747. /**
  22748. * Gets wether or not the blur is unpacking/repacking floats
  22749. */
  22750. get packedFloat(): boolean;
  22751. /**
  22752. * Creates a new instance BlurPostProcess
  22753. * @param name The name of the effect.
  22754. * @param direction The direction in which to blur the image.
  22755. * @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.
  22756. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22757. * @param camera The camera to apply the render pass to.
  22758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22759. * @param engine The engine which the post process will be applied. (default: current engine)
  22760. * @param reusable If the post process can be reused on the same frame. (default: false)
  22761. * @param textureType Type of textures used when performing the post process. (default: 0)
  22762. * @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)
  22763. */
  22764. constructor(name: string,
  22765. /** The direction in which to blur the image. */
  22766. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22767. /**
  22768. * Updates the effect with the current post process compile time values and recompiles the shader.
  22769. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22770. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22771. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22772. * @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
  22773. * @param onCompiled Called when the shader has been compiled.
  22774. * @param onError Called if there is an error when compiling a shader.
  22775. */
  22776. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22777. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22778. /**
  22779. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22780. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22781. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22782. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22783. * The gaps between physical kernels are compensated for in the weighting of the samples
  22784. * @param idealKernel Ideal blur kernel.
  22785. * @return Nearest best kernel.
  22786. */
  22787. protected _nearestBestKernel(idealKernel: number): number;
  22788. /**
  22789. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22790. * @param x The point on the Gaussian distribution to sample.
  22791. * @return the value of the Gaussian function at x.
  22792. */
  22793. protected _gaussianWeight(x: number): number;
  22794. /**
  22795. * Generates a string that can be used as a floating point number in GLSL.
  22796. * @param x Value to print.
  22797. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22798. * @return GLSL float string.
  22799. */
  22800. protected _glslFloat(x: number, decimalFigures?: number): string;
  22801. }
  22802. }
  22803. declare module BABYLON {
  22804. /**
  22805. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22806. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22807. * You can then easily use it as a reflectionTexture on a flat surface.
  22808. * In case the surface is not a plane, please consider relying on reflection probes.
  22809. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22810. */
  22811. export class MirrorTexture extends RenderTargetTexture {
  22812. private scene;
  22813. /**
  22814. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22815. * 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.
  22816. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22817. */
  22818. mirrorPlane: Plane;
  22819. /**
  22820. * Define the blur ratio used to blur the reflection if needed.
  22821. */
  22822. set blurRatio(value: number);
  22823. get blurRatio(): number;
  22824. /**
  22825. * Define the adaptive blur kernel used to blur the reflection if needed.
  22826. * This will autocompute the closest best match for the `blurKernel`
  22827. */
  22828. set adaptiveBlurKernel(value: number);
  22829. /**
  22830. * Define the blur kernel used to blur the reflection if needed.
  22831. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22832. */
  22833. set blurKernel(value: number);
  22834. /**
  22835. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22836. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22837. */
  22838. set blurKernelX(value: number);
  22839. get blurKernelX(): number;
  22840. /**
  22841. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22843. */
  22844. set blurKernelY(value: number);
  22845. get blurKernelY(): number;
  22846. private _autoComputeBlurKernel;
  22847. protected _onRatioRescale(): void;
  22848. private _updateGammaSpace;
  22849. private _imageProcessingConfigChangeObserver;
  22850. private _transformMatrix;
  22851. private _mirrorMatrix;
  22852. private _savedViewMatrix;
  22853. private _blurX;
  22854. private _blurY;
  22855. private _adaptiveBlurKernel;
  22856. private _blurKernelX;
  22857. private _blurKernelY;
  22858. private _blurRatio;
  22859. /**
  22860. * Instantiates a Mirror Texture.
  22861. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22862. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22863. * You can then easily use it as a reflectionTexture on a flat surface.
  22864. * In case the surface is not a plane, please consider relying on reflection probes.
  22865. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22866. * @param name
  22867. * @param size
  22868. * @param scene
  22869. * @param generateMipMaps
  22870. * @param type
  22871. * @param samplingMode
  22872. * @param generateDepthBuffer
  22873. */
  22874. constructor(name: string, size: number | {
  22875. width: number;
  22876. height: number;
  22877. } | {
  22878. ratio: number;
  22879. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22880. private _preparePostProcesses;
  22881. /**
  22882. * Clone the mirror texture.
  22883. * @returns the cloned texture
  22884. */
  22885. clone(): MirrorTexture;
  22886. /**
  22887. * Serialize the texture to a JSON representation you could use in Parse later on
  22888. * @returns the serialized JSON representation
  22889. */
  22890. serialize(): any;
  22891. /**
  22892. * Dispose the texture and release its associated resources.
  22893. */
  22894. dispose(): void;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /**
  22899. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22900. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22901. */
  22902. export class Texture extends BaseTexture {
  22903. /**
  22904. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22905. */
  22906. static SerializeBuffers: boolean;
  22907. /** @hidden */
  22908. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22909. /** @hidden */
  22910. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22911. /** @hidden */
  22912. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22913. /** nearest is mag = nearest and min = nearest and mip = linear */
  22914. static readonly NEAREST_SAMPLINGMODE: number;
  22915. /** nearest is mag = nearest and min = nearest and mip = linear */
  22916. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22917. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22918. static readonly BILINEAR_SAMPLINGMODE: number;
  22919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22920. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22921. /** Trilinear is mag = linear and min = linear and mip = linear */
  22922. static readonly TRILINEAR_SAMPLINGMODE: number;
  22923. /** Trilinear is mag = linear and min = linear and mip = linear */
  22924. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22925. /** mag = nearest and min = nearest and mip = nearest */
  22926. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22927. /** mag = nearest and min = linear and mip = nearest */
  22928. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22929. /** mag = nearest and min = linear and mip = linear */
  22930. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22931. /** mag = nearest and min = linear and mip = none */
  22932. static readonly NEAREST_LINEAR: number;
  22933. /** mag = nearest and min = nearest and mip = none */
  22934. static readonly NEAREST_NEAREST: number;
  22935. /** mag = linear and min = nearest and mip = nearest */
  22936. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22937. /** mag = linear and min = nearest and mip = linear */
  22938. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22939. /** mag = linear and min = linear and mip = none */
  22940. static readonly LINEAR_LINEAR: number;
  22941. /** mag = linear and min = nearest and mip = none */
  22942. static readonly LINEAR_NEAREST: number;
  22943. /** Explicit coordinates mode */
  22944. static readonly EXPLICIT_MODE: number;
  22945. /** Spherical coordinates mode */
  22946. static readonly SPHERICAL_MODE: number;
  22947. /** Planar coordinates mode */
  22948. static readonly PLANAR_MODE: number;
  22949. /** Cubic coordinates mode */
  22950. static readonly CUBIC_MODE: number;
  22951. /** Projection coordinates mode */
  22952. static readonly PROJECTION_MODE: number;
  22953. /** Inverse Cubic coordinates mode */
  22954. static readonly SKYBOX_MODE: number;
  22955. /** Inverse Cubic coordinates mode */
  22956. static readonly INVCUBIC_MODE: number;
  22957. /** Equirectangular coordinates mode */
  22958. static readonly EQUIRECTANGULAR_MODE: number;
  22959. /** Equirectangular Fixed coordinates mode */
  22960. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22961. /** Equirectangular Fixed Mirrored coordinates mode */
  22962. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22963. /** Texture is not repeating outside of 0..1 UVs */
  22964. static readonly CLAMP_ADDRESSMODE: number;
  22965. /** Texture is repeating outside of 0..1 UVs */
  22966. static readonly WRAP_ADDRESSMODE: number;
  22967. /** Texture is repeating and mirrored */
  22968. static readonly MIRROR_ADDRESSMODE: number;
  22969. /**
  22970. * 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
  22971. */
  22972. static UseSerializedUrlIfAny: boolean;
  22973. /**
  22974. * Define the url of the texture.
  22975. */
  22976. url: Nullable<string>;
  22977. /**
  22978. * Define an offset on the texture to offset the u coordinates of the UVs
  22979. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22980. */
  22981. uOffset: number;
  22982. /**
  22983. * Define an offset on the texture to offset the v coordinates of the UVs
  22984. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22985. */
  22986. vOffset: number;
  22987. /**
  22988. * Define an offset on the texture to scale the u coordinates of the UVs
  22989. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22990. */
  22991. uScale: number;
  22992. /**
  22993. * Define an offset on the texture to scale the v coordinates of the UVs
  22994. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22995. */
  22996. vScale: number;
  22997. /**
  22998. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22999. * @see http://doc.babylonjs.com/how_to/more_materials
  23000. */
  23001. uAng: number;
  23002. /**
  23003. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23004. * @see http://doc.babylonjs.com/how_to/more_materials
  23005. */
  23006. vAng: number;
  23007. /**
  23008. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23009. * @see http://doc.babylonjs.com/how_to/more_materials
  23010. */
  23011. wAng: number;
  23012. /**
  23013. * Defines the center of rotation (U)
  23014. */
  23015. uRotationCenter: number;
  23016. /**
  23017. * Defines the center of rotation (V)
  23018. */
  23019. vRotationCenter: number;
  23020. /**
  23021. * Defines the center of rotation (W)
  23022. */
  23023. wRotationCenter: number;
  23024. /**
  23025. * Are mip maps generated for this texture or not.
  23026. */
  23027. get noMipmap(): boolean;
  23028. /**
  23029. * List of inspectable custom properties (used by the Inspector)
  23030. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23031. */
  23032. inspectableCustomProperties: Nullable<IInspectable[]>;
  23033. private _noMipmap;
  23034. /** @hidden */
  23035. _invertY: boolean;
  23036. private _rowGenerationMatrix;
  23037. private _cachedTextureMatrix;
  23038. private _projectionModeMatrix;
  23039. private _t0;
  23040. private _t1;
  23041. private _t2;
  23042. private _cachedUOffset;
  23043. private _cachedVOffset;
  23044. private _cachedUScale;
  23045. private _cachedVScale;
  23046. private _cachedUAng;
  23047. private _cachedVAng;
  23048. private _cachedWAng;
  23049. private _cachedProjectionMatrixId;
  23050. private _cachedCoordinatesMode;
  23051. /** @hidden */
  23052. protected _initialSamplingMode: number;
  23053. /** @hidden */
  23054. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23055. private _deleteBuffer;
  23056. protected _format: Nullable<number>;
  23057. private _delayedOnLoad;
  23058. private _delayedOnError;
  23059. private _mimeType?;
  23060. /**
  23061. * Observable triggered once the texture has been loaded.
  23062. */
  23063. onLoadObservable: Observable<Texture>;
  23064. protected _isBlocking: boolean;
  23065. /**
  23066. * Is the texture preventing material to render while loading.
  23067. * If false, a default texture will be used instead of the loading one during the preparation step.
  23068. */
  23069. set isBlocking(value: boolean);
  23070. get isBlocking(): boolean;
  23071. /**
  23072. * Get the current sampling mode associated with the texture.
  23073. */
  23074. get samplingMode(): number;
  23075. /**
  23076. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23077. */
  23078. get invertY(): boolean;
  23079. /**
  23080. * Instantiates a new texture.
  23081. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23082. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23083. * @param url defines the url of the picture to load as a texture
  23084. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23085. * @param noMipmap defines if the texture will require mip maps or not
  23086. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23087. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23088. * @param onLoad defines a callback triggered when the texture has been loaded
  23089. * @param onError defines a callback triggered when an error occurred during the loading session
  23090. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23091. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23092. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23093. * @param mimeType defines an optional mime type information
  23094. */
  23095. 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);
  23096. /**
  23097. * Update the url (and optional buffer) of this texture if url was null during construction.
  23098. * @param url the url of the texture
  23099. * @param buffer the buffer of the texture (defaults to null)
  23100. * @param onLoad callback called when the texture is loaded (defaults to null)
  23101. */
  23102. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23103. /**
  23104. * Finish the loading sequence of a texture flagged as delayed load.
  23105. * @hidden
  23106. */
  23107. delayLoad(): void;
  23108. private _prepareRowForTextureGeneration;
  23109. /**
  23110. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23111. * @returns the transform matrix of the texture.
  23112. */
  23113. getTextureMatrix(uBase?: number): Matrix;
  23114. /**
  23115. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23116. * @returns The reflection texture transform
  23117. */
  23118. getReflectionTextureMatrix(): Matrix;
  23119. /**
  23120. * Clones the texture.
  23121. * @returns the cloned texture
  23122. */
  23123. clone(): Texture;
  23124. /**
  23125. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23126. * @returns The JSON representation of the texture
  23127. */
  23128. serialize(): any;
  23129. /**
  23130. * Get the current class name of the texture useful for serialization or dynamic coding.
  23131. * @returns "Texture"
  23132. */
  23133. getClassName(): string;
  23134. /**
  23135. * Dispose the texture and release its associated resources.
  23136. */
  23137. dispose(): void;
  23138. /**
  23139. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23140. * @param parsedTexture Define the JSON representation of the texture
  23141. * @param scene Define the scene the parsed texture should be instantiated in
  23142. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23143. * @returns The parsed texture if successful
  23144. */
  23145. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23146. /**
  23147. * Creates a texture from its base 64 representation.
  23148. * @param data Define the base64 payload without the data: prefix
  23149. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23150. * @param scene Define the scene the texture should belong to
  23151. * @param noMipmap Forces the texture to not create mip map information if true
  23152. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23153. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23154. * @param onLoad define a callback triggered when the texture has been loaded
  23155. * @param onError define a callback triggered when an error occurred during the loading session
  23156. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23157. * @returns the created texture
  23158. */
  23159. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23160. /**
  23161. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23162. * @param data Define the base64 payload without the data: prefix
  23163. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23164. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23165. * @param scene Define the scene the texture should belong to
  23166. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23167. * @param noMipmap Forces the texture to not create mip map information if true
  23168. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23169. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23170. * @param onLoad define a callback triggered when the texture has been loaded
  23171. * @param onError define a callback triggered when an error occurred during the loading session
  23172. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23173. * @returns the created texture
  23174. */
  23175. 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;
  23176. }
  23177. }
  23178. declare module BABYLON {
  23179. /**
  23180. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23181. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23182. */
  23183. export class PostProcessManager {
  23184. private _scene;
  23185. private _indexBuffer;
  23186. private _vertexBuffers;
  23187. /**
  23188. * Creates a new instance PostProcess
  23189. * @param scene The scene that the post process is associated with.
  23190. */
  23191. constructor(scene: Scene);
  23192. private _prepareBuffers;
  23193. private _buildIndexBuffer;
  23194. /**
  23195. * Rebuilds the vertex buffers of the manager.
  23196. * @hidden
  23197. */
  23198. _rebuild(): void;
  23199. /**
  23200. * Prepares a frame to be run through a post process.
  23201. * @param sourceTexture The input texture to the post procesess. (default: null)
  23202. * @param postProcesses An array of post processes to be run. (default: null)
  23203. * @returns True if the post processes were able to be run.
  23204. * @hidden
  23205. */
  23206. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23207. /**
  23208. * Manually render a set of post processes to a texture.
  23209. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23210. * @param postProcesses An array of post processes to be run.
  23211. * @param targetTexture The target texture to render to.
  23212. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23213. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23214. * @param lodLevel defines which lod of the texture to render to
  23215. */
  23216. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23217. /**
  23218. * Finalize the result of the output of the postprocesses.
  23219. * @param doNotPresent If true the result will not be displayed to the screen.
  23220. * @param targetTexture The target texture to render to.
  23221. * @param faceIndex The index of the face to bind the target texture to.
  23222. * @param postProcesses The array of post processes to render.
  23223. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23224. * @hidden
  23225. */
  23226. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23227. /**
  23228. * Disposes of the post process manager.
  23229. */
  23230. dispose(): void;
  23231. }
  23232. }
  23233. declare module BABYLON {
  23234. /**
  23235. * This Helps creating a texture that will be created from a camera in your scene.
  23236. * It is basically a dynamic texture that could be used to create special effects for instance.
  23237. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23238. */
  23239. export class RenderTargetTexture extends Texture {
  23240. isCube: boolean;
  23241. /**
  23242. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23243. */
  23244. static readonly REFRESHRATE_RENDER_ONCE: number;
  23245. /**
  23246. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23247. */
  23248. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23249. /**
  23250. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23251. * the central point of your effect and can save a lot of performances.
  23252. */
  23253. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23254. /**
  23255. * Use this predicate to dynamically define the list of mesh you want to render.
  23256. * If set, the renderList property will be overwritten.
  23257. */
  23258. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23259. private _renderList;
  23260. /**
  23261. * Use this list to define the list of mesh you want to render.
  23262. */
  23263. get renderList(): Nullable<Array<AbstractMesh>>;
  23264. set renderList(value: Nullable<Array<AbstractMesh>>);
  23265. /**
  23266. * Use this function to overload the renderList array at rendering time.
  23267. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23268. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23269. * the cube (if the RTT is a cube, else layerOrFace=0).
  23270. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23271. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23272. * hold dummy elements!
  23273. */
  23274. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23275. private _hookArray;
  23276. /**
  23277. * Define if particles should be rendered in your texture.
  23278. */
  23279. renderParticles: boolean;
  23280. /**
  23281. * Define if sprites should be rendered in your texture.
  23282. */
  23283. renderSprites: boolean;
  23284. /**
  23285. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23286. */
  23287. coordinatesMode: number;
  23288. /**
  23289. * Define the camera used to render the texture.
  23290. */
  23291. activeCamera: Nullable<Camera>;
  23292. /**
  23293. * Override the mesh isReady function with your own one.
  23294. */
  23295. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23296. /**
  23297. * Override the render function of the texture with your own one.
  23298. */
  23299. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23300. /**
  23301. * Define if camera post processes should be use while rendering the texture.
  23302. */
  23303. useCameraPostProcesses: boolean;
  23304. /**
  23305. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23306. */
  23307. ignoreCameraViewport: boolean;
  23308. private _postProcessManager;
  23309. private _postProcesses;
  23310. private _resizeObserver;
  23311. /**
  23312. * An event triggered when the texture is unbind.
  23313. */
  23314. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23315. /**
  23316. * An event triggered when the texture is unbind.
  23317. */
  23318. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23319. private _onAfterUnbindObserver;
  23320. /**
  23321. * Set a after unbind callback in the texture.
  23322. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23323. */
  23324. set onAfterUnbind(callback: () => void);
  23325. /**
  23326. * An event triggered before rendering the texture
  23327. */
  23328. onBeforeRenderObservable: Observable<number>;
  23329. private _onBeforeRenderObserver;
  23330. /**
  23331. * Set a before render callback in the texture.
  23332. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23333. */
  23334. set onBeforeRender(callback: (faceIndex: number) => void);
  23335. /**
  23336. * An event triggered after rendering the texture
  23337. */
  23338. onAfterRenderObservable: Observable<number>;
  23339. private _onAfterRenderObserver;
  23340. /**
  23341. * Set a after render callback in the texture.
  23342. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23343. */
  23344. set onAfterRender(callback: (faceIndex: number) => void);
  23345. /**
  23346. * An event triggered after the texture clear
  23347. */
  23348. onClearObservable: Observable<Engine>;
  23349. private _onClearObserver;
  23350. /**
  23351. * Set a clear callback in the texture.
  23352. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23353. */
  23354. set onClear(callback: (Engine: Engine) => void);
  23355. /**
  23356. * An event triggered when the texture is resized.
  23357. */
  23358. onResizeObservable: Observable<RenderTargetTexture>;
  23359. /**
  23360. * Define the clear color of the Render Target if it should be different from the scene.
  23361. */
  23362. clearColor: Color4;
  23363. protected _size: number | {
  23364. width: number;
  23365. height: number;
  23366. layers?: number;
  23367. };
  23368. protected _initialSizeParameter: number | {
  23369. width: number;
  23370. height: number;
  23371. } | {
  23372. ratio: number;
  23373. };
  23374. protected _sizeRatio: Nullable<number>;
  23375. /** @hidden */
  23376. _generateMipMaps: boolean;
  23377. protected _renderingManager: RenderingManager;
  23378. /** @hidden */
  23379. _waitingRenderList: string[];
  23380. protected _doNotChangeAspectRatio: boolean;
  23381. protected _currentRefreshId: number;
  23382. protected _refreshRate: number;
  23383. protected _textureMatrix: Matrix;
  23384. protected _samples: number;
  23385. protected _renderTargetOptions: RenderTargetCreationOptions;
  23386. /**
  23387. * Gets render target creation options that were used.
  23388. */
  23389. get renderTargetOptions(): RenderTargetCreationOptions;
  23390. protected _onRatioRescale(): void;
  23391. /**
  23392. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23393. * It must define where the camera used to render the texture is set
  23394. */
  23395. boundingBoxPosition: Vector3;
  23396. private _boundingBoxSize;
  23397. /**
  23398. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23399. * When defined, the cubemap will switch to local mode
  23400. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23401. * @example https://www.babylonjs-playground.com/#RNASML
  23402. */
  23403. set boundingBoxSize(value: Vector3);
  23404. get boundingBoxSize(): Vector3;
  23405. /**
  23406. * In case the RTT has been created with a depth texture, get the associated
  23407. * depth texture.
  23408. * Otherwise, return null.
  23409. */
  23410. get depthStencilTexture(): Nullable<InternalTexture>;
  23411. /**
  23412. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23413. * or used a shadow, depth texture...
  23414. * @param name The friendly name of the texture
  23415. * @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)
  23416. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23417. * @param generateMipMaps True if mip maps need to be generated after render.
  23418. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23419. * @param type The type of the buffer in the RTT (int, half float, float...)
  23420. * @param isCube True if a cube texture needs to be created
  23421. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23422. * @param generateDepthBuffer True to generate a depth buffer
  23423. * @param generateStencilBuffer True to generate a stencil buffer
  23424. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23425. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23426. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23427. */
  23428. constructor(name: string, size: number | {
  23429. width: number;
  23430. height: number;
  23431. layers?: number;
  23432. } | {
  23433. ratio: number;
  23434. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23435. /**
  23436. * Creates a depth stencil texture.
  23437. * This is only available in WebGL 2 or with the depth texture extension available.
  23438. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23439. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23440. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23441. */
  23442. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23443. private _processSizeParameter;
  23444. /**
  23445. * Define the number of samples to use in case of MSAA.
  23446. * It defaults to one meaning no MSAA has been enabled.
  23447. */
  23448. get samples(): number;
  23449. set samples(value: number);
  23450. /**
  23451. * Resets the refresh counter of the texture and start bak from scratch.
  23452. * Could be useful to regenerate the texture if it is setup to render only once.
  23453. */
  23454. resetRefreshCounter(): void;
  23455. /**
  23456. * Define the refresh rate of the texture or the rendering frequency.
  23457. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23458. */
  23459. get refreshRate(): number;
  23460. set refreshRate(value: number);
  23461. /**
  23462. * Adds a post process to the render target rendering passes.
  23463. * @param postProcess define the post process to add
  23464. */
  23465. addPostProcess(postProcess: PostProcess): void;
  23466. /**
  23467. * Clear all the post processes attached to the render target
  23468. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23469. */
  23470. clearPostProcesses(dispose?: boolean): void;
  23471. /**
  23472. * Remove one of the post process from the list of attached post processes to the texture
  23473. * @param postProcess define the post process to remove from the list
  23474. */
  23475. removePostProcess(postProcess: PostProcess): void;
  23476. /** @hidden */
  23477. _shouldRender(): boolean;
  23478. /**
  23479. * Gets the actual render size of the texture.
  23480. * @returns the width of the render size
  23481. */
  23482. getRenderSize(): number;
  23483. /**
  23484. * Gets the actual render width of the texture.
  23485. * @returns the width of the render size
  23486. */
  23487. getRenderWidth(): number;
  23488. /**
  23489. * Gets the actual render height of the texture.
  23490. * @returns the height of the render size
  23491. */
  23492. getRenderHeight(): number;
  23493. /**
  23494. * Gets the actual number of layers of the texture.
  23495. * @returns the number of layers
  23496. */
  23497. getRenderLayers(): number;
  23498. /**
  23499. * Get if the texture can be rescaled or not.
  23500. */
  23501. get canRescale(): boolean;
  23502. /**
  23503. * Resize the texture using a ratio.
  23504. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23505. */
  23506. scale(ratio: number): void;
  23507. /**
  23508. * Get the texture reflection matrix used to rotate/transform the reflection.
  23509. * @returns the reflection matrix
  23510. */
  23511. getReflectionTextureMatrix(): Matrix;
  23512. /**
  23513. * Resize the texture to a new desired size.
  23514. * Be carrefull as it will recreate all the data in the new texture.
  23515. * @param size Define the new size. It can be:
  23516. * - a number for squared texture,
  23517. * - an object containing { width: number, height: number }
  23518. * - or an object containing a ratio { ratio: number }
  23519. */
  23520. resize(size: number | {
  23521. width: number;
  23522. height: number;
  23523. } | {
  23524. ratio: number;
  23525. }): void;
  23526. private _defaultRenderListPrepared;
  23527. /**
  23528. * Renders all the objects from the render list into the texture.
  23529. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23530. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23531. */
  23532. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23533. private _bestReflectionRenderTargetDimension;
  23534. private _prepareRenderingManager;
  23535. /**
  23536. * @hidden
  23537. * @param faceIndex face index to bind to if this is a cubetexture
  23538. * @param layer defines the index of the texture to bind in the array
  23539. */
  23540. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23541. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23542. private renderToTarget;
  23543. /**
  23544. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23545. * This allowed control for front to back rendering or reversly depending of the special needs.
  23546. *
  23547. * @param renderingGroupId The rendering group id corresponding to its index
  23548. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23549. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23550. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23551. */
  23552. 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;
  23553. /**
  23554. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23555. *
  23556. * @param renderingGroupId The rendering group id corresponding to its index
  23557. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23558. */
  23559. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23560. /**
  23561. * Clones the texture.
  23562. * @returns the cloned texture
  23563. */
  23564. clone(): RenderTargetTexture;
  23565. /**
  23566. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23567. * @returns The JSON representation of the texture
  23568. */
  23569. serialize(): any;
  23570. /**
  23571. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23572. */
  23573. disposeFramebufferObjects(): void;
  23574. /**
  23575. * Dispose the texture and release its associated resources.
  23576. */
  23577. dispose(): void;
  23578. /** @hidden */
  23579. _rebuild(): void;
  23580. /**
  23581. * Clear the info related to rendering groups preventing retention point in material dispose.
  23582. */
  23583. freeRenderingGroups(): void;
  23584. /**
  23585. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23586. * @returns the view count
  23587. */
  23588. getViewCount(): number;
  23589. }
  23590. }
  23591. declare module BABYLON {
  23592. /**
  23593. * Class used to manipulate GUIDs
  23594. */
  23595. export class GUID {
  23596. /**
  23597. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23598. * Be aware Math.random() could cause collisions, but:
  23599. * "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"
  23600. * @returns a pseudo random id
  23601. */
  23602. static RandomId(): string;
  23603. }
  23604. }
  23605. declare module BABYLON {
  23606. /**
  23607. * Options to be used when creating a shadow depth material
  23608. */
  23609. export interface IIOptionShadowDepthMaterial {
  23610. /** Variables in the vertex shader code that need to have their names remapped.
  23611. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23612. * "var_name" should be either: worldPos or vNormalW
  23613. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23614. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23615. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23616. */
  23617. remappedVariables?: string[];
  23618. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23619. standalone?: boolean;
  23620. }
  23621. /**
  23622. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23623. */
  23624. export class ShadowDepthWrapper {
  23625. private _scene;
  23626. private _options?;
  23627. private _baseMaterial;
  23628. private _onEffectCreatedObserver;
  23629. private _subMeshToEffect;
  23630. private _subMeshToDepthEffect;
  23631. private _meshes;
  23632. /** @hidden */
  23633. _matriceNames: any;
  23634. /** Gets the standalone status of the wrapper */
  23635. get standalone(): boolean;
  23636. /** Gets the base material the wrapper is built upon */
  23637. get baseMaterial(): Material;
  23638. /**
  23639. * Instantiate a new shadow depth wrapper.
  23640. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23641. * generate the shadow depth map. For more information, please refer to the documentation:
  23642. * https://doc.babylonjs.com/babylon101/shadows
  23643. * @param baseMaterial Material to wrap
  23644. * @param scene Define the scene the material belongs to
  23645. * @param options Options used to create the wrapper
  23646. */
  23647. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23648. /**
  23649. * Gets the effect to use to generate the depth map
  23650. * @param subMesh subMesh to get the effect for
  23651. * @param shadowGenerator shadow generator to get the effect for
  23652. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23653. */
  23654. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23655. /**
  23656. * Specifies that the submesh is ready to be used for depth rendering
  23657. * @param subMesh submesh to check
  23658. * @param defines the list of defines to take into account when checking the effect
  23659. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23660. * @param useInstances specifies that instances should be used
  23661. * @returns a boolean indicating that the submesh is ready or not
  23662. */
  23663. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23664. /**
  23665. * Disposes the resources
  23666. */
  23667. dispose(): void;
  23668. private _makeEffect;
  23669. }
  23670. }
  23671. declare module BABYLON {
  23672. /**
  23673. * Options for compiling materials.
  23674. */
  23675. export interface IMaterialCompilationOptions {
  23676. /**
  23677. * Defines whether clip planes are enabled.
  23678. */
  23679. clipPlane: boolean;
  23680. /**
  23681. * Defines whether instances are enabled.
  23682. */
  23683. useInstances: boolean;
  23684. }
  23685. /**
  23686. * Options passed when calling customShaderNameResolve
  23687. */
  23688. export interface ICustomShaderNameResolveOptions {
  23689. /**
  23690. * 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
  23691. */
  23692. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23693. }
  23694. /**
  23695. * Base class for the main features of a material in Babylon.js
  23696. */
  23697. export class Material implements IAnimatable {
  23698. /**
  23699. * Returns the triangle fill mode
  23700. */
  23701. static readonly TriangleFillMode: number;
  23702. /**
  23703. * Returns the wireframe mode
  23704. */
  23705. static readonly WireFrameFillMode: number;
  23706. /**
  23707. * Returns the point fill mode
  23708. */
  23709. static readonly PointFillMode: number;
  23710. /**
  23711. * Returns the point list draw mode
  23712. */
  23713. static readonly PointListDrawMode: number;
  23714. /**
  23715. * Returns the line list draw mode
  23716. */
  23717. static readonly LineListDrawMode: number;
  23718. /**
  23719. * Returns the line loop draw mode
  23720. */
  23721. static readonly LineLoopDrawMode: number;
  23722. /**
  23723. * Returns the line strip draw mode
  23724. */
  23725. static readonly LineStripDrawMode: number;
  23726. /**
  23727. * Returns the triangle strip draw mode
  23728. */
  23729. static readonly TriangleStripDrawMode: number;
  23730. /**
  23731. * Returns the triangle fan draw mode
  23732. */
  23733. static readonly TriangleFanDrawMode: number;
  23734. /**
  23735. * Stores the clock-wise side orientation
  23736. */
  23737. static readonly ClockWiseSideOrientation: number;
  23738. /**
  23739. * Stores the counter clock-wise side orientation
  23740. */
  23741. static readonly CounterClockWiseSideOrientation: number;
  23742. /**
  23743. * The dirty texture flag value
  23744. */
  23745. static readonly TextureDirtyFlag: number;
  23746. /**
  23747. * The dirty light flag value
  23748. */
  23749. static readonly LightDirtyFlag: number;
  23750. /**
  23751. * The dirty fresnel flag value
  23752. */
  23753. static readonly FresnelDirtyFlag: number;
  23754. /**
  23755. * The dirty attribute flag value
  23756. */
  23757. static readonly AttributesDirtyFlag: number;
  23758. /**
  23759. * The dirty misc flag value
  23760. */
  23761. static readonly MiscDirtyFlag: number;
  23762. /**
  23763. * The all dirty flag value
  23764. */
  23765. static readonly AllDirtyFlag: number;
  23766. /**
  23767. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23768. */
  23769. static readonly MATERIAL_OPAQUE: number;
  23770. /**
  23771. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23772. */
  23773. static readonly MATERIAL_ALPHATEST: number;
  23774. /**
  23775. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23776. */
  23777. static readonly MATERIAL_ALPHABLEND: number;
  23778. /**
  23779. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23780. * They are also discarded below the alpha cutoff threshold to improve performances.
  23781. */
  23782. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23783. /**
  23784. * The Whiteout method is used to blend normals.
  23785. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23786. */
  23787. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23788. /**
  23789. * The Reoriented Normal Mapping method is used to blend normals.
  23790. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23791. */
  23792. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23793. /**
  23794. * Custom callback helping to override the default shader used in the material.
  23795. */
  23796. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23797. /**
  23798. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23799. */
  23800. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23801. /**
  23802. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23803. * This means that the material can keep using a previous shader while a new one is being compiled.
  23804. * This is mostly used when shader parallel compilation is supported (true by default)
  23805. */
  23806. allowShaderHotSwapping: boolean;
  23807. /**
  23808. * The ID of the material
  23809. */
  23810. id: string;
  23811. /**
  23812. * Gets or sets the unique id of the material
  23813. */
  23814. uniqueId: number;
  23815. /**
  23816. * The name of the material
  23817. */
  23818. name: string;
  23819. /**
  23820. * Gets or sets user defined metadata
  23821. */
  23822. metadata: any;
  23823. /**
  23824. * For internal use only. Please do not use.
  23825. */
  23826. reservedDataStore: any;
  23827. /**
  23828. * Specifies if the ready state should be checked on each call
  23829. */
  23830. checkReadyOnEveryCall: boolean;
  23831. /**
  23832. * Specifies if the ready state should be checked once
  23833. */
  23834. checkReadyOnlyOnce: boolean;
  23835. /**
  23836. * The state of the material
  23837. */
  23838. state: string;
  23839. /**
  23840. * The alpha value of the material
  23841. */
  23842. protected _alpha: number;
  23843. /**
  23844. * List of inspectable custom properties (used by the Inspector)
  23845. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23846. */
  23847. inspectableCustomProperties: IInspectable[];
  23848. /**
  23849. * Sets the alpha value of the material
  23850. */
  23851. set alpha(value: number);
  23852. /**
  23853. * Gets the alpha value of the material
  23854. */
  23855. get alpha(): number;
  23856. /**
  23857. * Specifies if back face culling is enabled
  23858. */
  23859. protected _backFaceCulling: boolean;
  23860. /**
  23861. * Sets the back-face culling state
  23862. */
  23863. set backFaceCulling(value: boolean);
  23864. /**
  23865. * Gets the back-face culling state
  23866. */
  23867. get backFaceCulling(): boolean;
  23868. /**
  23869. * Stores the value for side orientation
  23870. */
  23871. sideOrientation: number;
  23872. /**
  23873. * Callback triggered when the material is compiled
  23874. */
  23875. onCompiled: Nullable<(effect: Effect) => void>;
  23876. /**
  23877. * Callback triggered when an error occurs
  23878. */
  23879. onError: Nullable<(effect: Effect, errors: string) => void>;
  23880. /**
  23881. * Callback triggered to get the render target textures
  23882. */
  23883. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23884. /**
  23885. * Gets a boolean indicating that current material needs to register RTT
  23886. */
  23887. get hasRenderTargetTextures(): boolean;
  23888. /**
  23889. * Specifies if the material should be serialized
  23890. */
  23891. doNotSerialize: boolean;
  23892. /**
  23893. * @hidden
  23894. */
  23895. _storeEffectOnSubMeshes: boolean;
  23896. /**
  23897. * Stores the animations for the material
  23898. */
  23899. animations: Nullable<Array<Animation>>;
  23900. /**
  23901. * An event triggered when the material is disposed
  23902. */
  23903. onDisposeObservable: Observable<Material>;
  23904. /**
  23905. * An observer which watches for dispose events
  23906. */
  23907. private _onDisposeObserver;
  23908. private _onUnBindObservable;
  23909. /**
  23910. * Called during a dispose event
  23911. */
  23912. set onDispose(callback: () => void);
  23913. private _onBindObservable;
  23914. /**
  23915. * An event triggered when the material is bound
  23916. */
  23917. get onBindObservable(): Observable<AbstractMesh>;
  23918. /**
  23919. * An observer which watches for bind events
  23920. */
  23921. private _onBindObserver;
  23922. /**
  23923. * Called during a bind event
  23924. */
  23925. set onBind(callback: (Mesh: AbstractMesh) => void);
  23926. /**
  23927. * An event triggered when the material is unbound
  23928. */
  23929. get onUnBindObservable(): Observable<Material>;
  23930. protected _onEffectCreatedObservable: Nullable<Observable<{
  23931. effect: Effect;
  23932. subMesh: Nullable<SubMesh>;
  23933. }>>;
  23934. /**
  23935. * An event triggered when the effect is (re)created
  23936. */
  23937. get onEffectCreatedObservable(): Observable<{
  23938. effect: Effect;
  23939. subMesh: Nullable<SubMesh>;
  23940. }>;
  23941. /**
  23942. * Stores the value of the alpha mode
  23943. */
  23944. private _alphaMode;
  23945. /**
  23946. * Sets the value of the alpha mode.
  23947. *
  23948. * | Value | Type | Description |
  23949. * | --- | --- | --- |
  23950. * | 0 | ALPHA_DISABLE | |
  23951. * | 1 | ALPHA_ADD | |
  23952. * | 2 | ALPHA_COMBINE | |
  23953. * | 3 | ALPHA_SUBTRACT | |
  23954. * | 4 | ALPHA_MULTIPLY | |
  23955. * | 5 | ALPHA_MAXIMIZED | |
  23956. * | 6 | ALPHA_ONEONE | |
  23957. * | 7 | ALPHA_PREMULTIPLIED | |
  23958. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23959. * | 9 | ALPHA_INTERPOLATE | |
  23960. * | 10 | ALPHA_SCREENMODE | |
  23961. *
  23962. */
  23963. set alphaMode(value: number);
  23964. /**
  23965. * Gets the value of the alpha mode
  23966. */
  23967. get alphaMode(): number;
  23968. /**
  23969. * Stores the state of the need depth pre-pass value
  23970. */
  23971. private _needDepthPrePass;
  23972. /**
  23973. * Sets the need depth pre-pass value
  23974. */
  23975. set needDepthPrePass(value: boolean);
  23976. /**
  23977. * Gets the depth pre-pass value
  23978. */
  23979. get needDepthPrePass(): boolean;
  23980. /**
  23981. * Specifies if depth writing should be disabled
  23982. */
  23983. disableDepthWrite: boolean;
  23984. /**
  23985. * Specifies if color writing should be disabled
  23986. */
  23987. disableColorWrite: boolean;
  23988. /**
  23989. * Specifies if depth writing should be forced
  23990. */
  23991. forceDepthWrite: boolean;
  23992. /**
  23993. * Specifies the depth function that should be used. 0 means the default engine function
  23994. */
  23995. depthFunction: number;
  23996. /**
  23997. * Specifies if there should be a separate pass for culling
  23998. */
  23999. separateCullingPass: boolean;
  24000. /**
  24001. * Stores the state specifing if fog should be enabled
  24002. */
  24003. private _fogEnabled;
  24004. /**
  24005. * Sets the state for enabling fog
  24006. */
  24007. set fogEnabled(value: boolean);
  24008. /**
  24009. * Gets the value of the fog enabled state
  24010. */
  24011. get fogEnabled(): boolean;
  24012. /**
  24013. * Stores the size of points
  24014. */
  24015. pointSize: number;
  24016. /**
  24017. * Stores the z offset value
  24018. */
  24019. zOffset: number;
  24020. get wireframe(): boolean;
  24021. /**
  24022. * Sets the state of wireframe mode
  24023. */
  24024. set wireframe(value: boolean);
  24025. /**
  24026. * Gets the value specifying if point clouds are enabled
  24027. */
  24028. get pointsCloud(): boolean;
  24029. /**
  24030. * Sets the state of point cloud mode
  24031. */
  24032. set pointsCloud(value: boolean);
  24033. /**
  24034. * Gets the material fill mode
  24035. */
  24036. get fillMode(): number;
  24037. /**
  24038. * Sets the material fill mode
  24039. */
  24040. set fillMode(value: number);
  24041. /**
  24042. * @hidden
  24043. * Stores the effects for the material
  24044. */
  24045. _effect: Nullable<Effect>;
  24046. /**
  24047. * Specifies if uniform buffers should be used
  24048. */
  24049. private _useUBO;
  24050. /**
  24051. * Stores a reference to the scene
  24052. */
  24053. private _scene;
  24054. /**
  24055. * Stores the fill mode state
  24056. */
  24057. private _fillMode;
  24058. /**
  24059. * Specifies if the depth write state should be cached
  24060. */
  24061. private _cachedDepthWriteState;
  24062. /**
  24063. * Specifies if the color write state should be cached
  24064. */
  24065. private _cachedColorWriteState;
  24066. /**
  24067. * Specifies if the depth function state should be cached
  24068. */
  24069. private _cachedDepthFunctionState;
  24070. /**
  24071. * Stores the uniform buffer
  24072. */
  24073. protected _uniformBuffer: UniformBuffer;
  24074. /** @hidden */
  24075. _indexInSceneMaterialArray: number;
  24076. /** @hidden */
  24077. meshMap: Nullable<{
  24078. [id: string]: AbstractMesh | undefined;
  24079. }>;
  24080. /**
  24081. * Creates a material instance
  24082. * @param name defines the name of the material
  24083. * @param scene defines the scene to reference
  24084. * @param doNotAdd specifies if the material should be added to the scene
  24085. */
  24086. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24087. /**
  24088. * Returns a string representation of the current material
  24089. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24090. * @returns a string with material information
  24091. */
  24092. toString(fullDetails?: boolean): string;
  24093. /**
  24094. * Gets the class name of the material
  24095. * @returns a string with the class name of the material
  24096. */
  24097. getClassName(): string;
  24098. /**
  24099. * Specifies if updates for the material been locked
  24100. */
  24101. get isFrozen(): boolean;
  24102. /**
  24103. * Locks updates for the material
  24104. */
  24105. freeze(): void;
  24106. /**
  24107. * Unlocks updates for the material
  24108. */
  24109. unfreeze(): void;
  24110. /**
  24111. * Specifies if the material is ready to be used
  24112. * @param mesh defines the mesh to check
  24113. * @param useInstances specifies if instances should be used
  24114. * @returns a boolean indicating if the material is ready to be used
  24115. */
  24116. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24117. /**
  24118. * Specifies that the submesh is ready to be used
  24119. * @param mesh defines the mesh to check
  24120. * @param subMesh defines which submesh to check
  24121. * @param useInstances specifies that instances should be used
  24122. * @returns a boolean indicating that the submesh is ready or not
  24123. */
  24124. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24125. /**
  24126. * Returns the material effect
  24127. * @returns the effect associated with the material
  24128. */
  24129. getEffect(): Nullable<Effect>;
  24130. /**
  24131. * Returns the current scene
  24132. * @returns a Scene
  24133. */
  24134. getScene(): Scene;
  24135. /**
  24136. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24137. */
  24138. protected _forceAlphaTest: boolean;
  24139. /**
  24140. * The transparency mode of the material.
  24141. */
  24142. protected _transparencyMode: Nullable<number>;
  24143. /**
  24144. * Gets the current transparency mode.
  24145. */
  24146. get transparencyMode(): Nullable<number>;
  24147. /**
  24148. * Sets the transparency mode of the material.
  24149. *
  24150. * | Value | Type | Description |
  24151. * | ----- | ----------------------------------- | ----------- |
  24152. * | 0 | OPAQUE | |
  24153. * | 1 | ALPHATEST | |
  24154. * | 2 | ALPHABLEND | |
  24155. * | 3 | ALPHATESTANDBLEND | |
  24156. *
  24157. */
  24158. set transparencyMode(value: Nullable<number>);
  24159. /**
  24160. * Returns true if alpha blending should be disabled.
  24161. */
  24162. protected get _disableAlphaBlending(): boolean;
  24163. /**
  24164. * Specifies whether or not this material should be rendered in alpha blend mode.
  24165. * @returns a boolean specifying if alpha blending is needed
  24166. */
  24167. needAlphaBlending(): boolean;
  24168. /**
  24169. * Specifies if the mesh will require alpha blending
  24170. * @param mesh defines the mesh to check
  24171. * @returns a boolean specifying if alpha blending is needed for the mesh
  24172. */
  24173. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24174. /**
  24175. * Specifies whether or not this material should be rendered in alpha test mode.
  24176. * @returns a boolean specifying if an alpha test is needed.
  24177. */
  24178. needAlphaTesting(): boolean;
  24179. /**
  24180. * Specifies if material alpha testing should be turned on for the mesh
  24181. * @param mesh defines the mesh to check
  24182. */
  24183. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24184. /**
  24185. * Gets the texture used for the alpha test
  24186. * @returns the texture to use for alpha testing
  24187. */
  24188. getAlphaTestTexture(): Nullable<BaseTexture>;
  24189. /**
  24190. * Marks the material to indicate that it needs to be re-calculated
  24191. */
  24192. markDirty(): void;
  24193. /** @hidden */
  24194. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24195. /**
  24196. * Binds the material to the mesh
  24197. * @param world defines the world transformation matrix
  24198. * @param mesh defines the mesh to bind the material to
  24199. */
  24200. bind(world: Matrix, mesh?: Mesh): void;
  24201. /**
  24202. * Binds the submesh to the material
  24203. * @param world defines the world transformation matrix
  24204. * @param mesh defines the mesh containing the submesh
  24205. * @param subMesh defines the submesh to bind the material to
  24206. */
  24207. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24208. /**
  24209. * Binds the world matrix to the material
  24210. * @param world defines the world transformation matrix
  24211. */
  24212. bindOnlyWorldMatrix(world: Matrix): void;
  24213. /**
  24214. * Binds the scene's uniform buffer to the effect.
  24215. * @param effect defines the effect to bind to the scene uniform buffer
  24216. * @param sceneUbo defines the uniform buffer storing scene data
  24217. */
  24218. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24219. /**
  24220. * Binds the view matrix to the effect
  24221. * @param effect defines the effect to bind the view matrix to
  24222. */
  24223. bindView(effect: Effect): void;
  24224. /**
  24225. * Binds the view projection matrix to the effect
  24226. * @param effect defines the effect to bind the view projection matrix to
  24227. */
  24228. bindViewProjection(effect: Effect): void;
  24229. /**
  24230. * Processes to execute after binding the material to a mesh
  24231. * @param mesh defines the rendered mesh
  24232. */
  24233. protected _afterBind(mesh?: Mesh): void;
  24234. /**
  24235. * Unbinds the material from the mesh
  24236. */
  24237. unbind(): void;
  24238. /**
  24239. * Gets the active textures from the material
  24240. * @returns an array of textures
  24241. */
  24242. getActiveTextures(): BaseTexture[];
  24243. /**
  24244. * Specifies if the material uses a texture
  24245. * @param texture defines the texture to check against the material
  24246. * @returns a boolean specifying if the material uses the texture
  24247. */
  24248. hasTexture(texture: BaseTexture): boolean;
  24249. /**
  24250. * Makes a duplicate of the material, and gives it a new name
  24251. * @param name defines the new name for the duplicated material
  24252. * @returns the cloned material
  24253. */
  24254. clone(name: string): Nullable<Material>;
  24255. /**
  24256. * Gets the meshes bound to the material
  24257. * @returns an array of meshes bound to the material
  24258. */
  24259. getBindedMeshes(): AbstractMesh[];
  24260. /**
  24261. * Force shader compilation
  24262. * @param mesh defines the mesh associated with this material
  24263. * @param onCompiled defines a function to execute once the material is compiled
  24264. * @param options defines the options to configure the compilation
  24265. * @param onError defines a function to execute if the material fails compiling
  24266. */
  24267. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24268. /**
  24269. * Force shader compilation
  24270. * @param mesh defines the mesh that will use this material
  24271. * @param options defines additional options for compiling the shaders
  24272. * @returns a promise that resolves when the compilation completes
  24273. */
  24274. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24275. private static readonly _AllDirtyCallBack;
  24276. private static readonly _ImageProcessingDirtyCallBack;
  24277. private static readonly _TextureDirtyCallBack;
  24278. private static readonly _FresnelDirtyCallBack;
  24279. private static readonly _MiscDirtyCallBack;
  24280. private static readonly _LightsDirtyCallBack;
  24281. private static readonly _AttributeDirtyCallBack;
  24282. private static _FresnelAndMiscDirtyCallBack;
  24283. private static _TextureAndMiscDirtyCallBack;
  24284. private static readonly _DirtyCallbackArray;
  24285. private static readonly _RunDirtyCallBacks;
  24286. /**
  24287. * Marks a define in the material to indicate that it needs to be re-computed
  24288. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24289. */
  24290. markAsDirty(flag: number): void;
  24291. /**
  24292. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24293. * @param func defines a function which checks material defines against the submeshes
  24294. */
  24295. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24296. /**
  24297. * Indicates that we need to re-calculated for all submeshes
  24298. */
  24299. protected _markAllSubMeshesAsAllDirty(): void;
  24300. /**
  24301. * Indicates that image processing needs to be re-calculated for all submeshes
  24302. */
  24303. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24304. /**
  24305. * Indicates that textures need to be re-calculated for all submeshes
  24306. */
  24307. protected _markAllSubMeshesAsTexturesDirty(): void;
  24308. /**
  24309. * Indicates that fresnel needs to be re-calculated for all submeshes
  24310. */
  24311. protected _markAllSubMeshesAsFresnelDirty(): void;
  24312. /**
  24313. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24314. */
  24315. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24316. /**
  24317. * Indicates that lights need to be re-calculated for all submeshes
  24318. */
  24319. protected _markAllSubMeshesAsLightsDirty(): void;
  24320. /**
  24321. * Indicates that attributes need to be re-calculated for all submeshes
  24322. */
  24323. protected _markAllSubMeshesAsAttributesDirty(): void;
  24324. /**
  24325. * Indicates that misc needs to be re-calculated for all submeshes
  24326. */
  24327. protected _markAllSubMeshesAsMiscDirty(): void;
  24328. /**
  24329. * Indicates that textures and misc need to be re-calculated for all submeshes
  24330. */
  24331. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24332. /**
  24333. * Disposes the material
  24334. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24335. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24336. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24337. */
  24338. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24339. /** @hidden */
  24340. private releaseVertexArrayObject;
  24341. /**
  24342. * Serializes this material
  24343. * @returns the serialized material object
  24344. */
  24345. serialize(): any;
  24346. /**
  24347. * Creates a material from parsed material data
  24348. * @param parsedMaterial defines parsed material data
  24349. * @param scene defines the hosting scene
  24350. * @param rootUrl defines the root URL to use to load textures
  24351. * @returns a new material
  24352. */
  24353. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24354. }
  24355. }
  24356. declare module BABYLON {
  24357. /**
  24358. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24359. * separate meshes. This can be use to improve performances.
  24360. * @see http://doc.babylonjs.com/how_to/multi_materials
  24361. */
  24362. export class MultiMaterial extends Material {
  24363. private _subMaterials;
  24364. /**
  24365. * Gets or Sets the list of Materials used within the multi material.
  24366. * They need to be ordered according to the submeshes order in the associated mesh
  24367. */
  24368. get subMaterials(): Nullable<Material>[];
  24369. set subMaterials(value: Nullable<Material>[]);
  24370. /**
  24371. * Function used to align with Node.getChildren()
  24372. * @returns the list of Materials used within the multi material
  24373. */
  24374. getChildren(): Nullable<Material>[];
  24375. /**
  24376. * Instantiates a new Multi Material
  24377. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24378. * separate meshes. This can be use to improve performances.
  24379. * @see http://doc.babylonjs.com/how_to/multi_materials
  24380. * @param name Define the name in the scene
  24381. * @param scene Define the scene the material belongs to
  24382. */
  24383. constructor(name: string, scene: Scene);
  24384. private _hookArray;
  24385. /**
  24386. * Get one of the submaterial by its index in the submaterials array
  24387. * @param index The index to look the sub material at
  24388. * @returns The Material if the index has been defined
  24389. */
  24390. getSubMaterial(index: number): Nullable<Material>;
  24391. /**
  24392. * Get the list of active textures for the whole sub materials list.
  24393. * @returns All the textures that will be used during the rendering
  24394. */
  24395. getActiveTextures(): BaseTexture[];
  24396. /**
  24397. * Gets the current class name of the material e.g. "MultiMaterial"
  24398. * Mainly use in serialization.
  24399. * @returns the class name
  24400. */
  24401. getClassName(): string;
  24402. /**
  24403. * Checks if the material is ready to render the requested sub mesh
  24404. * @param mesh Define the mesh the submesh belongs to
  24405. * @param subMesh Define the sub mesh to look readyness for
  24406. * @param useInstances Define whether or not the material is used with instances
  24407. * @returns true if ready, otherwise false
  24408. */
  24409. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24410. /**
  24411. * Clones the current material and its related sub materials
  24412. * @param name Define the name of the newly cloned material
  24413. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24414. * @returns the cloned material
  24415. */
  24416. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24417. /**
  24418. * Serializes the materials into a JSON representation.
  24419. * @returns the JSON representation
  24420. */
  24421. serialize(): any;
  24422. /**
  24423. * Dispose the material and release its associated resources
  24424. * @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)
  24425. * @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)
  24426. * @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)
  24427. */
  24428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24429. /**
  24430. * Creates a MultiMaterial from parsed MultiMaterial data.
  24431. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24432. * @param scene defines the hosting scene
  24433. * @returns a new MultiMaterial
  24434. */
  24435. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24436. }
  24437. }
  24438. declare module BABYLON {
  24439. /**
  24440. * Defines a subdivision inside a mesh
  24441. */
  24442. export class SubMesh implements ICullable {
  24443. /** the material index to use */
  24444. materialIndex: number;
  24445. /** vertex index start */
  24446. verticesStart: number;
  24447. /** vertices count */
  24448. verticesCount: number;
  24449. /** index start */
  24450. indexStart: number;
  24451. /** indices count */
  24452. indexCount: number;
  24453. /** @hidden */
  24454. _materialDefines: Nullable<MaterialDefines>;
  24455. /** @hidden */
  24456. _materialEffect: Nullable<Effect>;
  24457. /** @hidden */
  24458. _effectOverride: Nullable<Effect>;
  24459. /**
  24460. * Gets material defines used by the effect associated to the sub mesh
  24461. */
  24462. get materialDefines(): Nullable<MaterialDefines>;
  24463. /**
  24464. * Sets material defines used by the effect associated to the sub mesh
  24465. */
  24466. set materialDefines(defines: Nullable<MaterialDefines>);
  24467. /**
  24468. * Gets associated effect
  24469. */
  24470. get effect(): Nullable<Effect>;
  24471. /**
  24472. * Sets associated effect (effect used to render this submesh)
  24473. * @param effect defines the effect to associate with
  24474. * @param defines defines the set of defines used to compile this effect
  24475. */
  24476. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24477. /** @hidden */
  24478. _linesIndexCount: number;
  24479. private _mesh;
  24480. private _renderingMesh;
  24481. private _boundingInfo;
  24482. private _linesIndexBuffer;
  24483. /** @hidden */
  24484. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24485. /** @hidden */
  24486. _trianglePlanes: Plane[];
  24487. /** @hidden */
  24488. _lastColliderTransformMatrix: Nullable<Matrix>;
  24489. /** @hidden */
  24490. _renderId: number;
  24491. /** @hidden */
  24492. _alphaIndex: number;
  24493. /** @hidden */
  24494. _distanceToCamera: number;
  24495. /** @hidden */
  24496. _id: number;
  24497. private _currentMaterial;
  24498. /**
  24499. * Add a new submesh to a mesh
  24500. * @param materialIndex defines the material index to use
  24501. * @param verticesStart defines vertex index start
  24502. * @param verticesCount defines vertices count
  24503. * @param indexStart defines index start
  24504. * @param indexCount defines indices count
  24505. * @param mesh defines the parent mesh
  24506. * @param renderingMesh defines an optional rendering mesh
  24507. * @param createBoundingBox defines if bounding box should be created for this submesh
  24508. * @returns the new submesh
  24509. */
  24510. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24511. /**
  24512. * Creates a new submesh
  24513. * @param materialIndex defines the material index to use
  24514. * @param verticesStart defines vertex index start
  24515. * @param verticesCount defines vertices count
  24516. * @param indexStart defines index start
  24517. * @param indexCount defines indices count
  24518. * @param mesh defines the parent mesh
  24519. * @param renderingMesh defines an optional rendering mesh
  24520. * @param createBoundingBox defines if bounding box should be created for this submesh
  24521. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24522. */
  24523. constructor(
  24524. /** the material index to use */
  24525. materialIndex: number,
  24526. /** vertex index start */
  24527. verticesStart: number,
  24528. /** vertices count */
  24529. verticesCount: number,
  24530. /** index start */
  24531. indexStart: number,
  24532. /** indices count */
  24533. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24534. /**
  24535. * Returns true if this submesh covers the entire parent mesh
  24536. * @ignorenaming
  24537. */
  24538. get IsGlobal(): boolean;
  24539. /**
  24540. * Returns the submesh BoudingInfo object
  24541. * @returns current bounding info (or mesh's one if the submesh is global)
  24542. */
  24543. getBoundingInfo(): BoundingInfo;
  24544. /**
  24545. * Sets the submesh BoundingInfo
  24546. * @param boundingInfo defines the new bounding info to use
  24547. * @returns the SubMesh
  24548. */
  24549. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24550. /**
  24551. * Returns the mesh of the current submesh
  24552. * @return the parent mesh
  24553. */
  24554. getMesh(): AbstractMesh;
  24555. /**
  24556. * Returns the rendering mesh of the submesh
  24557. * @returns the rendering mesh (could be different from parent mesh)
  24558. */
  24559. getRenderingMesh(): Mesh;
  24560. /**
  24561. * Returns the replacement mesh of the submesh
  24562. * @returns the replacement mesh (could be different from parent mesh)
  24563. */
  24564. getReplacementMesh(): Nullable<AbstractMesh>;
  24565. /**
  24566. * Returns the effective mesh of the submesh
  24567. * @returns the effective mesh (could be different from parent mesh)
  24568. */
  24569. getEffectiveMesh(): AbstractMesh;
  24570. /**
  24571. * Returns the submesh material
  24572. * @returns null or the current material
  24573. */
  24574. getMaterial(): Nullable<Material>;
  24575. /**
  24576. * Sets a new updated BoundingInfo object to the submesh
  24577. * @param data defines an optional position array to use to determine the bounding info
  24578. * @returns the SubMesh
  24579. */
  24580. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24581. /** @hidden */
  24582. _checkCollision(collider: Collider): boolean;
  24583. /**
  24584. * Updates the submesh BoundingInfo
  24585. * @param world defines the world matrix to use to update the bounding info
  24586. * @returns the submesh
  24587. */
  24588. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24589. /**
  24590. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24591. * @param frustumPlanes defines the frustum planes
  24592. * @returns true if the submesh is intersecting with the frustum
  24593. */
  24594. isInFrustum(frustumPlanes: Plane[]): boolean;
  24595. /**
  24596. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24597. * @param frustumPlanes defines the frustum planes
  24598. * @returns true if the submesh is inside the frustum
  24599. */
  24600. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24601. /**
  24602. * Renders the submesh
  24603. * @param enableAlphaMode defines if alpha needs to be used
  24604. * @returns the submesh
  24605. */
  24606. render(enableAlphaMode: boolean): SubMesh;
  24607. /**
  24608. * @hidden
  24609. */
  24610. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24611. /**
  24612. * Checks if the submesh intersects with a ray
  24613. * @param ray defines the ray to test
  24614. * @returns true is the passed ray intersects the submesh bounding box
  24615. */
  24616. canIntersects(ray: Ray): boolean;
  24617. /**
  24618. * Intersects current submesh with a ray
  24619. * @param ray defines the ray to test
  24620. * @param positions defines mesh's positions array
  24621. * @param indices defines mesh's indices array
  24622. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24623. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24624. * @returns intersection info or null if no intersection
  24625. */
  24626. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24627. /** @hidden */
  24628. private _intersectLines;
  24629. /** @hidden */
  24630. private _intersectUnIndexedLines;
  24631. /** @hidden */
  24632. private _intersectTriangles;
  24633. /** @hidden */
  24634. private _intersectUnIndexedTriangles;
  24635. /** @hidden */
  24636. _rebuild(): void;
  24637. /**
  24638. * Creates a new submesh from the passed mesh
  24639. * @param newMesh defines the new hosting mesh
  24640. * @param newRenderingMesh defines an optional rendering mesh
  24641. * @returns the new submesh
  24642. */
  24643. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24644. /**
  24645. * Release associated resources
  24646. */
  24647. dispose(): void;
  24648. /**
  24649. * Gets the class name
  24650. * @returns the string "SubMesh".
  24651. */
  24652. getClassName(): string;
  24653. /**
  24654. * Creates a new submesh from indices data
  24655. * @param materialIndex the index of the main mesh material
  24656. * @param startIndex the index where to start the copy in the mesh indices array
  24657. * @param indexCount the number of indices to copy then from the startIndex
  24658. * @param mesh the main mesh to create the submesh from
  24659. * @param renderingMesh the optional rendering mesh
  24660. * @returns a new submesh
  24661. */
  24662. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24663. }
  24664. }
  24665. declare module BABYLON {
  24666. /**
  24667. * Class used to represent data loading progression
  24668. */
  24669. export class SceneLoaderFlags {
  24670. private static _ForceFullSceneLoadingForIncremental;
  24671. private static _ShowLoadingScreen;
  24672. private static _CleanBoneMatrixWeights;
  24673. private static _loggingLevel;
  24674. /**
  24675. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24676. */
  24677. static get ForceFullSceneLoadingForIncremental(): boolean;
  24678. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24679. /**
  24680. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24681. */
  24682. static get ShowLoadingScreen(): boolean;
  24683. static set ShowLoadingScreen(value: boolean);
  24684. /**
  24685. * Defines the current logging level (while loading the scene)
  24686. * @ignorenaming
  24687. */
  24688. static get loggingLevel(): number;
  24689. static set loggingLevel(value: number);
  24690. /**
  24691. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24692. */
  24693. static get CleanBoneMatrixWeights(): boolean;
  24694. static set CleanBoneMatrixWeights(value: boolean);
  24695. }
  24696. }
  24697. declare module BABYLON {
  24698. /**
  24699. * Class used to store geometry data (vertex buffers + index buffer)
  24700. */
  24701. export class Geometry implements IGetSetVerticesData {
  24702. /**
  24703. * Gets or sets the ID of the geometry
  24704. */
  24705. id: string;
  24706. /**
  24707. * Gets or sets the unique ID of the geometry
  24708. */
  24709. uniqueId: number;
  24710. /**
  24711. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24712. */
  24713. delayLoadState: number;
  24714. /**
  24715. * Gets the file containing the data to load when running in delay load state
  24716. */
  24717. delayLoadingFile: Nullable<string>;
  24718. /**
  24719. * Callback called when the geometry is updated
  24720. */
  24721. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24722. private _scene;
  24723. private _engine;
  24724. private _meshes;
  24725. private _totalVertices;
  24726. /** @hidden */
  24727. _indices: IndicesArray;
  24728. /** @hidden */
  24729. _vertexBuffers: {
  24730. [key: string]: VertexBuffer;
  24731. };
  24732. private _isDisposed;
  24733. private _extend;
  24734. private _boundingBias;
  24735. /** @hidden */
  24736. _delayInfo: Array<string>;
  24737. private _indexBuffer;
  24738. private _indexBufferIsUpdatable;
  24739. /** @hidden */
  24740. _boundingInfo: Nullable<BoundingInfo>;
  24741. /** @hidden */
  24742. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24743. /** @hidden */
  24744. _softwareSkinningFrameId: number;
  24745. private _vertexArrayObjects;
  24746. private _updatable;
  24747. /** @hidden */
  24748. _positions: Nullable<Vector3[]>;
  24749. /**
  24750. * 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
  24751. */
  24752. get boundingBias(): Vector2;
  24753. /**
  24754. * 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
  24755. */
  24756. set boundingBias(value: Vector2);
  24757. /**
  24758. * Static function used to attach a new empty geometry to a mesh
  24759. * @param mesh defines the mesh to attach the geometry to
  24760. * @returns the new Geometry
  24761. */
  24762. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24763. /** Get the list of meshes using this geometry */
  24764. get meshes(): Mesh[];
  24765. /**
  24766. * Creates a new geometry
  24767. * @param id defines the unique ID
  24768. * @param scene defines the hosting scene
  24769. * @param vertexData defines the VertexData used to get geometry data
  24770. * @param updatable defines if geometry must be updatable (false by default)
  24771. * @param mesh defines the mesh that will be associated with the geometry
  24772. */
  24773. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24774. /**
  24775. * Gets the current extend of the geometry
  24776. */
  24777. get extend(): {
  24778. minimum: Vector3;
  24779. maximum: Vector3;
  24780. };
  24781. /**
  24782. * Gets the hosting scene
  24783. * @returns the hosting Scene
  24784. */
  24785. getScene(): Scene;
  24786. /**
  24787. * Gets the hosting engine
  24788. * @returns the hosting Engine
  24789. */
  24790. getEngine(): Engine;
  24791. /**
  24792. * Defines if the geometry is ready to use
  24793. * @returns true if the geometry is ready to be used
  24794. */
  24795. isReady(): boolean;
  24796. /**
  24797. * Gets a value indicating that the geometry should not be serialized
  24798. */
  24799. get doNotSerialize(): boolean;
  24800. /** @hidden */
  24801. _rebuild(): void;
  24802. /**
  24803. * Affects all geometry data in one call
  24804. * @param vertexData defines the geometry data
  24805. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24806. */
  24807. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24808. /**
  24809. * Set specific vertex data
  24810. * @param kind defines the data kind (Position, normal, etc...)
  24811. * @param data defines the vertex data to use
  24812. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24813. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24814. */
  24815. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24816. /**
  24817. * Removes a specific vertex data
  24818. * @param kind defines the data kind (Position, normal, etc...)
  24819. */
  24820. removeVerticesData(kind: string): void;
  24821. /**
  24822. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24823. * @param buffer defines the vertex buffer to use
  24824. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24825. */
  24826. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24827. /**
  24828. * Update a specific vertex buffer
  24829. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24830. * It will do nothing if the buffer is not updatable
  24831. * @param kind defines the data kind (Position, normal, etc...)
  24832. * @param data defines the data to use
  24833. * @param offset defines the offset in the target buffer where to store the data
  24834. * @param useBytes set to true if the offset is in bytes
  24835. */
  24836. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24837. /**
  24838. * Update a specific vertex buffer
  24839. * This function will create a new buffer if the current one is not updatable
  24840. * @param kind defines the data kind (Position, normal, etc...)
  24841. * @param data defines the data to use
  24842. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24843. */
  24844. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24845. private _updateBoundingInfo;
  24846. /** @hidden */
  24847. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24848. /**
  24849. * Gets total number of vertices
  24850. * @returns the total number of vertices
  24851. */
  24852. getTotalVertices(): number;
  24853. /**
  24854. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24855. * @param kind defines the data kind (Position, normal, etc...)
  24856. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24857. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24858. * @returns a float array containing vertex data
  24859. */
  24860. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24861. /**
  24862. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24863. * @param kind defines the data kind (Position, normal, etc...)
  24864. * @returns true if the vertex buffer with the specified kind is updatable
  24865. */
  24866. isVertexBufferUpdatable(kind: string): boolean;
  24867. /**
  24868. * Gets a specific vertex buffer
  24869. * @param kind defines the data kind (Position, normal, etc...)
  24870. * @returns a VertexBuffer
  24871. */
  24872. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24873. /**
  24874. * Returns all vertex buffers
  24875. * @return an object holding all vertex buffers indexed by kind
  24876. */
  24877. getVertexBuffers(): Nullable<{
  24878. [key: string]: VertexBuffer;
  24879. }>;
  24880. /**
  24881. * Gets a boolean indicating if specific vertex buffer is present
  24882. * @param kind defines the data kind (Position, normal, etc...)
  24883. * @returns true if data is present
  24884. */
  24885. isVerticesDataPresent(kind: string): boolean;
  24886. /**
  24887. * Gets a list of all attached data kinds (Position, normal, etc...)
  24888. * @returns a list of string containing all kinds
  24889. */
  24890. getVerticesDataKinds(): string[];
  24891. /**
  24892. * Update index buffer
  24893. * @param indices defines the indices to store in the index buffer
  24894. * @param offset defines the offset in the target buffer where to store the data
  24895. * @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)
  24896. */
  24897. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24898. /**
  24899. * Creates a new index buffer
  24900. * @param indices defines the indices to store in the index buffer
  24901. * @param totalVertices defines the total number of vertices (could be null)
  24902. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24903. */
  24904. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24905. /**
  24906. * Return the total number of indices
  24907. * @returns the total number of indices
  24908. */
  24909. getTotalIndices(): number;
  24910. /**
  24911. * Gets the index buffer array
  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 the index buffer array
  24915. */
  24916. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24917. /**
  24918. * Gets the index buffer
  24919. * @return the index buffer
  24920. */
  24921. getIndexBuffer(): Nullable<DataBuffer>;
  24922. /** @hidden */
  24923. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24924. /**
  24925. * Release the associated resources for a specific mesh
  24926. * @param mesh defines the source mesh
  24927. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24928. */
  24929. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24930. /**
  24931. * Apply current geometry to a given mesh
  24932. * @param mesh defines the mesh to apply geometry to
  24933. */
  24934. applyToMesh(mesh: Mesh): void;
  24935. private _updateExtend;
  24936. private _applyToMesh;
  24937. private notifyUpdate;
  24938. /**
  24939. * Load the geometry if it was flagged as delay loaded
  24940. * @param scene defines the hosting scene
  24941. * @param onLoaded defines a callback called when the geometry is loaded
  24942. */
  24943. load(scene: Scene, onLoaded?: () => void): void;
  24944. private _queueLoad;
  24945. /**
  24946. * Invert the geometry to move from a right handed system to a left handed one.
  24947. */
  24948. toLeftHanded(): void;
  24949. /** @hidden */
  24950. _resetPointsArrayCache(): void;
  24951. /** @hidden */
  24952. _generatePointsArray(): boolean;
  24953. /**
  24954. * Gets a value indicating if the geometry is disposed
  24955. * @returns true if the geometry was disposed
  24956. */
  24957. isDisposed(): boolean;
  24958. private _disposeVertexArrayObjects;
  24959. /**
  24960. * Free all associated resources
  24961. */
  24962. dispose(): void;
  24963. /**
  24964. * Clone the current geometry into a new geometry
  24965. * @param id defines the unique ID of the new geometry
  24966. * @returns a new geometry object
  24967. */
  24968. copy(id: string): Geometry;
  24969. /**
  24970. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24971. * @return a JSON representation of the current geometry data (without the vertices data)
  24972. */
  24973. serialize(): any;
  24974. private toNumberArray;
  24975. /**
  24976. * Serialize all vertices data into a JSON oject
  24977. * @returns a JSON representation of the current geometry data
  24978. */
  24979. serializeVerticeData(): any;
  24980. /**
  24981. * Extracts a clone of a mesh geometry
  24982. * @param mesh defines the source mesh
  24983. * @param id defines the unique ID of the new geometry object
  24984. * @returns the new geometry object
  24985. */
  24986. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24987. /**
  24988. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24989. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24990. * Be aware Math.random() could cause collisions, but:
  24991. * "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"
  24992. * @returns a string containing a new GUID
  24993. */
  24994. static RandomId(): string;
  24995. /** @hidden */
  24996. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24997. private static _CleanMatricesWeights;
  24998. /**
  24999. * Create a new geometry from persisted data (Using .babylon file format)
  25000. * @param parsedVertexData defines the persisted data
  25001. * @param scene defines the hosting scene
  25002. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25003. * @returns the new geometry object
  25004. */
  25005. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * Define an interface for all classes that will get and set the data on vertices
  25011. */
  25012. export interface IGetSetVerticesData {
  25013. /**
  25014. * Gets a boolean indicating if specific vertex data is present
  25015. * @param kind defines the vertex data kind to use
  25016. * @returns true is data kind is present
  25017. */
  25018. isVerticesDataPresent(kind: string): boolean;
  25019. /**
  25020. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25021. * @param kind defines the data kind (Position, normal, etc...)
  25022. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25023. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25024. * @returns a float array containing vertex data
  25025. */
  25026. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25027. /**
  25028. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25029. * @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.
  25030. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25031. * @returns the indices array or an empty array if the mesh has no geometry
  25032. */
  25033. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25034. /**
  25035. * Set specific vertex data
  25036. * @param kind defines the data kind (Position, normal, etc...)
  25037. * @param data defines the vertex data to use
  25038. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25039. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25040. */
  25041. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25042. /**
  25043. * Update a specific associated vertex buffer
  25044. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25045. * - VertexBuffer.PositionKind
  25046. * - VertexBuffer.UVKind
  25047. * - VertexBuffer.UV2Kind
  25048. * - VertexBuffer.UV3Kind
  25049. * - VertexBuffer.UV4Kind
  25050. * - VertexBuffer.UV5Kind
  25051. * - VertexBuffer.UV6Kind
  25052. * - VertexBuffer.ColorKind
  25053. * - VertexBuffer.MatricesIndicesKind
  25054. * - VertexBuffer.MatricesIndicesExtraKind
  25055. * - VertexBuffer.MatricesWeightsKind
  25056. * - VertexBuffer.MatricesWeightsExtraKind
  25057. * @param data defines the data source
  25058. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25059. * @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)
  25060. */
  25061. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25062. /**
  25063. * Creates a new index buffer
  25064. * @param indices defines the indices to store in the index buffer
  25065. * @param totalVertices defines the total number of vertices (could be null)
  25066. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25067. */
  25068. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25069. }
  25070. /**
  25071. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25072. */
  25073. export class VertexData {
  25074. /**
  25075. * Mesh side orientation : usually the external or front surface
  25076. */
  25077. static readonly FRONTSIDE: number;
  25078. /**
  25079. * Mesh side orientation : usually the internal or back surface
  25080. */
  25081. static readonly BACKSIDE: number;
  25082. /**
  25083. * Mesh side orientation : both internal and external or front and back surfaces
  25084. */
  25085. static readonly DOUBLESIDE: number;
  25086. /**
  25087. * Mesh side orientation : by default, `FRONTSIDE`
  25088. */
  25089. static readonly DEFAULTSIDE: number;
  25090. /**
  25091. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25092. */
  25093. positions: Nullable<FloatArray>;
  25094. /**
  25095. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25096. */
  25097. normals: Nullable<FloatArray>;
  25098. /**
  25099. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25100. */
  25101. tangents: Nullable<FloatArray>;
  25102. /**
  25103. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25104. */
  25105. uvs: Nullable<FloatArray>;
  25106. /**
  25107. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25108. */
  25109. uvs2: Nullable<FloatArray>;
  25110. /**
  25111. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25112. */
  25113. uvs3: Nullable<FloatArray>;
  25114. /**
  25115. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25116. */
  25117. uvs4: Nullable<FloatArray>;
  25118. /**
  25119. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25120. */
  25121. uvs5: Nullable<FloatArray>;
  25122. /**
  25123. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25124. */
  25125. uvs6: Nullable<FloatArray>;
  25126. /**
  25127. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25128. */
  25129. colors: Nullable<FloatArray>;
  25130. /**
  25131. * 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).
  25132. */
  25133. matricesIndices: Nullable<FloatArray>;
  25134. /**
  25135. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25136. */
  25137. matricesWeights: Nullable<FloatArray>;
  25138. /**
  25139. * An array extending the number of possible indices
  25140. */
  25141. matricesIndicesExtra: Nullable<FloatArray>;
  25142. /**
  25143. * An array extending the number of possible weights when the number of indices is extended
  25144. */
  25145. matricesWeightsExtra: Nullable<FloatArray>;
  25146. /**
  25147. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25148. */
  25149. indices: Nullable<IndicesArray>;
  25150. /**
  25151. * Uses the passed data array to set the set the values for the specified kind of data
  25152. * @param data a linear array of floating numbers
  25153. * @param kind the type of data that is being set, eg positions, colors etc
  25154. */
  25155. set(data: FloatArray, kind: string): void;
  25156. /**
  25157. * Associates the vertexData to the passed Mesh.
  25158. * Sets it as updatable or not (default `false`)
  25159. * @param mesh the mesh the vertexData is applied to
  25160. * @param updatable when used and having the value true allows new data to update the vertexData
  25161. * @returns the VertexData
  25162. */
  25163. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25164. /**
  25165. * Associates the vertexData to the passed Geometry.
  25166. * Sets it as updatable or not (default `false`)
  25167. * @param geometry the geometry the vertexData is applied to
  25168. * @param updatable when used and having the value true allows new data to update the vertexData
  25169. * @returns VertexData
  25170. */
  25171. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25172. /**
  25173. * Updates the associated mesh
  25174. * @param mesh the mesh to be updated
  25175. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25176. * @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
  25177. * @returns VertexData
  25178. */
  25179. updateMesh(mesh: Mesh): VertexData;
  25180. /**
  25181. * Updates the associated geometry
  25182. * @param geometry the geometry to be updated
  25183. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25184. * @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
  25185. * @returns VertexData.
  25186. */
  25187. updateGeometry(geometry: Geometry): VertexData;
  25188. private _applyTo;
  25189. private _update;
  25190. /**
  25191. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25192. * @param matrix the transforming matrix
  25193. * @returns the VertexData
  25194. */
  25195. transform(matrix: Matrix): VertexData;
  25196. /**
  25197. * Merges the passed VertexData into the current one
  25198. * @param other the VertexData to be merged into the current one
  25199. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25200. * @returns the modified VertexData
  25201. */
  25202. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25203. private _mergeElement;
  25204. private _validate;
  25205. /**
  25206. * Serializes the VertexData
  25207. * @returns a serialized object
  25208. */
  25209. serialize(): any;
  25210. /**
  25211. * Extracts the vertexData from a mesh
  25212. * @param mesh the mesh from which to extract the VertexData
  25213. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25214. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25215. * @returns the object VertexData associated to the passed mesh
  25216. */
  25217. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25218. /**
  25219. * Extracts the vertexData from the geometry
  25220. * @param geometry the geometry from which to extract the VertexData
  25221. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25222. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25223. * @returns the object VertexData associated to the passed mesh
  25224. */
  25225. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25226. private static _ExtractFrom;
  25227. /**
  25228. * Creates the VertexData for a Ribbon
  25229. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25230. * * pathArray array of paths, each of which an array of successive Vector3
  25231. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25232. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25233. * * 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
  25234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25235. * * 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)
  25236. * * 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)
  25237. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25238. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25239. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25240. * @returns the VertexData of the ribbon
  25241. */
  25242. static CreateRibbon(options: {
  25243. pathArray: Vector3[][];
  25244. closeArray?: boolean;
  25245. closePath?: boolean;
  25246. offset?: number;
  25247. sideOrientation?: number;
  25248. frontUVs?: Vector4;
  25249. backUVs?: Vector4;
  25250. invertUV?: boolean;
  25251. uvs?: Vector2[];
  25252. colors?: Color4[];
  25253. }): VertexData;
  25254. /**
  25255. * Creates the VertexData for a box
  25256. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25257. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25258. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25259. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25260. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25261. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25262. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25264. * * 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)
  25265. * * 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)
  25266. * @returns the VertexData of the box
  25267. */
  25268. static CreateBox(options: {
  25269. size?: number;
  25270. width?: number;
  25271. height?: number;
  25272. depth?: number;
  25273. faceUV?: Vector4[];
  25274. faceColors?: Color4[];
  25275. sideOrientation?: number;
  25276. frontUVs?: Vector4;
  25277. backUVs?: Vector4;
  25278. }): VertexData;
  25279. /**
  25280. * Creates the VertexData for a tiled box
  25281. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25282. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25283. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25284. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25286. * @returns the VertexData of the box
  25287. */
  25288. static CreateTiledBox(options: {
  25289. pattern?: number;
  25290. width?: number;
  25291. height?: number;
  25292. depth?: number;
  25293. tileSize?: number;
  25294. tileWidth?: number;
  25295. tileHeight?: number;
  25296. alignHorizontal?: number;
  25297. alignVertical?: number;
  25298. faceUV?: Vector4[];
  25299. faceColors?: Color4[];
  25300. sideOrientation?: number;
  25301. }): VertexData;
  25302. /**
  25303. * Creates the VertexData for a tiled plane
  25304. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25305. * * pattern a limited pattern arrangement depending on the number
  25306. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25307. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25308. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25310. * * 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)
  25311. * * 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)
  25312. * @returns the VertexData of the tiled plane
  25313. */
  25314. static CreateTiledPlane(options: {
  25315. pattern?: number;
  25316. tileSize?: number;
  25317. tileWidth?: number;
  25318. tileHeight?: number;
  25319. size?: number;
  25320. width?: number;
  25321. height?: number;
  25322. alignHorizontal?: number;
  25323. alignVertical?: number;
  25324. sideOrientation?: number;
  25325. frontUVs?: Vector4;
  25326. backUVs?: Vector4;
  25327. }): VertexData;
  25328. /**
  25329. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25330. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25331. * * segments sets the number of horizontal strips optional, default 32
  25332. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25333. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25334. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25335. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25336. * * 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
  25337. * * 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
  25338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25339. * * 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)
  25340. * * 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)
  25341. * @returns the VertexData of the ellipsoid
  25342. */
  25343. static CreateSphere(options: {
  25344. segments?: number;
  25345. diameter?: number;
  25346. diameterX?: number;
  25347. diameterY?: number;
  25348. diameterZ?: number;
  25349. arc?: number;
  25350. slice?: number;
  25351. sideOrientation?: number;
  25352. frontUVs?: Vector4;
  25353. backUVs?: Vector4;
  25354. }): VertexData;
  25355. /**
  25356. * Creates the VertexData for a cylinder, cone or prism
  25357. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25358. * * height sets the height (y direction) of the cylinder, optional, default 2
  25359. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25360. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25361. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25362. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25363. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25364. * * 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
  25365. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25366. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25367. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25368. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25370. * * 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)
  25371. * * 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)
  25372. * @returns the VertexData of the cylinder, cone or prism
  25373. */
  25374. static CreateCylinder(options: {
  25375. height?: number;
  25376. diameterTop?: number;
  25377. diameterBottom?: number;
  25378. diameter?: number;
  25379. tessellation?: number;
  25380. subdivisions?: number;
  25381. arc?: number;
  25382. faceColors?: Color4[];
  25383. faceUV?: Vector4[];
  25384. hasRings?: boolean;
  25385. enclose?: boolean;
  25386. sideOrientation?: number;
  25387. frontUVs?: Vector4;
  25388. backUVs?: Vector4;
  25389. }): VertexData;
  25390. /**
  25391. * Creates the VertexData for a torus
  25392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25393. * * diameter the diameter of the torus, optional default 1
  25394. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25395. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25397. * * 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)
  25398. * * 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)
  25399. * @returns the VertexData of the torus
  25400. */
  25401. static CreateTorus(options: {
  25402. diameter?: number;
  25403. thickness?: number;
  25404. tessellation?: number;
  25405. sideOrientation?: number;
  25406. frontUVs?: Vector4;
  25407. backUVs?: Vector4;
  25408. }): VertexData;
  25409. /**
  25410. * Creates the VertexData of the LineSystem
  25411. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25412. * - lines an array of lines, each line being an array of successive Vector3
  25413. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25414. * @returns the VertexData of the LineSystem
  25415. */
  25416. static CreateLineSystem(options: {
  25417. lines: Vector3[][];
  25418. colors?: Nullable<Color4[][]>;
  25419. }): VertexData;
  25420. /**
  25421. * Create the VertexData for a DashedLines
  25422. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25423. * - points an array successive Vector3
  25424. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25425. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25426. * - dashNb the intended total number of dashes, optional, default 200
  25427. * @returns the VertexData for the DashedLines
  25428. */
  25429. static CreateDashedLines(options: {
  25430. points: Vector3[];
  25431. dashSize?: number;
  25432. gapSize?: number;
  25433. dashNb?: number;
  25434. }): VertexData;
  25435. /**
  25436. * Creates the VertexData for a Ground
  25437. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25438. * - width the width (x direction) of the ground, optional, default 1
  25439. * - height the height (z direction) of the ground, optional, default 1
  25440. * - subdivisions the number of subdivisions per side, optional, default 1
  25441. * @returns the VertexData of the Ground
  25442. */
  25443. static CreateGround(options: {
  25444. width?: number;
  25445. height?: number;
  25446. subdivisions?: number;
  25447. subdivisionsX?: number;
  25448. subdivisionsY?: number;
  25449. }): VertexData;
  25450. /**
  25451. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25452. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25453. * * xmin the ground minimum X coordinate, optional, default -1
  25454. * * zmin the ground minimum Z coordinate, optional, default -1
  25455. * * xmax the ground maximum X coordinate, optional, default 1
  25456. * * zmax the ground maximum Z coordinate, optional, default 1
  25457. * * 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}
  25458. * * 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}
  25459. * @returns the VertexData of the TiledGround
  25460. */
  25461. static CreateTiledGround(options: {
  25462. xmin: number;
  25463. zmin: number;
  25464. xmax: number;
  25465. zmax: number;
  25466. subdivisions?: {
  25467. w: number;
  25468. h: number;
  25469. };
  25470. precision?: {
  25471. w: number;
  25472. h: number;
  25473. };
  25474. }): VertexData;
  25475. /**
  25476. * Creates the VertexData of the Ground designed from a heightmap
  25477. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25478. * * width the width (x direction) of the ground
  25479. * * height the height (z direction) of the ground
  25480. * * subdivisions the number of subdivisions per side
  25481. * * minHeight the minimum altitude on the ground, optional, default 0
  25482. * * maxHeight the maximum altitude on the ground, optional default 1
  25483. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25484. * * buffer the array holding the image color data
  25485. * * bufferWidth the width of image
  25486. * * bufferHeight the height of image
  25487. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25488. * @returns the VertexData of the Ground designed from a heightmap
  25489. */
  25490. static CreateGroundFromHeightMap(options: {
  25491. width: number;
  25492. height: number;
  25493. subdivisions: number;
  25494. minHeight: number;
  25495. maxHeight: number;
  25496. colorFilter: Color3;
  25497. buffer: Uint8Array;
  25498. bufferWidth: number;
  25499. bufferHeight: number;
  25500. alphaFilter: number;
  25501. }): VertexData;
  25502. /**
  25503. * Creates the VertexData for a Plane
  25504. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25505. * * size sets the width and height of the plane to the value of size, optional default 1
  25506. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25507. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25509. * * 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)
  25510. * * 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)
  25511. * @returns the VertexData of the box
  25512. */
  25513. static CreatePlane(options: {
  25514. size?: number;
  25515. width?: number;
  25516. height?: number;
  25517. sideOrientation?: number;
  25518. frontUVs?: Vector4;
  25519. backUVs?: Vector4;
  25520. }): VertexData;
  25521. /**
  25522. * Creates the VertexData of the Disc or regular Polygon
  25523. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25524. * * radius the radius of the disc, optional default 0.5
  25525. * * tessellation the number of polygon sides, optional, default 64
  25526. * * 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
  25527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25528. * * 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)
  25529. * * 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)
  25530. * @returns the VertexData of the box
  25531. */
  25532. static CreateDisc(options: {
  25533. radius?: number;
  25534. tessellation?: number;
  25535. arc?: number;
  25536. sideOrientation?: number;
  25537. frontUVs?: Vector4;
  25538. backUVs?: Vector4;
  25539. }): VertexData;
  25540. /**
  25541. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25542. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25543. * @param polygon a mesh built from polygonTriangulation.build()
  25544. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25545. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25546. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25547. * @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)
  25548. * @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)
  25549. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25550. * @returns the VertexData of the Polygon
  25551. */
  25552. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25553. /**
  25554. * Creates the VertexData of the IcoSphere
  25555. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25556. * * radius the radius of the IcoSphere, optional default 1
  25557. * * radiusX allows stretching in the x direction, optional, default radius
  25558. * * radiusY allows stretching in the y direction, optional, default radius
  25559. * * radiusZ allows stretching in the z direction, optional, default radius
  25560. * * flat when true creates a flat shaded mesh, optional, default true
  25561. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25562. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25563. * * 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)
  25564. * * 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)
  25565. * @returns the VertexData of the IcoSphere
  25566. */
  25567. static CreateIcoSphere(options: {
  25568. radius?: number;
  25569. radiusX?: number;
  25570. radiusY?: number;
  25571. radiusZ?: number;
  25572. flat?: boolean;
  25573. subdivisions?: number;
  25574. sideOrientation?: number;
  25575. frontUVs?: Vector4;
  25576. backUVs?: Vector4;
  25577. }): VertexData;
  25578. /**
  25579. * Creates the VertexData for a Polyhedron
  25580. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25581. * * type provided types are:
  25582. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25583. * * 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)
  25584. * * size the size of the IcoSphere, optional default 1
  25585. * * sizeX allows stretching in the x direction, optional, default size
  25586. * * sizeY allows stretching in the y direction, optional, default size
  25587. * * sizeZ allows stretching in the z direction, optional, default size
  25588. * * 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
  25589. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25590. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25591. * * flat when true creates a flat shaded mesh, optional, default true
  25592. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25594. * * 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)
  25595. * * 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)
  25596. * @returns the VertexData of the Polyhedron
  25597. */
  25598. static CreatePolyhedron(options: {
  25599. type?: number;
  25600. size?: number;
  25601. sizeX?: number;
  25602. sizeY?: number;
  25603. sizeZ?: number;
  25604. custom?: any;
  25605. faceUV?: Vector4[];
  25606. faceColors?: Color4[];
  25607. flat?: boolean;
  25608. sideOrientation?: number;
  25609. frontUVs?: Vector4;
  25610. backUVs?: Vector4;
  25611. }): VertexData;
  25612. /**
  25613. * Creates the VertexData for a TorusKnot
  25614. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25615. * * radius the radius of the torus knot, optional, default 2
  25616. * * tube the thickness of the tube, optional, default 0.5
  25617. * * radialSegments the number of sides on each tube segments, optional, default 32
  25618. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25619. * * p the number of windings around the z axis, optional, default 2
  25620. * * q the number of windings around the x axis, optional, default 3
  25621. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25622. * * 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)
  25623. * * 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)
  25624. * @returns the VertexData of the Torus Knot
  25625. */
  25626. static CreateTorusKnot(options: {
  25627. radius?: number;
  25628. tube?: number;
  25629. radialSegments?: number;
  25630. tubularSegments?: number;
  25631. p?: number;
  25632. q?: number;
  25633. sideOrientation?: number;
  25634. frontUVs?: Vector4;
  25635. backUVs?: Vector4;
  25636. }): VertexData;
  25637. /**
  25638. * Compute normals for given positions and indices
  25639. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25640. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25641. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25642. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25643. * * facetNormals : optional array of facet normals (vector3)
  25644. * * facetPositions : optional array of facet positions (vector3)
  25645. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25646. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25647. * * bInfo : optional bounding info, required for facetPartitioning computation
  25648. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25649. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25650. * * useRightHandedSystem: optional boolean to for right handed system computation
  25651. * * depthSort : optional boolean to enable the facet depth sort computation
  25652. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25653. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25654. */
  25655. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25656. facetNormals?: any;
  25657. facetPositions?: any;
  25658. facetPartitioning?: any;
  25659. ratio?: number;
  25660. bInfo?: any;
  25661. bbSize?: Vector3;
  25662. subDiv?: any;
  25663. useRightHandedSystem?: boolean;
  25664. depthSort?: boolean;
  25665. distanceTo?: Vector3;
  25666. depthSortedFacets?: any;
  25667. }): void;
  25668. /** @hidden */
  25669. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25670. /**
  25671. * Applies VertexData created from the imported parameters to the geometry
  25672. * @param parsedVertexData the parsed data from an imported file
  25673. * @param geometry the geometry to apply the VertexData to
  25674. */
  25675. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25676. }
  25677. }
  25678. declare module BABYLON {
  25679. /**
  25680. * Defines a target to use with MorphTargetManager
  25681. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25682. */
  25683. export class MorphTarget implements IAnimatable {
  25684. /** defines the name of the target */
  25685. name: string;
  25686. /**
  25687. * Gets or sets the list of animations
  25688. */
  25689. animations: Animation[];
  25690. private _scene;
  25691. private _positions;
  25692. private _normals;
  25693. private _tangents;
  25694. private _uvs;
  25695. private _influence;
  25696. private _uniqueId;
  25697. /**
  25698. * Observable raised when the influence changes
  25699. */
  25700. onInfluenceChanged: Observable<boolean>;
  25701. /** @hidden */
  25702. _onDataLayoutChanged: Observable<void>;
  25703. /**
  25704. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25705. */
  25706. get influence(): number;
  25707. set influence(influence: number);
  25708. /**
  25709. * Gets or sets the id of the morph Target
  25710. */
  25711. id: string;
  25712. private _animationPropertiesOverride;
  25713. /**
  25714. * Gets or sets the animation properties override
  25715. */
  25716. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25717. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25718. /**
  25719. * Creates a new MorphTarget
  25720. * @param name defines the name of the target
  25721. * @param influence defines the influence to use
  25722. * @param scene defines the scene the morphtarget belongs to
  25723. */
  25724. constructor(
  25725. /** defines the name of the target */
  25726. name: string, influence?: number, scene?: Nullable<Scene>);
  25727. /**
  25728. * Gets the unique ID of this manager
  25729. */
  25730. get uniqueId(): number;
  25731. /**
  25732. * Gets a boolean defining if the target contains position data
  25733. */
  25734. get hasPositions(): boolean;
  25735. /**
  25736. * Gets a boolean defining if the target contains normal data
  25737. */
  25738. get hasNormals(): boolean;
  25739. /**
  25740. * Gets a boolean defining if the target contains tangent data
  25741. */
  25742. get hasTangents(): boolean;
  25743. /**
  25744. * Gets a boolean defining if the target contains texture coordinates data
  25745. */
  25746. get hasUVs(): boolean;
  25747. /**
  25748. * Affects position data to this target
  25749. * @param data defines the position data to use
  25750. */
  25751. setPositions(data: Nullable<FloatArray>): void;
  25752. /**
  25753. * Gets the position data stored in this target
  25754. * @returns a FloatArray containing the position data (or null if not present)
  25755. */
  25756. getPositions(): Nullable<FloatArray>;
  25757. /**
  25758. * Affects normal data to this target
  25759. * @param data defines the normal data to use
  25760. */
  25761. setNormals(data: Nullable<FloatArray>): void;
  25762. /**
  25763. * Gets the normal data stored in this target
  25764. * @returns a FloatArray containing the normal data (or null if not present)
  25765. */
  25766. getNormals(): Nullable<FloatArray>;
  25767. /**
  25768. * Affects tangent data to this target
  25769. * @param data defines the tangent data to use
  25770. */
  25771. setTangents(data: Nullable<FloatArray>): void;
  25772. /**
  25773. * Gets the tangent data stored in this target
  25774. * @returns a FloatArray containing the tangent data (or null if not present)
  25775. */
  25776. getTangents(): Nullable<FloatArray>;
  25777. /**
  25778. * Affects texture coordinates data to this target
  25779. * @param data defines the texture coordinates data to use
  25780. */
  25781. setUVs(data: Nullable<FloatArray>): void;
  25782. /**
  25783. * Gets the texture coordinates data stored in this target
  25784. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25785. */
  25786. getUVs(): Nullable<FloatArray>;
  25787. /**
  25788. * Clone the current target
  25789. * @returns a new MorphTarget
  25790. */
  25791. clone(): MorphTarget;
  25792. /**
  25793. * Serializes the current target into a Serialization object
  25794. * @returns the serialized object
  25795. */
  25796. serialize(): any;
  25797. /**
  25798. * Returns the string "MorphTarget"
  25799. * @returns "MorphTarget"
  25800. */
  25801. getClassName(): string;
  25802. /**
  25803. * Creates a new target from serialized data
  25804. * @param serializationObject defines the serialized data to use
  25805. * @returns a new MorphTarget
  25806. */
  25807. static Parse(serializationObject: any): MorphTarget;
  25808. /**
  25809. * Creates a MorphTarget from mesh data
  25810. * @param mesh defines the source mesh
  25811. * @param name defines the name to use for the new target
  25812. * @param influence defines the influence to attach to the target
  25813. * @returns a new MorphTarget
  25814. */
  25815. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25816. }
  25817. }
  25818. declare module BABYLON {
  25819. /**
  25820. * This class is used to deform meshes using morphing between different targets
  25821. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25822. */
  25823. export class MorphTargetManager {
  25824. private _targets;
  25825. private _targetInfluenceChangedObservers;
  25826. private _targetDataLayoutChangedObservers;
  25827. private _activeTargets;
  25828. private _scene;
  25829. private _influences;
  25830. private _supportsNormals;
  25831. private _supportsTangents;
  25832. private _supportsUVs;
  25833. private _vertexCount;
  25834. private _uniqueId;
  25835. private _tempInfluences;
  25836. /**
  25837. * Gets or sets a boolean indicating if normals must be morphed
  25838. */
  25839. enableNormalMorphing: boolean;
  25840. /**
  25841. * Gets or sets a boolean indicating if tangents must be morphed
  25842. */
  25843. enableTangentMorphing: boolean;
  25844. /**
  25845. * Gets or sets a boolean indicating if UV must be morphed
  25846. */
  25847. enableUVMorphing: boolean;
  25848. /**
  25849. * Creates a new MorphTargetManager
  25850. * @param scene defines the current scene
  25851. */
  25852. constructor(scene?: Nullable<Scene>);
  25853. /**
  25854. * Gets the unique ID of this manager
  25855. */
  25856. get uniqueId(): number;
  25857. /**
  25858. * Gets the number of vertices handled by this manager
  25859. */
  25860. get vertexCount(): number;
  25861. /**
  25862. * Gets a boolean indicating if this manager supports morphing of normals
  25863. */
  25864. get supportsNormals(): boolean;
  25865. /**
  25866. * Gets a boolean indicating if this manager supports morphing of tangents
  25867. */
  25868. get supportsTangents(): boolean;
  25869. /**
  25870. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25871. */
  25872. get supportsUVs(): boolean;
  25873. /**
  25874. * Gets the number of targets stored in this manager
  25875. */
  25876. get numTargets(): number;
  25877. /**
  25878. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25879. */
  25880. get numInfluencers(): number;
  25881. /**
  25882. * Gets the list of influences (one per target)
  25883. */
  25884. get influences(): Float32Array;
  25885. /**
  25886. * Gets the active target at specified index. An active target is a target with an influence > 0
  25887. * @param index defines the index to check
  25888. * @returns the requested target
  25889. */
  25890. getActiveTarget(index: number): MorphTarget;
  25891. /**
  25892. * Gets the target at specified index
  25893. * @param index defines the index to check
  25894. * @returns the requested target
  25895. */
  25896. getTarget(index: number): MorphTarget;
  25897. /**
  25898. * Add a new target to this manager
  25899. * @param target defines the target to add
  25900. */
  25901. addTarget(target: MorphTarget): void;
  25902. /**
  25903. * Removes a target from the manager
  25904. * @param target defines the target to remove
  25905. */
  25906. removeTarget(target: MorphTarget): void;
  25907. /**
  25908. * Clone the current manager
  25909. * @returns a new MorphTargetManager
  25910. */
  25911. clone(): MorphTargetManager;
  25912. /**
  25913. * Serializes the current manager into a Serialization object
  25914. * @returns the serialized object
  25915. */
  25916. serialize(): any;
  25917. private _syncActiveTargets;
  25918. /**
  25919. * Syncrhonize the targets with all the meshes using this morph target manager
  25920. */
  25921. synchronize(): void;
  25922. /**
  25923. * Creates a new MorphTargetManager from serialized data
  25924. * @param serializationObject defines the serialized data
  25925. * @param scene defines the hosting scene
  25926. * @returns the new MorphTargetManager
  25927. */
  25928. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25929. }
  25930. }
  25931. declare module BABYLON {
  25932. /**
  25933. * Class used to represent a specific level of detail of a mesh
  25934. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25935. */
  25936. export class MeshLODLevel {
  25937. /** Defines the distance where this level should start being displayed */
  25938. distance: number;
  25939. /** Defines the mesh to use to render this level */
  25940. mesh: Nullable<Mesh>;
  25941. /**
  25942. * Creates a new LOD level
  25943. * @param distance defines the distance where this level should star being displayed
  25944. * @param mesh defines the mesh to use to render this level
  25945. */
  25946. constructor(
  25947. /** Defines the distance where this level should start being displayed */
  25948. distance: number,
  25949. /** Defines the mesh to use to render this level */
  25950. mesh: Nullable<Mesh>);
  25951. }
  25952. }
  25953. declare module BABYLON {
  25954. /**
  25955. * Mesh representing the gorund
  25956. */
  25957. export class GroundMesh extends Mesh {
  25958. /** If octree should be generated */
  25959. generateOctree: boolean;
  25960. private _heightQuads;
  25961. /** @hidden */
  25962. _subdivisionsX: number;
  25963. /** @hidden */
  25964. _subdivisionsY: number;
  25965. /** @hidden */
  25966. _width: number;
  25967. /** @hidden */
  25968. _height: number;
  25969. /** @hidden */
  25970. _minX: number;
  25971. /** @hidden */
  25972. _maxX: number;
  25973. /** @hidden */
  25974. _minZ: number;
  25975. /** @hidden */
  25976. _maxZ: number;
  25977. constructor(name: string, scene: Scene);
  25978. /**
  25979. * "GroundMesh"
  25980. * @returns "GroundMesh"
  25981. */
  25982. getClassName(): string;
  25983. /**
  25984. * The minimum of x and y subdivisions
  25985. */
  25986. get subdivisions(): number;
  25987. /**
  25988. * X subdivisions
  25989. */
  25990. get subdivisionsX(): number;
  25991. /**
  25992. * Y subdivisions
  25993. */
  25994. get subdivisionsY(): number;
  25995. /**
  25996. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25997. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25998. * @param chunksCount the number of subdivisions for x and y
  25999. * @param octreeBlocksSize (Default: 32)
  26000. */
  26001. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26002. /**
  26003. * Returns a height (y) value in the Worl system :
  26004. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26005. * @param x x coordinate
  26006. * @param z z coordinate
  26007. * @returns the ground y position if (x, z) are outside the ground surface.
  26008. */
  26009. getHeightAtCoordinates(x: number, z: number): number;
  26010. /**
  26011. * Returns a normalized vector (Vector3) orthogonal to the ground
  26012. * at the ground coordinates (x, z) expressed in the World system.
  26013. * @param x x coordinate
  26014. * @param z z coordinate
  26015. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26016. */
  26017. getNormalAtCoordinates(x: number, z: number): Vector3;
  26018. /**
  26019. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26020. * at the ground coordinates (x, z) expressed in the World system.
  26021. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26022. * @param x x coordinate
  26023. * @param z z coordinate
  26024. * @param ref vector to store the result
  26025. * @returns the GroundMesh.
  26026. */
  26027. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26028. /**
  26029. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26030. * if the ground has been updated.
  26031. * This can be used in the render loop.
  26032. * @returns the GroundMesh.
  26033. */
  26034. updateCoordinateHeights(): GroundMesh;
  26035. private _getFacetAt;
  26036. private _initHeightQuads;
  26037. private _computeHeightQuads;
  26038. /**
  26039. * Serializes this ground mesh
  26040. * @param serializationObject object to write serialization to
  26041. */
  26042. serialize(serializationObject: any): void;
  26043. /**
  26044. * Parses a serialized ground mesh
  26045. * @param parsedMesh the serialized mesh
  26046. * @param scene the scene to create the ground mesh in
  26047. * @returns the created ground mesh
  26048. */
  26049. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26050. }
  26051. }
  26052. declare module BABYLON {
  26053. /**
  26054. * Interface for Physics-Joint data
  26055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26056. */
  26057. export interface PhysicsJointData {
  26058. /**
  26059. * The main pivot of the joint
  26060. */
  26061. mainPivot?: Vector3;
  26062. /**
  26063. * The connected pivot of the joint
  26064. */
  26065. connectedPivot?: Vector3;
  26066. /**
  26067. * The main axis of the joint
  26068. */
  26069. mainAxis?: Vector3;
  26070. /**
  26071. * The connected axis of the joint
  26072. */
  26073. connectedAxis?: Vector3;
  26074. /**
  26075. * The collision of the joint
  26076. */
  26077. collision?: boolean;
  26078. /**
  26079. * Native Oimo/Cannon/Energy data
  26080. */
  26081. nativeParams?: any;
  26082. }
  26083. /**
  26084. * This is a holder class for the physics joint created by the physics plugin
  26085. * It holds a set of functions to control the underlying joint
  26086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26087. */
  26088. export class PhysicsJoint {
  26089. /**
  26090. * The type of the physics joint
  26091. */
  26092. type: number;
  26093. /**
  26094. * The data for the physics joint
  26095. */
  26096. jointData: PhysicsJointData;
  26097. private _physicsJoint;
  26098. protected _physicsPlugin: IPhysicsEnginePlugin;
  26099. /**
  26100. * Initializes the physics joint
  26101. * @param type The type of the physics joint
  26102. * @param jointData The data for the physics joint
  26103. */
  26104. constructor(
  26105. /**
  26106. * The type of the physics joint
  26107. */
  26108. type: number,
  26109. /**
  26110. * The data for the physics joint
  26111. */
  26112. jointData: PhysicsJointData);
  26113. /**
  26114. * Gets the physics joint
  26115. */
  26116. get physicsJoint(): any;
  26117. /**
  26118. * Sets the physics joint
  26119. */
  26120. set physicsJoint(newJoint: any);
  26121. /**
  26122. * Sets the physics plugin
  26123. */
  26124. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26125. /**
  26126. * Execute a function that is physics-plugin specific.
  26127. * @param {Function} func the function that will be executed.
  26128. * It accepts two parameters: the physics world and the physics joint
  26129. */
  26130. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26131. /**
  26132. * Distance-Joint type
  26133. */
  26134. static DistanceJoint: number;
  26135. /**
  26136. * Hinge-Joint type
  26137. */
  26138. static HingeJoint: number;
  26139. /**
  26140. * Ball-and-Socket joint type
  26141. */
  26142. static BallAndSocketJoint: number;
  26143. /**
  26144. * Wheel-Joint type
  26145. */
  26146. static WheelJoint: number;
  26147. /**
  26148. * Slider-Joint type
  26149. */
  26150. static SliderJoint: number;
  26151. /**
  26152. * Prismatic-Joint type
  26153. */
  26154. static PrismaticJoint: number;
  26155. /**
  26156. * Universal-Joint type
  26157. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26158. */
  26159. static UniversalJoint: number;
  26160. /**
  26161. * Hinge-Joint 2 type
  26162. */
  26163. static Hinge2Joint: number;
  26164. /**
  26165. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26166. */
  26167. static PointToPointJoint: number;
  26168. /**
  26169. * Spring-Joint type
  26170. */
  26171. static SpringJoint: number;
  26172. /**
  26173. * Lock-Joint type
  26174. */
  26175. static LockJoint: number;
  26176. }
  26177. /**
  26178. * A class representing a physics distance joint
  26179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26180. */
  26181. export class DistanceJoint extends PhysicsJoint {
  26182. /**
  26183. *
  26184. * @param jointData The data for the Distance-Joint
  26185. */
  26186. constructor(jointData: DistanceJointData);
  26187. /**
  26188. * Update the predefined distance.
  26189. * @param maxDistance The maximum preferred distance
  26190. * @param minDistance The minimum preferred distance
  26191. */
  26192. updateDistance(maxDistance: number, minDistance?: number): void;
  26193. }
  26194. /**
  26195. * Represents a Motor-Enabled Joint
  26196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26197. */
  26198. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26199. /**
  26200. * Initializes the Motor-Enabled Joint
  26201. * @param type The type of the joint
  26202. * @param jointData The physica joint data for the joint
  26203. */
  26204. constructor(type: number, jointData: PhysicsJointData);
  26205. /**
  26206. * Set the motor values.
  26207. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26208. * @param force the force to apply
  26209. * @param maxForce max force for this motor.
  26210. */
  26211. setMotor(force?: number, maxForce?: number): void;
  26212. /**
  26213. * Set the motor's limits.
  26214. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26215. * @param upperLimit The upper limit of the motor
  26216. * @param lowerLimit The lower limit of the motor
  26217. */
  26218. setLimit(upperLimit: number, lowerLimit?: number): void;
  26219. }
  26220. /**
  26221. * This class represents a single physics Hinge-Joint
  26222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26223. */
  26224. export class HingeJoint extends MotorEnabledJoint {
  26225. /**
  26226. * Initializes the Hinge-Joint
  26227. * @param jointData The joint data for the Hinge-Joint
  26228. */
  26229. constructor(jointData: PhysicsJointData);
  26230. /**
  26231. * Set the motor values.
  26232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26233. * @param {number} force the force to apply
  26234. * @param {number} maxForce max force for this motor.
  26235. */
  26236. setMotor(force?: number, maxForce?: number): void;
  26237. /**
  26238. * Set the motor's limits.
  26239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26240. * @param upperLimit The upper limit of the motor
  26241. * @param lowerLimit The lower limit of the motor
  26242. */
  26243. setLimit(upperLimit: number, lowerLimit?: number): void;
  26244. }
  26245. /**
  26246. * This class represents a dual hinge physics joint (same as wheel joint)
  26247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26248. */
  26249. export class Hinge2Joint extends MotorEnabledJoint {
  26250. /**
  26251. * Initializes the Hinge2-Joint
  26252. * @param jointData The joint data for the Hinge2-Joint
  26253. */
  26254. constructor(jointData: PhysicsJointData);
  26255. /**
  26256. * Set the motor values.
  26257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26258. * @param {number} targetSpeed the speed the motor is to reach
  26259. * @param {number} maxForce max force for this motor.
  26260. * @param {motorIndex} the motor's index, 0 or 1.
  26261. */
  26262. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26263. /**
  26264. * Set the motor limits.
  26265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26266. * @param {number} upperLimit the upper limit
  26267. * @param {number} lowerLimit lower limit
  26268. * @param {motorIndex} the motor's index, 0 or 1.
  26269. */
  26270. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26271. }
  26272. /**
  26273. * Interface for a motor enabled joint
  26274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26275. */
  26276. export interface IMotorEnabledJoint {
  26277. /**
  26278. * Physics joint
  26279. */
  26280. physicsJoint: any;
  26281. /**
  26282. * Sets the motor of the motor-enabled joint
  26283. * @param force The force of the motor
  26284. * @param maxForce The maximum force of the motor
  26285. * @param motorIndex The index of the motor
  26286. */
  26287. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26288. /**
  26289. * Sets the limit of the motor
  26290. * @param upperLimit The upper limit of the motor
  26291. * @param lowerLimit The lower limit of the motor
  26292. * @param motorIndex The index of the motor
  26293. */
  26294. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26295. }
  26296. /**
  26297. * Joint data for a Distance-Joint
  26298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26299. */
  26300. export interface DistanceJointData extends PhysicsJointData {
  26301. /**
  26302. * Max distance the 2 joint objects can be apart
  26303. */
  26304. maxDistance: number;
  26305. }
  26306. /**
  26307. * Joint data from a spring joint
  26308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26309. */
  26310. export interface SpringJointData extends PhysicsJointData {
  26311. /**
  26312. * Length of the spring
  26313. */
  26314. length: number;
  26315. /**
  26316. * Stiffness of the spring
  26317. */
  26318. stiffness: number;
  26319. /**
  26320. * Damping of the spring
  26321. */
  26322. damping: number;
  26323. /** this callback will be called when applying the force to the impostors. */
  26324. forceApplicationCallback: () => void;
  26325. }
  26326. }
  26327. declare module BABYLON {
  26328. /**
  26329. * Holds the data for the raycast result
  26330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26331. */
  26332. export class PhysicsRaycastResult {
  26333. private _hasHit;
  26334. private _hitDistance;
  26335. private _hitNormalWorld;
  26336. private _hitPointWorld;
  26337. private _rayFromWorld;
  26338. private _rayToWorld;
  26339. /**
  26340. * Gets if there was a hit
  26341. */
  26342. get hasHit(): boolean;
  26343. /**
  26344. * Gets the distance from the hit
  26345. */
  26346. get hitDistance(): number;
  26347. /**
  26348. * Gets the hit normal/direction in the world
  26349. */
  26350. get hitNormalWorld(): Vector3;
  26351. /**
  26352. * Gets the hit point in the world
  26353. */
  26354. get hitPointWorld(): Vector3;
  26355. /**
  26356. * Gets the ray "start point" of the ray in the world
  26357. */
  26358. get rayFromWorld(): Vector3;
  26359. /**
  26360. * Gets the ray "end point" of the ray in the world
  26361. */
  26362. get rayToWorld(): Vector3;
  26363. /**
  26364. * Sets the hit data (normal & point in world space)
  26365. * @param hitNormalWorld defines the normal in world space
  26366. * @param hitPointWorld defines the point in world space
  26367. */
  26368. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26369. /**
  26370. * Sets the distance from the start point to the hit point
  26371. * @param distance
  26372. */
  26373. setHitDistance(distance: number): void;
  26374. /**
  26375. * Calculates the distance manually
  26376. */
  26377. calculateHitDistance(): void;
  26378. /**
  26379. * Resets all the values to default
  26380. * @param from The from point on world space
  26381. * @param to The to point on world space
  26382. */
  26383. reset(from?: Vector3, to?: Vector3): void;
  26384. }
  26385. /**
  26386. * Interface for the size containing width and height
  26387. */
  26388. interface IXYZ {
  26389. /**
  26390. * X
  26391. */
  26392. x: number;
  26393. /**
  26394. * Y
  26395. */
  26396. y: number;
  26397. /**
  26398. * Z
  26399. */
  26400. z: number;
  26401. }
  26402. }
  26403. declare module BABYLON {
  26404. /**
  26405. * Interface used to describe a physics joint
  26406. */
  26407. export interface PhysicsImpostorJoint {
  26408. /** Defines the main impostor to which the joint is linked */
  26409. mainImpostor: PhysicsImpostor;
  26410. /** Defines the impostor that is connected to the main impostor using this joint */
  26411. connectedImpostor: PhysicsImpostor;
  26412. /** Defines the joint itself */
  26413. joint: PhysicsJoint;
  26414. }
  26415. /** @hidden */
  26416. export interface IPhysicsEnginePlugin {
  26417. world: any;
  26418. name: string;
  26419. setGravity(gravity: Vector3): void;
  26420. setTimeStep(timeStep: number): void;
  26421. getTimeStep(): number;
  26422. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26423. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26424. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26425. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26426. removePhysicsBody(impostor: PhysicsImpostor): void;
  26427. generateJoint(joint: PhysicsImpostorJoint): void;
  26428. removeJoint(joint: PhysicsImpostorJoint): void;
  26429. isSupported(): boolean;
  26430. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26431. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26432. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26433. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26434. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26435. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26436. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26437. getBodyMass(impostor: PhysicsImpostor): number;
  26438. getBodyFriction(impostor: PhysicsImpostor): number;
  26439. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26440. getBodyRestitution(impostor: PhysicsImpostor): number;
  26441. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26442. getBodyPressure?(impostor: PhysicsImpostor): number;
  26443. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26444. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26445. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26446. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26447. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26448. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26449. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26450. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26451. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26452. sleepBody(impostor: PhysicsImpostor): void;
  26453. wakeUpBody(impostor: PhysicsImpostor): void;
  26454. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26455. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26456. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26457. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26458. getRadius(impostor: PhysicsImpostor): number;
  26459. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26460. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26461. dispose(): void;
  26462. }
  26463. /**
  26464. * Interface used to define a physics engine
  26465. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26466. */
  26467. export interface IPhysicsEngine {
  26468. /**
  26469. * Gets the gravity vector used by the simulation
  26470. */
  26471. gravity: Vector3;
  26472. /**
  26473. * Sets the gravity vector used by the simulation
  26474. * @param gravity defines the gravity vector to use
  26475. */
  26476. setGravity(gravity: Vector3): void;
  26477. /**
  26478. * Set the time step of the physics engine.
  26479. * Default is 1/60.
  26480. * To slow it down, enter 1/600 for example.
  26481. * To speed it up, 1/30
  26482. * @param newTimeStep the new timestep to apply to this world.
  26483. */
  26484. setTimeStep(newTimeStep: number): void;
  26485. /**
  26486. * Get the time step of the physics engine.
  26487. * @returns the current time step
  26488. */
  26489. getTimeStep(): number;
  26490. /**
  26491. * Set the sub time step of the physics engine.
  26492. * Default is 0 meaning there is no sub steps
  26493. * To increase physics resolution precision, set a small value (like 1 ms)
  26494. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26495. */
  26496. setSubTimeStep(subTimeStep: number): void;
  26497. /**
  26498. * Get the sub time step of the physics engine.
  26499. * @returns the current sub time step
  26500. */
  26501. getSubTimeStep(): number;
  26502. /**
  26503. * Release all resources
  26504. */
  26505. dispose(): void;
  26506. /**
  26507. * Gets the name of the current physics plugin
  26508. * @returns the name of the plugin
  26509. */
  26510. getPhysicsPluginName(): string;
  26511. /**
  26512. * Adding a new impostor for the impostor tracking.
  26513. * This will be done by the impostor itself.
  26514. * @param impostor the impostor to add
  26515. */
  26516. addImpostor(impostor: PhysicsImpostor): void;
  26517. /**
  26518. * Remove an impostor from the engine.
  26519. * This impostor and its mesh will not longer be updated by the physics engine.
  26520. * @param impostor the impostor to remove
  26521. */
  26522. removeImpostor(impostor: PhysicsImpostor): void;
  26523. /**
  26524. * Add a joint to the physics engine
  26525. * @param mainImpostor defines the main impostor to which the joint is added.
  26526. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26527. * @param joint defines the joint that will connect both impostors.
  26528. */
  26529. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26530. /**
  26531. * Removes a joint from the simulation
  26532. * @param mainImpostor defines the impostor used with the joint
  26533. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26534. * @param joint defines the joint to remove
  26535. */
  26536. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26537. /**
  26538. * Gets the current plugin used to run the simulation
  26539. * @returns current plugin
  26540. */
  26541. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26542. /**
  26543. * Gets the list of physic impostors
  26544. * @returns an array of PhysicsImpostor
  26545. */
  26546. getImpostors(): Array<PhysicsImpostor>;
  26547. /**
  26548. * Gets the impostor for a physics enabled object
  26549. * @param object defines the object impersonated by the impostor
  26550. * @returns the PhysicsImpostor or null if not found
  26551. */
  26552. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26553. /**
  26554. * Gets the impostor for a physics body object
  26555. * @param body defines physics body used by the impostor
  26556. * @returns the PhysicsImpostor or null if not found
  26557. */
  26558. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26559. /**
  26560. * Does a raycast in the physics world
  26561. * @param from when should the ray start?
  26562. * @param to when should the ray end?
  26563. * @returns PhysicsRaycastResult
  26564. */
  26565. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26566. /**
  26567. * Called by the scene. No need to call it.
  26568. * @param delta defines the timespam between frames
  26569. */
  26570. _step(delta: number): void;
  26571. }
  26572. }
  26573. declare module BABYLON {
  26574. /**
  26575. * The interface for the physics imposter parameters
  26576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26577. */
  26578. export interface PhysicsImpostorParameters {
  26579. /**
  26580. * The mass of the physics imposter
  26581. */
  26582. mass: number;
  26583. /**
  26584. * The friction of the physics imposter
  26585. */
  26586. friction?: number;
  26587. /**
  26588. * The coefficient of restitution of the physics imposter
  26589. */
  26590. restitution?: number;
  26591. /**
  26592. * The native options of the physics imposter
  26593. */
  26594. nativeOptions?: any;
  26595. /**
  26596. * Specifies if the parent should be ignored
  26597. */
  26598. ignoreParent?: boolean;
  26599. /**
  26600. * Specifies if bi-directional transformations should be disabled
  26601. */
  26602. disableBidirectionalTransformation?: boolean;
  26603. /**
  26604. * The pressure inside the physics imposter, soft object only
  26605. */
  26606. pressure?: number;
  26607. /**
  26608. * The stiffness the physics imposter, soft object only
  26609. */
  26610. stiffness?: number;
  26611. /**
  26612. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26613. */
  26614. velocityIterations?: number;
  26615. /**
  26616. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26617. */
  26618. positionIterations?: number;
  26619. /**
  26620. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26621. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26622. * Add to fix multiple points
  26623. */
  26624. fixedPoints?: number;
  26625. /**
  26626. * The collision margin around a soft object
  26627. */
  26628. margin?: number;
  26629. /**
  26630. * The collision margin around a soft object
  26631. */
  26632. damping?: number;
  26633. /**
  26634. * The path for a rope based on an extrusion
  26635. */
  26636. path?: any;
  26637. /**
  26638. * The shape of an extrusion used for a rope based on an extrusion
  26639. */
  26640. shape?: any;
  26641. }
  26642. /**
  26643. * Interface for a physics-enabled object
  26644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26645. */
  26646. export interface IPhysicsEnabledObject {
  26647. /**
  26648. * The position of the physics-enabled object
  26649. */
  26650. position: Vector3;
  26651. /**
  26652. * The rotation of the physics-enabled object
  26653. */
  26654. rotationQuaternion: Nullable<Quaternion>;
  26655. /**
  26656. * The scale of the physics-enabled object
  26657. */
  26658. scaling: Vector3;
  26659. /**
  26660. * The rotation of the physics-enabled object
  26661. */
  26662. rotation?: Vector3;
  26663. /**
  26664. * The parent of the physics-enabled object
  26665. */
  26666. parent?: any;
  26667. /**
  26668. * The bounding info of the physics-enabled object
  26669. * @returns The bounding info of the physics-enabled object
  26670. */
  26671. getBoundingInfo(): BoundingInfo;
  26672. /**
  26673. * Computes the world matrix
  26674. * @param force Specifies if the world matrix should be computed by force
  26675. * @returns A world matrix
  26676. */
  26677. computeWorldMatrix(force: boolean): Matrix;
  26678. /**
  26679. * Gets the world matrix
  26680. * @returns A world matrix
  26681. */
  26682. getWorldMatrix?(): Matrix;
  26683. /**
  26684. * Gets the child meshes
  26685. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26686. * @returns An array of abstract meshes
  26687. */
  26688. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26689. /**
  26690. * Gets the vertex data
  26691. * @param kind The type of vertex data
  26692. * @returns A nullable array of numbers, or a float32 array
  26693. */
  26694. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26695. /**
  26696. * Gets the indices from the mesh
  26697. * @returns A nullable array of index arrays
  26698. */
  26699. getIndices?(): Nullable<IndicesArray>;
  26700. /**
  26701. * Gets the scene from the mesh
  26702. * @returns the indices array or null
  26703. */
  26704. getScene?(): Scene;
  26705. /**
  26706. * Gets the absolute position from the mesh
  26707. * @returns the absolute position
  26708. */
  26709. getAbsolutePosition(): Vector3;
  26710. /**
  26711. * Gets the absolute pivot point from the mesh
  26712. * @returns the absolute pivot point
  26713. */
  26714. getAbsolutePivotPoint(): Vector3;
  26715. /**
  26716. * Rotates the mesh
  26717. * @param axis The axis of rotation
  26718. * @param amount The amount of rotation
  26719. * @param space The space of the rotation
  26720. * @returns The rotation transform node
  26721. */
  26722. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26723. /**
  26724. * Translates the mesh
  26725. * @param axis The axis of translation
  26726. * @param distance The distance of translation
  26727. * @param space The space of the translation
  26728. * @returns The transform node
  26729. */
  26730. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26731. /**
  26732. * Sets the absolute position of the mesh
  26733. * @param absolutePosition The absolute position of the mesh
  26734. * @returns The transform node
  26735. */
  26736. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26737. /**
  26738. * Gets the class name of the mesh
  26739. * @returns The class name
  26740. */
  26741. getClassName(): string;
  26742. }
  26743. /**
  26744. * Represents a physics imposter
  26745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26746. */
  26747. export class PhysicsImpostor {
  26748. /**
  26749. * The physics-enabled object used as the physics imposter
  26750. */
  26751. object: IPhysicsEnabledObject;
  26752. /**
  26753. * The type of the physics imposter
  26754. */
  26755. type: number;
  26756. private _options;
  26757. private _scene?;
  26758. /**
  26759. * The default object size of the imposter
  26760. */
  26761. static DEFAULT_OBJECT_SIZE: Vector3;
  26762. /**
  26763. * The identity quaternion of the imposter
  26764. */
  26765. static IDENTITY_QUATERNION: Quaternion;
  26766. /** @hidden */
  26767. _pluginData: any;
  26768. private _physicsEngine;
  26769. private _physicsBody;
  26770. private _bodyUpdateRequired;
  26771. private _onBeforePhysicsStepCallbacks;
  26772. private _onAfterPhysicsStepCallbacks;
  26773. /** @hidden */
  26774. _onPhysicsCollideCallbacks: Array<{
  26775. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26776. otherImpostors: Array<PhysicsImpostor>;
  26777. }>;
  26778. private _deltaPosition;
  26779. private _deltaRotation;
  26780. private _deltaRotationConjugated;
  26781. /** @hidden */
  26782. _isFromLine: boolean;
  26783. private _parent;
  26784. private _isDisposed;
  26785. private static _tmpVecs;
  26786. private static _tmpQuat;
  26787. /**
  26788. * Specifies if the physics imposter is disposed
  26789. */
  26790. get isDisposed(): boolean;
  26791. /**
  26792. * Gets the mass of the physics imposter
  26793. */
  26794. get mass(): number;
  26795. set mass(value: number);
  26796. /**
  26797. * Gets the coefficient of friction
  26798. */
  26799. get friction(): number;
  26800. /**
  26801. * Sets the coefficient of friction
  26802. */
  26803. set friction(value: number);
  26804. /**
  26805. * Gets the coefficient of restitution
  26806. */
  26807. get restitution(): number;
  26808. /**
  26809. * Sets the coefficient of restitution
  26810. */
  26811. set restitution(value: number);
  26812. /**
  26813. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26814. */
  26815. get pressure(): number;
  26816. /**
  26817. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26818. */
  26819. set pressure(value: number);
  26820. /**
  26821. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26822. */
  26823. get stiffness(): number;
  26824. /**
  26825. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26826. */
  26827. set stiffness(value: number);
  26828. /**
  26829. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26830. */
  26831. get velocityIterations(): number;
  26832. /**
  26833. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26834. */
  26835. set velocityIterations(value: number);
  26836. /**
  26837. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26838. */
  26839. get positionIterations(): number;
  26840. /**
  26841. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26842. */
  26843. set positionIterations(value: number);
  26844. /**
  26845. * The unique id of the physics imposter
  26846. * set by the physics engine when adding this impostor to the array
  26847. */
  26848. uniqueId: number;
  26849. /**
  26850. * @hidden
  26851. */
  26852. soft: boolean;
  26853. /**
  26854. * @hidden
  26855. */
  26856. segments: number;
  26857. private _joints;
  26858. /**
  26859. * Initializes the physics imposter
  26860. * @param object The physics-enabled object used as the physics imposter
  26861. * @param type The type of the physics imposter
  26862. * @param _options The options for the physics imposter
  26863. * @param _scene The Babylon scene
  26864. */
  26865. constructor(
  26866. /**
  26867. * The physics-enabled object used as the physics imposter
  26868. */
  26869. object: IPhysicsEnabledObject,
  26870. /**
  26871. * The type of the physics imposter
  26872. */
  26873. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26874. /**
  26875. * This function will completly initialize this impostor.
  26876. * It will create a new body - but only if this mesh has no parent.
  26877. * If it has, this impostor will not be used other than to define the impostor
  26878. * of the child mesh.
  26879. * @hidden
  26880. */
  26881. _init(): void;
  26882. private _getPhysicsParent;
  26883. /**
  26884. * Should a new body be generated.
  26885. * @returns boolean specifying if body initialization is required
  26886. */
  26887. isBodyInitRequired(): boolean;
  26888. /**
  26889. * Sets the updated scaling
  26890. * @param updated Specifies if the scaling is updated
  26891. */
  26892. setScalingUpdated(): void;
  26893. /**
  26894. * Force a regeneration of this or the parent's impostor's body.
  26895. * Use under cautious - This will remove all joints already implemented.
  26896. */
  26897. forceUpdate(): void;
  26898. /**
  26899. * Gets the body that holds this impostor. Either its own, or its parent.
  26900. */
  26901. get physicsBody(): any;
  26902. /**
  26903. * Get the parent of the physics imposter
  26904. * @returns Physics imposter or null
  26905. */
  26906. get parent(): Nullable<PhysicsImpostor>;
  26907. /**
  26908. * Sets the parent of the physics imposter
  26909. */
  26910. set parent(value: Nullable<PhysicsImpostor>);
  26911. /**
  26912. * Set the physics body. Used mainly by the physics engine/plugin
  26913. */
  26914. set physicsBody(physicsBody: any);
  26915. /**
  26916. * Resets the update flags
  26917. */
  26918. resetUpdateFlags(): void;
  26919. /**
  26920. * Gets the object extend size
  26921. * @returns the object extend size
  26922. */
  26923. getObjectExtendSize(): Vector3;
  26924. /**
  26925. * Gets the object center
  26926. * @returns The object center
  26927. */
  26928. getObjectCenter(): Vector3;
  26929. /**
  26930. * Get a specific parameter from the options parameters
  26931. * @param paramName The object parameter name
  26932. * @returns The object parameter
  26933. */
  26934. getParam(paramName: string): any;
  26935. /**
  26936. * Sets a specific parameter in the options given to the physics plugin
  26937. * @param paramName The parameter name
  26938. * @param value The value of the parameter
  26939. */
  26940. setParam(paramName: string, value: number): void;
  26941. /**
  26942. * Specifically change the body's mass option. Won't recreate the physics body object
  26943. * @param mass The mass of the physics imposter
  26944. */
  26945. setMass(mass: number): void;
  26946. /**
  26947. * Gets the linear velocity
  26948. * @returns linear velocity or null
  26949. */
  26950. getLinearVelocity(): Nullable<Vector3>;
  26951. /**
  26952. * Sets the linear velocity
  26953. * @param velocity linear velocity or null
  26954. */
  26955. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26956. /**
  26957. * Gets the angular velocity
  26958. * @returns angular velocity or null
  26959. */
  26960. getAngularVelocity(): Nullable<Vector3>;
  26961. /**
  26962. * Sets the angular velocity
  26963. * @param velocity The velocity or null
  26964. */
  26965. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26966. /**
  26967. * Execute a function with the physics plugin native code
  26968. * Provide a function the will have two variables - the world object and the physics body object
  26969. * @param func The function to execute with the physics plugin native code
  26970. */
  26971. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26972. /**
  26973. * Register a function that will be executed before the physics world is stepping forward
  26974. * @param func The function to execute before the physics world is stepped forward
  26975. */
  26976. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26977. /**
  26978. * Unregister a function that will be executed before the physics world is stepping forward
  26979. * @param func The function to execute before the physics world is stepped forward
  26980. */
  26981. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26982. /**
  26983. * Register a function that will be executed after the physics step
  26984. * @param func The function to execute after physics step
  26985. */
  26986. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26987. /**
  26988. * Unregisters a function that will be executed after the physics step
  26989. * @param func The function to execute after physics step
  26990. */
  26991. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26992. /**
  26993. * register a function that will be executed when this impostor collides against a different body
  26994. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26995. * @param func Callback that is executed on collision
  26996. */
  26997. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26998. /**
  26999. * Unregisters the physics imposter on contact
  27000. * @param collideAgainst The physics object to collide against
  27001. * @param func Callback to execute on collision
  27002. */
  27003. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27004. private _tmpQuat;
  27005. private _tmpQuat2;
  27006. /**
  27007. * Get the parent rotation
  27008. * @returns The parent rotation
  27009. */
  27010. getParentsRotation(): Quaternion;
  27011. /**
  27012. * this function is executed by the physics engine.
  27013. */
  27014. beforeStep: () => void;
  27015. /**
  27016. * this function is executed by the physics engine
  27017. */
  27018. afterStep: () => void;
  27019. /**
  27020. * Legacy collision detection event support
  27021. */
  27022. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27023. /**
  27024. * event and body object due to cannon's event-based architecture.
  27025. */
  27026. onCollide: (e: {
  27027. body: any;
  27028. }) => void;
  27029. /**
  27030. * Apply a force
  27031. * @param force The force to apply
  27032. * @param contactPoint The contact point for the force
  27033. * @returns The physics imposter
  27034. */
  27035. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27036. /**
  27037. * Apply an impulse
  27038. * @param force The impulse force
  27039. * @param contactPoint The contact point for the impulse force
  27040. * @returns The physics imposter
  27041. */
  27042. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27043. /**
  27044. * A help function to create a joint
  27045. * @param otherImpostor A physics imposter used to create a joint
  27046. * @param jointType The type of joint
  27047. * @param jointData The data for the joint
  27048. * @returns The physics imposter
  27049. */
  27050. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27051. /**
  27052. * Add a joint to this impostor with a different impostor
  27053. * @param otherImpostor A physics imposter used to add a joint
  27054. * @param joint The joint to add
  27055. * @returns The physics imposter
  27056. */
  27057. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27058. /**
  27059. * Add an anchor to a cloth impostor
  27060. * @param otherImpostor rigid impostor to anchor to
  27061. * @param width ratio across width from 0 to 1
  27062. * @param height ratio up height from 0 to 1
  27063. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27064. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27065. * @returns impostor the soft imposter
  27066. */
  27067. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27068. /**
  27069. * Add a hook to a rope impostor
  27070. * @param otherImpostor rigid impostor to anchor to
  27071. * @param length ratio across rope from 0 to 1
  27072. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27073. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27074. * @returns impostor the rope imposter
  27075. */
  27076. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27077. /**
  27078. * Will keep this body still, in a sleep mode.
  27079. * @returns the physics imposter
  27080. */
  27081. sleep(): PhysicsImpostor;
  27082. /**
  27083. * Wake the body up.
  27084. * @returns The physics imposter
  27085. */
  27086. wakeUp(): PhysicsImpostor;
  27087. /**
  27088. * Clones the physics imposter
  27089. * @param newObject The physics imposter clones to this physics-enabled object
  27090. * @returns A nullable physics imposter
  27091. */
  27092. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27093. /**
  27094. * Disposes the physics imposter
  27095. */
  27096. dispose(): void;
  27097. /**
  27098. * Sets the delta position
  27099. * @param position The delta position amount
  27100. */
  27101. setDeltaPosition(position: Vector3): void;
  27102. /**
  27103. * Sets the delta rotation
  27104. * @param rotation The delta rotation amount
  27105. */
  27106. setDeltaRotation(rotation: Quaternion): void;
  27107. /**
  27108. * Gets the box size of the physics imposter and stores the result in the input parameter
  27109. * @param result Stores the box size
  27110. * @returns The physics imposter
  27111. */
  27112. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27113. /**
  27114. * Gets the radius of the physics imposter
  27115. * @returns Radius of the physics imposter
  27116. */
  27117. getRadius(): number;
  27118. /**
  27119. * Sync a bone with this impostor
  27120. * @param bone The bone to sync to the impostor.
  27121. * @param boneMesh The mesh that the bone is influencing.
  27122. * @param jointPivot The pivot of the joint / bone in local space.
  27123. * @param distToJoint Optional distance from the impostor to the joint.
  27124. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27125. */
  27126. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27127. /**
  27128. * Sync impostor to a bone
  27129. * @param bone The bone that the impostor will be synced to.
  27130. * @param boneMesh The mesh that the bone is influencing.
  27131. * @param jointPivot The pivot of the joint / bone in local space.
  27132. * @param distToJoint Optional distance from the impostor to the joint.
  27133. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27134. * @param boneAxis Optional vector3 axis the bone is aligned with
  27135. */
  27136. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27137. /**
  27138. * No-Imposter type
  27139. */
  27140. static NoImpostor: number;
  27141. /**
  27142. * Sphere-Imposter type
  27143. */
  27144. static SphereImpostor: number;
  27145. /**
  27146. * Box-Imposter type
  27147. */
  27148. static BoxImpostor: number;
  27149. /**
  27150. * Plane-Imposter type
  27151. */
  27152. static PlaneImpostor: number;
  27153. /**
  27154. * Mesh-imposter type
  27155. */
  27156. static MeshImpostor: number;
  27157. /**
  27158. * Capsule-Impostor type (Ammo.js plugin only)
  27159. */
  27160. static CapsuleImpostor: number;
  27161. /**
  27162. * Cylinder-Imposter type
  27163. */
  27164. static CylinderImpostor: number;
  27165. /**
  27166. * Particle-Imposter type
  27167. */
  27168. static ParticleImpostor: number;
  27169. /**
  27170. * Heightmap-Imposter type
  27171. */
  27172. static HeightmapImpostor: number;
  27173. /**
  27174. * ConvexHull-Impostor type (Ammo.js plugin only)
  27175. */
  27176. static ConvexHullImpostor: number;
  27177. /**
  27178. * Custom-Imposter type (Ammo.js plugin only)
  27179. */
  27180. static CustomImpostor: number;
  27181. /**
  27182. * Rope-Imposter type
  27183. */
  27184. static RopeImpostor: number;
  27185. /**
  27186. * Cloth-Imposter type
  27187. */
  27188. static ClothImpostor: number;
  27189. /**
  27190. * Softbody-Imposter type
  27191. */
  27192. static SoftbodyImpostor: number;
  27193. }
  27194. }
  27195. declare module BABYLON {
  27196. /**
  27197. * @hidden
  27198. **/
  27199. export class _CreationDataStorage {
  27200. closePath?: boolean;
  27201. closeArray?: boolean;
  27202. idx: number[];
  27203. dashSize: number;
  27204. gapSize: number;
  27205. path3D: Path3D;
  27206. pathArray: Vector3[][];
  27207. arc: number;
  27208. radius: number;
  27209. cap: number;
  27210. tessellation: number;
  27211. }
  27212. /**
  27213. * @hidden
  27214. **/
  27215. class _InstanceDataStorage {
  27216. visibleInstances: any;
  27217. batchCache: _InstancesBatch;
  27218. instancesBufferSize: number;
  27219. instancesBuffer: Nullable<Buffer>;
  27220. instancesData: Float32Array;
  27221. overridenInstanceCount: number;
  27222. isFrozen: boolean;
  27223. previousBatch: Nullable<_InstancesBatch>;
  27224. hardwareInstancedRendering: boolean;
  27225. sideOrientation: number;
  27226. manualUpdate: boolean;
  27227. }
  27228. /**
  27229. * @hidden
  27230. **/
  27231. export class _InstancesBatch {
  27232. mustReturn: boolean;
  27233. visibleInstances: Nullable<InstancedMesh[]>[];
  27234. renderSelf: boolean[];
  27235. hardwareInstancedRendering: boolean[];
  27236. }
  27237. /**
  27238. * @hidden
  27239. **/
  27240. class _ThinInstanceDataStorage {
  27241. instancesCount: number;
  27242. matrixBuffer: Nullable<Buffer>;
  27243. matrixBufferSize: number;
  27244. matrixData: Nullable<Float32Array>;
  27245. boundingVectors: Array<Vector3>;
  27246. }
  27247. /**
  27248. * Class used to represent renderable models
  27249. */
  27250. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27251. /**
  27252. * Mesh side orientation : usually the external or front surface
  27253. */
  27254. static readonly FRONTSIDE: number;
  27255. /**
  27256. * Mesh side orientation : usually the internal or back surface
  27257. */
  27258. static readonly BACKSIDE: number;
  27259. /**
  27260. * Mesh side orientation : both internal and external or front and back surfaces
  27261. */
  27262. static readonly DOUBLESIDE: number;
  27263. /**
  27264. * Mesh side orientation : by default, `FRONTSIDE`
  27265. */
  27266. static readonly DEFAULTSIDE: number;
  27267. /**
  27268. * Mesh cap setting : no cap
  27269. */
  27270. static readonly NO_CAP: number;
  27271. /**
  27272. * Mesh cap setting : one cap at the beginning of the mesh
  27273. */
  27274. static readonly CAP_START: number;
  27275. /**
  27276. * Mesh cap setting : one cap at the end of the mesh
  27277. */
  27278. static readonly CAP_END: number;
  27279. /**
  27280. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27281. */
  27282. static readonly CAP_ALL: number;
  27283. /**
  27284. * Mesh pattern setting : no flip or rotate
  27285. */
  27286. static readonly NO_FLIP: number;
  27287. /**
  27288. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27289. */
  27290. static readonly FLIP_TILE: number;
  27291. /**
  27292. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27293. */
  27294. static readonly ROTATE_TILE: number;
  27295. /**
  27296. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27297. */
  27298. static readonly FLIP_ROW: number;
  27299. /**
  27300. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27301. */
  27302. static readonly ROTATE_ROW: number;
  27303. /**
  27304. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27305. */
  27306. static readonly FLIP_N_ROTATE_TILE: number;
  27307. /**
  27308. * Mesh pattern setting : rotate pattern and rotate
  27309. */
  27310. static readonly FLIP_N_ROTATE_ROW: number;
  27311. /**
  27312. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27313. */
  27314. static readonly CENTER: number;
  27315. /**
  27316. * Mesh tile positioning : part tiles on left
  27317. */
  27318. static readonly LEFT: number;
  27319. /**
  27320. * Mesh tile positioning : part tiles on right
  27321. */
  27322. static readonly RIGHT: number;
  27323. /**
  27324. * Mesh tile positioning : part tiles on top
  27325. */
  27326. static readonly TOP: number;
  27327. /**
  27328. * Mesh tile positioning : part tiles on bottom
  27329. */
  27330. static readonly BOTTOM: number;
  27331. /**
  27332. * Gets the default side orientation.
  27333. * @param orientation the orientation to value to attempt to get
  27334. * @returns the default orientation
  27335. * @hidden
  27336. */
  27337. static _GetDefaultSideOrientation(orientation?: number): number;
  27338. private _internalMeshDataInfo;
  27339. /**
  27340. * An event triggered before rendering the mesh
  27341. */
  27342. get onBeforeRenderObservable(): Observable<Mesh>;
  27343. /**
  27344. * An event triggered before binding the mesh
  27345. */
  27346. get onBeforeBindObservable(): Observable<Mesh>;
  27347. /**
  27348. * An event triggered after rendering the mesh
  27349. */
  27350. get onAfterRenderObservable(): Observable<Mesh>;
  27351. /**
  27352. * An event triggered before drawing the mesh
  27353. */
  27354. get onBeforeDrawObservable(): Observable<Mesh>;
  27355. private _onBeforeDrawObserver;
  27356. /**
  27357. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27358. */
  27359. set onBeforeDraw(callback: () => void);
  27360. get hasInstances(): boolean;
  27361. get hasThinInstances(): boolean;
  27362. /**
  27363. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27364. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27365. */
  27366. delayLoadState: number;
  27367. /**
  27368. * Gets the list of instances created from this mesh
  27369. * it is not supposed to be modified manually.
  27370. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27371. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27372. */
  27373. instances: InstancedMesh[];
  27374. /**
  27375. * Gets the file containing delay loading data for this mesh
  27376. */
  27377. delayLoadingFile: string;
  27378. /** @hidden */
  27379. _binaryInfo: any;
  27380. /**
  27381. * User defined function used to change how LOD level selection is done
  27382. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27383. */
  27384. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27385. /**
  27386. * Gets or sets the morph target manager
  27387. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27388. */
  27389. get morphTargetManager(): Nullable<MorphTargetManager>;
  27390. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27391. /** @hidden */
  27392. _creationDataStorage: Nullable<_CreationDataStorage>;
  27393. /** @hidden */
  27394. _geometry: Nullable<Geometry>;
  27395. /** @hidden */
  27396. _delayInfo: Array<string>;
  27397. /** @hidden */
  27398. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27399. /** @hidden */
  27400. _instanceDataStorage: _InstanceDataStorage;
  27401. /** @hidden */
  27402. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27403. private _effectiveMaterial;
  27404. /** @hidden */
  27405. _shouldGenerateFlatShading: boolean;
  27406. /** @hidden */
  27407. _originalBuilderSideOrientation: number;
  27408. /**
  27409. * Use this property to change the original side orientation defined at construction time
  27410. */
  27411. overrideMaterialSideOrientation: Nullable<number>;
  27412. /**
  27413. * Gets the source mesh (the one used to clone this one from)
  27414. */
  27415. get source(): Nullable<Mesh>;
  27416. /**
  27417. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27418. */
  27419. get isUnIndexed(): boolean;
  27420. set isUnIndexed(value: boolean);
  27421. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27422. get worldMatrixInstancedBuffer(): Float32Array;
  27423. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27424. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27425. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27426. /**
  27427. * @constructor
  27428. * @param name The value used by scene.getMeshByName() to do a lookup.
  27429. * @param scene The scene to add this mesh to.
  27430. * @param parent The parent of this mesh, if it has one
  27431. * @param source An optional Mesh from which geometry is shared, cloned.
  27432. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27433. * When false, achieved by calling a clone(), also passing False.
  27434. * This will make creation of children, recursive.
  27435. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27436. */
  27437. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27438. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27439. doNotInstantiate: boolean;
  27440. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27441. /**
  27442. * Gets the class name
  27443. * @returns the string "Mesh".
  27444. */
  27445. getClassName(): string;
  27446. /** @hidden */
  27447. get _isMesh(): boolean;
  27448. /**
  27449. * Returns a description of this mesh
  27450. * @param fullDetails define if full details about this mesh must be used
  27451. * @returns a descriptive string representing this mesh
  27452. */
  27453. toString(fullDetails?: boolean): string;
  27454. /** @hidden */
  27455. _unBindEffect(): void;
  27456. /**
  27457. * Gets a boolean indicating if this mesh has LOD
  27458. */
  27459. get hasLODLevels(): boolean;
  27460. /**
  27461. * Gets the list of MeshLODLevel associated with the current mesh
  27462. * @returns an array of MeshLODLevel
  27463. */
  27464. getLODLevels(): MeshLODLevel[];
  27465. private _sortLODLevels;
  27466. /**
  27467. * Add a mesh as LOD level triggered at the given distance.
  27468. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27469. * @param distance The distance from the center of the object to show this level
  27470. * @param mesh The mesh to be added as LOD level (can be null)
  27471. * @return This mesh (for chaining)
  27472. */
  27473. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27474. /**
  27475. * Returns the LOD level mesh at the passed distance or null if not found.
  27476. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27477. * @param distance The distance from the center of the object to show this level
  27478. * @returns a Mesh or `null`
  27479. */
  27480. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27481. /**
  27482. * Remove a mesh from the LOD array
  27483. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27484. * @param mesh defines the mesh to be removed
  27485. * @return This mesh (for chaining)
  27486. */
  27487. removeLODLevel(mesh: Mesh): Mesh;
  27488. /**
  27489. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27490. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27491. * @param camera defines the camera to use to compute distance
  27492. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27493. * @return This mesh (for chaining)
  27494. */
  27495. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27496. /**
  27497. * Gets the mesh internal Geometry object
  27498. */
  27499. get geometry(): Nullable<Geometry>;
  27500. /**
  27501. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27502. * @returns the total number of vertices
  27503. */
  27504. getTotalVertices(): number;
  27505. /**
  27506. * Returns the content of an associated vertex buffer
  27507. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27508. * - VertexBuffer.PositionKind
  27509. * - VertexBuffer.UVKind
  27510. * - VertexBuffer.UV2Kind
  27511. * - VertexBuffer.UV3Kind
  27512. * - VertexBuffer.UV4Kind
  27513. * - VertexBuffer.UV5Kind
  27514. * - VertexBuffer.UV6Kind
  27515. * - VertexBuffer.ColorKind
  27516. * - VertexBuffer.MatricesIndicesKind
  27517. * - VertexBuffer.MatricesIndicesExtraKind
  27518. * - VertexBuffer.MatricesWeightsKind
  27519. * - VertexBuffer.MatricesWeightsExtraKind
  27520. * @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
  27521. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27522. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27523. */
  27524. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27525. /**
  27526. * Returns the mesh VertexBuffer object from the requested `kind`
  27527. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27528. * - VertexBuffer.PositionKind
  27529. * - VertexBuffer.NormalKind
  27530. * - VertexBuffer.UVKind
  27531. * - VertexBuffer.UV2Kind
  27532. * - VertexBuffer.UV3Kind
  27533. * - VertexBuffer.UV4Kind
  27534. * - VertexBuffer.UV5Kind
  27535. * - VertexBuffer.UV6Kind
  27536. * - VertexBuffer.ColorKind
  27537. * - VertexBuffer.MatricesIndicesKind
  27538. * - VertexBuffer.MatricesIndicesExtraKind
  27539. * - VertexBuffer.MatricesWeightsKind
  27540. * - VertexBuffer.MatricesWeightsExtraKind
  27541. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27542. */
  27543. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27544. /**
  27545. * Tests if a specific vertex buffer is associated with this mesh
  27546. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27547. * - VertexBuffer.PositionKind
  27548. * - VertexBuffer.NormalKind
  27549. * - VertexBuffer.UVKind
  27550. * - VertexBuffer.UV2Kind
  27551. * - VertexBuffer.UV3Kind
  27552. * - VertexBuffer.UV4Kind
  27553. * - VertexBuffer.UV5Kind
  27554. * - VertexBuffer.UV6Kind
  27555. * - VertexBuffer.ColorKind
  27556. * - VertexBuffer.MatricesIndicesKind
  27557. * - VertexBuffer.MatricesIndicesExtraKind
  27558. * - VertexBuffer.MatricesWeightsKind
  27559. * - VertexBuffer.MatricesWeightsExtraKind
  27560. * @returns a boolean
  27561. */
  27562. isVerticesDataPresent(kind: string): boolean;
  27563. /**
  27564. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27565. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27566. * - VertexBuffer.PositionKind
  27567. * - VertexBuffer.UVKind
  27568. * - VertexBuffer.UV2Kind
  27569. * - VertexBuffer.UV3Kind
  27570. * - VertexBuffer.UV4Kind
  27571. * - VertexBuffer.UV5Kind
  27572. * - VertexBuffer.UV6Kind
  27573. * - VertexBuffer.ColorKind
  27574. * - VertexBuffer.MatricesIndicesKind
  27575. * - VertexBuffer.MatricesIndicesExtraKind
  27576. * - VertexBuffer.MatricesWeightsKind
  27577. * - VertexBuffer.MatricesWeightsExtraKind
  27578. * @returns a boolean
  27579. */
  27580. isVertexBufferUpdatable(kind: string): boolean;
  27581. /**
  27582. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27583. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27584. * - VertexBuffer.PositionKind
  27585. * - VertexBuffer.NormalKind
  27586. * - VertexBuffer.UVKind
  27587. * - VertexBuffer.UV2Kind
  27588. * - VertexBuffer.UV3Kind
  27589. * - VertexBuffer.UV4Kind
  27590. * - VertexBuffer.UV5Kind
  27591. * - VertexBuffer.UV6Kind
  27592. * - VertexBuffer.ColorKind
  27593. * - VertexBuffer.MatricesIndicesKind
  27594. * - VertexBuffer.MatricesIndicesExtraKind
  27595. * - VertexBuffer.MatricesWeightsKind
  27596. * - VertexBuffer.MatricesWeightsExtraKind
  27597. * @returns an array of strings
  27598. */
  27599. getVerticesDataKinds(): string[];
  27600. /**
  27601. * Returns a positive integer : the total number of indices in this mesh geometry.
  27602. * @returns the numner of indices or zero if the mesh has no geometry.
  27603. */
  27604. getTotalIndices(): number;
  27605. /**
  27606. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27607. * @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.
  27608. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27609. * @returns the indices array or an empty array if the mesh has no geometry
  27610. */
  27611. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27612. get isBlocked(): boolean;
  27613. /**
  27614. * Determine if the current mesh is ready to be rendered
  27615. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27616. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27617. * @returns true if all associated assets are ready (material, textures, shaders)
  27618. */
  27619. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27620. /**
  27621. * 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.
  27622. */
  27623. get areNormalsFrozen(): boolean;
  27624. /**
  27625. * 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.
  27626. * @returns the current mesh
  27627. */
  27628. freezeNormals(): Mesh;
  27629. /**
  27630. * 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
  27631. * @returns the current mesh
  27632. */
  27633. unfreezeNormals(): Mesh;
  27634. /**
  27635. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27636. */
  27637. set overridenInstanceCount(count: number);
  27638. /** @hidden */
  27639. _preActivate(): Mesh;
  27640. /** @hidden */
  27641. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27642. /** @hidden */
  27643. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27644. protected _afterComputeWorldMatrix(): void;
  27645. /** @hidden */
  27646. _postActivate(): void;
  27647. /**
  27648. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27649. * This means the mesh underlying bounding box and sphere are recomputed.
  27650. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27651. * @returns the current mesh
  27652. */
  27653. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27654. /** @hidden */
  27655. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27656. /**
  27657. * This function will subdivide the mesh into multiple submeshes
  27658. * @param count defines the expected number of submeshes
  27659. */
  27660. subdivide(count: number): void;
  27661. /**
  27662. * Copy a FloatArray into a specific associated vertex buffer
  27663. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27664. * - VertexBuffer.PositionKind
  27665. * - VertexBuffer.UVKind
  27666. * - VertexBuffer.UV2Kind
  27667. * - VertexBuffer.UV3Kind
  27668. * - VertexBuffer.UV4Kind
  27669. * - VertexBuffer.UV5Kind
  27670. * - VertexBuffer.UV6Kind
  27671. * - VertexBuffer.ColorKind
  27672. * - VertexBuffer.MatricesIndicesKind
  27673. * - VertexBuffer.MatricesIndicesExtraKind
  27674. * - VertexBuffer.MatricesWeightsKind
  27675. * - VertexBuffer.MatricesWeightsExtraKind
  27676. * @param data defines the data source
  27677. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27678. * @param stride defines the data stride size (can be null)
  27679. * @returns the current mesh
  27680. */
  27681. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27682. /**
  27683. * Delete a vertex buffer associated with this mesh
  27684. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27685. * - VertexBuffer.PositionKind
  27686. * - VertexBuffer.UVKind
  27687. * - VertexBuffer.UV2Kind
  27688. * - VertexBuffer.UV3Kind
  27689. * - VertexBuffer.UV4Kind
  27690. * - VertexBuffer.UV5Kind
  27691. * - VertexBuffer.UV6Kind
  27692. * - VertexBuffer.ColorKind
  27693. * - VertexBuffer.MatricesIndicesKind
  27694. * - VertexBuffer.MatricesIndicesExtraKind
  27695. * - VertexBuffer.MatricesWeightsKind
  27696. * - VertexBuffer.MatricesWeightsExtraKind
  27697. */
  27698. removeVerticesData(kind: string): void;
  27699. /**
  27700. * Flags an associated vertex buffer as updatable
  27701. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27702. * - VertexBuffer.PositionKind
  27703. * - VertexBuffer.UVKind
  27704. * - VertexBuffer.UV2Kind
  27705. * - VertexBuffer.UV3Kind
  27706. * - VertexBuffer.UV4Kind
  27707. * - VertexBuffer.UV5Kind
  27708. * - VertexBuffer.UV6Kind
  27709. * - VertexBuffer.ColorKind
  27710. * - VertexBuffer.MatricesIndicesKind
  27711. * - VertexBuffer.MatricesIndicesExtraKind
  27712. * - VertexBuffer.MatricesWeightsKind
  27713. * - VertexBuffer.MatricesWeightsExtraKind
  27714. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27715. */
  27716. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27717. /**
  27718. * Sets the mesh global Vertex Buffer
  27719. * @param buffer defines the buffer to use
  27720. * @returns the current mesh
  27721. */
  27722. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27723. /**
  27724. * Update a specific associated vertex buffer
  27725. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27726. * - VertexBuffer.PositionKind
  27727. * - VertexBuffer.UVKind
  27728. * - VertexBuffer.UV2Kind
  27729. * - VertexBuffer.UV3Kind
  27730. * - VertexBuffer.UV4Kind
  27731. * - VertexBuffer.UV5Kind
  27732. * - VertexBuffer.UV6Kind
  27733. * - VertexBuffer.ColorKind
  27734. * - VertexBuffer.MatricesIndicesKind
  27735. * - VertexBuffer.MatricesIndicesExtraKind
  27736. * - VertexBuffer.MatricesWeightsKind
  27737. * - VertexBuffer.MatricesWeightsExtraKind
  27738. * @param data defines the data source
  27739. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27740. * @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)
  27741. * @returns the current mesh
  27742. */
  27743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27744. /**
  27745. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27746. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27747. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27748. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27749. * @returns the current mesh
  27750. */
  27751. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27752. /**
  27753. * Creates a un-shared specific occurence of the geometry for the mesh.
  27754. * @returns the current mesh
  27755. */
  27756. makeGeometryUnique(): Mesh;
  27757. /**
  27758. * Set the index buffer of this mesh
  27759. * @param indices defines the source data
  27760. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27761. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27762. * @returns the current mesh
  27763. */
  27764. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27765. /**
  27766. * Update the current index buffer
  27767. * @param indices defines the source data
  27768. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27769. * @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)
  27770. * @returns the current mesh
  27771. */
  27772. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27773. /**
  27774. * Invert the geometry to move from a right handed system to a left handed one.
  27775. * @returns the current mesh
  27776. */
  27777. toLeftHanded(): Mesh;
  27778. /** @hidden */
  27779. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27780. /** @hidden */
  27781. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27782. /**
  27783. * Registers for this mesh a javascript function called just before the rendering process
  27784. * @param func defines the function to call before rendering this mesh
  27785. * @returns the current mesh
  27786. */
  27787. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27788. /**
  27789. * Disposes a previously registered javascript function called before the rendering
  27790. * @param func defines the function to remove
  27791. * @returns the current mesh
  27792. */
  27793. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27794. /**
  27795. * Registers for this mesh a javascript function called just after the rendering is complete
  27796. * @param func defines the function to call after rendering this mesh
  27797. * @returns the current mesh
  27798. */
  27799. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27800. /**
  27801. * Disposes a previously registered javascript function called after the rendering.
  27802. * @param func defines the function to remove
  27803. * @returns the current mesh
  27804. */
  27805. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27806. /** @hidden */
  27807. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27808. /** @hidden */
  27809. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27810. /** @hidden */
  27811. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27812. /** @hidden */
  27813. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27814. /** @hidden */
  27815. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27816. /** @hidden */
  27817. _rebuild(): void;
  27818. /** @hidden */
  27819. _freeze(): void;
  27820. /** @hidden */
  27821. _unFreeze(): void;
  27822. /**
  27823. * 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
  27824. * @param subMesh defines the subMesh to render
  27825. * @param enableAlphaMode defines if alpha mode can be changed
  27826. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27827. * @returns the current mesh
  27828. */
  27829. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27830. private _onBeforeDraw;
  27831. /**
  27832. * Renormalize the mesh and patch it up if there are no weights
  27833. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27834. * However in the case of zero weights then we set just a single influence to 1.
  27835. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27836. */
  27837. cleanMatrixWeights(): void;
  27838. private normalizeSkinFourWeights;
  27839. private normalizeSkinWeightsAndExtra;
  27840. /**
  27841. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27842. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27843. * the user know there was an issue with importing the mesh
  27844. * @returns a validation object with skinned, valid and report string
  27845. */
  27846. validateSkinning(): {
  27847. skinned: boolean;
  27848. valid: boolean;
  27849. report: string;
  27850. };
  27851. /** @hidden */
  27852. _checkDelayState(): Mesh;
  27853. private _queueLoad;
  27854. /**
  27855. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27856. * A mesh is in the frustum if its bounding box intersects the frustum
  27857. * @param frustumPlanes defines the frustum to test
  27858. * @returns true if the mesh is in the frustum planes
  27859. */
  27860. isInFrustum(frustumPlanes: Plane[]): boolean;
  27861. /**
  27862. * Sets the mesh material by the material or multiMaterial `id` property
  27863. * @param id is a string identifying the material or the multiMaterial
  27864. * @returns the current mesh
  27865. */
  27866. setMaterialByID(id: string): Mesh;
  27867. /**
  27868. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27869. * @returns an array of IAnimatable
  27870. */
  27871. getAnimatables(): IAnimatable[];
  27872. /**
  27873. * Modifies the mesh geometry according to the passed transformation matrix.
  27874. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27875. * The mesh normals are modified using the same transformation.
  27876. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27877. * @param transform defines the transform matrix to use
  27878. * @see http://doc.babylonjs.com/resources/baking_transformations
  27879. * @returns the current mesh
  27880. */
  27881. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27882. /**
  27883. * Modifies the mesh geometry according to its own current World Matrix.
  27884. * The mesh World Matrix is then reset.
  27885. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27886. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27887. * @see http://doc.babylonjs.com/resources/baking_transformations
  27888. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27889. * @returns the current mesh
  27890. */
  27891. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27892. /** @hidden */
  27893. get _positions(): Nullable<Vector3[]>;
  27894. /** @hidden */
  27895. _resetPointsArrayCache(): Mesh;
  27896. /** @hidden */
  27897. _generatePointsArray(): boolean;
  27898. /**
  27899. * Returns a new Mesh object generated from the current mesh properties.
  27900. * This method must not get confused with createInstance()
  27901. * @param name is a string, the name given to the new mesh
  27902. * @param newParent can be any Node object (default `null`)
  27903. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27904. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27905. * @returns a new mesh
  27906. */
  27907. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27908. /**
  27909. * Releases resources associated with this mesh.
  27910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27912. */
  27913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27914. /** @hidden */
  27915. _disposeInstanceSpecificData(): void;
  27916. /** @hidden */
  27917. _disposeThinInstanceSpecificData(): void;
  27918. /**
  27919. * Modifies the mesh geometry according to a displacement map.
  27920. * 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.
  27921. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27922. * @param url is a string, the URL from the image file is to be downloaded.
  27923. * @param minHeight is the lower limit of the displacement.
  27924. * @param maxHeight is the upper limit of the displacement.
  27925. * @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.
  27926. * @param uvOffset is an optional vector2 used to offset UV.
  27927. * @param uvScale is an optional vector2 used to scale UV.
  27928. * @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.
  27929. * @returns the Mesh.
  27930. */
  27931. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27932. /**
  27933. * Modifies the mesh geometry according to a displacementMap buffer.
  27934. * 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.
  27935. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27936. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27937. * @param heightMapWidth is the width of the buffer image.
  27938. * @param heightMapHeight is the height of the buffer image.
  27939. * @param minHeight is the lower limit of the displacement.
  27940. * @param maxHeight is the upper limit of the displacement.
  27941. * @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.
  27942. * @param uvOffset is an optional vector2 used to offset UV.
  27943. * @param uvScale is an optional vector2 used to scale UV.
  27944. * @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.
  27945. * @returns the Mesh.
  27946. */
  27947. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27948. /**
  27949. * Modify the mesh to get a flat shading rendering.
  27950. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27951. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27952. * @returns current mesh
  27953. */
  27954. convertToFlatShadedMesh(): Mesh;
  27955. /**
  27956. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27957. * In other words, more vertices, no more indices and a single bigger VBO.
  27958. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27959. * @returns current mesh
  27960. */
  27961. convertToUnIndexedMesh(): Mesh;
  27962. /**
  27963. * Inverses facet orientations.
  27964. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27965. * @param flipNormals will also inverts the normals
  27966. * @returns current mesh
  27967. */
  27968. flipFaces(flipNormals?: boolean): Mesh;
  27969. /**
  27970. * Increase the number of facets and hence vertices in a mesh
  27971. * Vertex normals are interpolated from existing vertex normals
  27972. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27973. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27974. */
  27975. increaseVertices(numberPerEdge: number): void;
  27976. /**
  27977. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27978. * This will undo any application of covertToFlatShadedMesh
  27979. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27980. */
  27981. forceSharedVertices(): void;
  27982. /** @hidden */
  27983. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27984. /** @hidden */
  27985. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27986. /**
  27987. * Creates a new InstancedMesh object from the mesh model.
  27988. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27989. * @param name defines the name of the new instance
  27990. * @returns a new InstancedMesh
  27991. */
  27992. createInstance(name: string): InstancedMesh;
  27993. /**
  27994. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27995. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27996. * @returns the current mesh
  27997. */
  27998. synchronizeInstances(): Mesh;
  27999. /**
  28000. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28001. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28002. * This should be used together with the simplification to avoid disappearing triangles.
  28003. * @param successCallback an optional success callback to be called after the optimization finished.
  28004. * @returns the current mesh
  28005. */
  28006. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28007. /**
  28008. * Serialize current mesh
  28009. * @param serializationObject defines the object which will receive the serialization data
  28010. */
  28011. serialize(serializationObject: any): void;
  28012. /** @hidden */
  28013. _syncGeometryWithMorphTargetManager(): void;
  28014. /** @hidden */
  28015. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28016. /**
  28017. * Returns a new Mesh object parsed from the source provided.
  28018. * @param parsedMesh is the source
  28019. * @param scene defines the hosting scene
  28020. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28021. * @returns a new Mesh
  28022. */
  28023. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28024. /**
  28025. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28026. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28027. * @param name defines the name of the mesh to create
  28028. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28029. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28030. * @param closePath creates a seam between the first and the last points of each path of the path array
  28031. * @param offset is taken in account only if the `pathArray` is containing a single path
  28032. * @param scene defines the hosting scene
  28033. * @param updatable defines if the mesh must be flagged as updatable
  28034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28035. * @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)
  28036. * @returns a new Mesh
  28037. */
  28038. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28039. /**
  28040. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28041. * @param name defines the name of the mesh to create
  28042. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28043. * @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
  28044. * @param scene defines the hosting scene
  28045. * @param updatable defines if the mesh must be flagged as updatable
  28046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28047. * @returns a new Mesh
  28048. */
  28049. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28050. /**
  28051. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28052. * @param name defines the name of the mesh to create
  28053. * @param size sets the size (float) of each box side (default 1)
  28054. * @param scene defines the hosting scene
  28055. * @param updatable defines if the mesh must be flagged as updatable
  28056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28057. * @returns a new Mesh
  28058. */
  28059. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28060. /**
  28061. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28062. * @param name defines the name of the mesh to create
  28063. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28064. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28065. * @param scene defines the hosting scene
  28066. * @param updatable defines if the mesh must be flagged as updatable
  28067. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28068. * @returns a new Mesh
  28069. */
  28070. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28071. /**
  28072. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28073. * @param name defines the name of the mesh to create
  28074. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28075. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28076. * @param scene defines the hosting scene
  28077. * @returns a new Mesh
  28078. */
  28079. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28080. /**
  28081. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28082. * @param name defines the name of the mesh to create
  28083. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28084. * @param diameterTop set the top cap diameter (floats, default 1)
  28085. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28086. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28087. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28088. * @param scene defines the hosting scene
  28089. * @param updatable defines if the mesh must be flagged as updatable
  28090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28091. * @returns a new Mesh
  28092. */
  28093. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28094. /**
  28095. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28096. * @param name defines the name of the mesh to create
  28097. * @param diameter sets the diameter size (float) of the torus (default 1)
  28098. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28099. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28100. * @param scene defines the hosting scene
  28101. * @param updatable defines if the mesh must be flagged as updatable
  28102. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28103. * @returns a new Mesh
  28104. */
  28105. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28106. /**
  28107. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28108. * @param name defines the name of the mesh to create
  28109. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28110. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28111. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28112. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28113. * @param p the number of windings on X axis (positive integers, default 2)
  28114. * @param q the number of windings on Y axis (positive integers, default 3)
  28115. * @param scene defines the hosting scene
  28116. * @param updatable defines if the mesh must be flagged as updatable
  28117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28118. * @returns a new Mesh
  28119. */
  28120. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28121. /**
  28122. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28123. * @param name defines the name of the mesh to create
  28124. * @param points is an array successive Vector3
  28125. * @param scene defines the hosting scene
  28126. * @param updatable defines if the mesh must be flagged as updatable
  28127. * @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).
  28128. * @returns a new Mesh
  28129. */
  28130. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28131. /**
  28132. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28133. * @param name defines the name of the mesh to create
  28134. * @param points is an array successive Vector3
  28135. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28136. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28137. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28138. * @param scene defines the hosting scene
  28139. * @param updatable defines if the mesh must be flagged as updatable
  28140. * @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)
  28141. * @returns a new Mesh
  28142. */
  28143. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28144. /**
  28145. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28146. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28147. * 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.
  28148. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28149. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28150. * Remember you can only change the shape positions, not their number when updating a polygon.
  28151. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28152. * @param name defines the name of the mesh to create
  28153. * @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
  28154. * @param scene defines the hosting scene
  28155. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28156. * @param updatable defines if the mesh must be flagged as updatable
  28157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28158. * @param earcutInjection can be used to inject your own earcut reference
  28159. * @returns a new Mesh
  28160. */
  28161. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28162. /**
  28163. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28164. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28165. * @param name defines the name of the mesh to create
  28166. * @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
  28167. * @param depth defines the height of extrusion
  28168. * @param scene defines the hosting scene
  28169. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28170. * @param updatable defines if the mesh must be flagged as updatable
  28171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28172. * @param earcutInjection can be used to inject your own earcut reference
  28173. * @returns a new Mesh
  28174. */
  28175. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28176. /**
  28177. * Creates an extruded shape mesh.
  28178. * 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
  28179. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28180. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28181. * @param name defines the name of the mesh to create
  28182. * @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
  28183. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28184. * @param scale is the value to scale the shape
  28185. * @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
  28186. * @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
  28187. * @param scene defines the hosting scene
  28188. * @param updatable defines if the mesh must be flagged as updatable
  28189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28190. * @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)
  28191. * @returns a new Mesh
  28192. */
  28193. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28194. /**
  28195. * Creates an custom extruded shape mesh.
  28196. * The custom extrusion 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#extruded-shapes
  28200. * @param name defines the name of the mesh to create
  28201. * @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
  28202. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28203. * @param scaleFunction is a custom Javascript function called on each path point
  28204. * @param rotationFunction is a custom Javascript function called on each path point
  28205. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28206. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28207. * @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
  28208. * @param scene defines the hosting scene
  28209. * @param updatable defines if the mesh must be flagged as updatable
  28210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28211. * @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)
  28212. * @returns a new Mesh
  28213. */
  28214. 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;
  28215. /**
  28216. * Creates lathe mesh.
  28217. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28218. * Please consider using the same method from the MeshBuilder class instead
  28219. * @param name defines the name of the mesh to create
  28220. * @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
  28221. * @param radius is the radius value of the lathe
  28222. * @param tessellation is the side number of the lathe.
  28223. * @param scene defines the hosting scene
  28224. * @param updatable defines if the mesh must be flagged as updatable
  28225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28226. * @returns a new Mesh
  28227. */
  28228. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28229. /**
  28230. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28231. * @param name defines the name of the mesh to create
  28232. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28233. * @param scene defines the hosting scene
  28234. * @param updatable defines if the mesh must be flagged as updatable
  28235. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28236. * @returns a new Mesh
  28237. */
  28238. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28239. /**
  28240. * Creates a ground mesh.
  28241. * Please consider using the same method from the MeshBuilder class instead
  28242. * @param name defines the name of the mesh to create
  28243. * @param width set the width of the ground
  28244. * @param height set the height of the ground
  28245. * @param subdivisions sets the number of subdivisions per side
  28246. * @param scene defines the hosting scene
  28247. * @param updatable defines if the mesh must be flagged as updatable
  28248. * @returns a new Mesh
  28249. */
  28250. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28251. /**
  28252. * Creates a tiled ground mesh.
  28253. * Please consider using the same method from the MeshBuilder class instead
  28254. * @param name defines the name of the mesh to create
  28255. * @param xmin set the ground minimum X coordinate
  28256. * @param zmin set the ground minimum Y coordinate
  28257. * @param xmax set the ground maximum X coordinate
  28258. * @param zmax set the ground maximum Z coordinate
  28259. * @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
  28260. * @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
  28261. * @param scene defines the hosting scene
  28262. * @param updatable defines if the mesh must be flagged as updatable
  28263. * @returns a new Mesh
  28264. */
  28265. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28266. w: number;
  28267. h: number;
  28268. }, precision: {
  28269. w: number;
  28270. h: number;
  28271. }, scene: Scene, updatable?: boolean): Mesh;
  28272. /**
  28273. * Creates a ground mesh from a height map.
  28274. * Please consider using the same method from the MeshBuilder class instead
  28275. * @see http://doc.babylonjs.com/babylon101/height_map
  28276. * @param name defines the name of the mesh to create
  28277. * @param url sets the URL of the height map image resource
  28278. * @param width set the ground width size
  28279. * @param height set the ground height size
  28280. * @param subdivisions sets the number of subdivision per side
  28281. * @param minHeight is the minimum altitude on the ground
  28282. * @param maxHeight is the maximum altitude on the ground
  28283. * @param scene defines the hosting scene
  28284. * @param updatable defines if the mesh must be flagged as updatable
  28285. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28286. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28287. * @returns a new Mesh
  28288. */
  28289. 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;
  28290. /**
  28291. * Creates a tube mesh.
  28292. * The tube is a parametric shape.
  28293. * It has no predefined shape. Its final shape will depend on the input parameters.
  28294. * Please consider using the same method from the MeshBuilder class instead
  28295. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28296. * @param name defines the name of the mesh to create
  28297. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28298. * @param radius sets the tube radius size
  28299. * @param tessellation is the number of sides on the tubular surface
  28300. * @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
  28301. * @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
  28302. * @param scene defines the hosting scene
  28303. * @param updatable defines if the mesh must be flagged as updatable
  28304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28305. * @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)
  28306. * @returns a new Mesh
  28307. */
  28308. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28309. (i: number, distance: number): number;
  28310. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28311. /**
  28312. * Creates a polyhedron mesh.
  28313. * Please consider using the same method from the MeshBuilder class instead.
  28314. * * 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
  28315. * * The parameter `size` (positive float, default 1) sets the polygon size
  28316. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28317. * * 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`
  28318. * * 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
  28319. * * 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)`)
  28320. * * 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
  28321. * * 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
  28322. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28323. * * 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
  28324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28325. * @param name defines the name of the mesh to create
  28326. * @param options defines the options used to create the mesh
  28327. * @param scene defines the hosting scene
  28328. * @returns a new Mesh
  28329. */
  28330. static CreatePolyhedron(name: string, options: {
  28331. type?: number;
  28332. size?: number;
  28333. sizeX?: number;
  28334. sizeY?: number;
  28335. sizeZ?: number;
  28336. custom?: any;
  28337. faceUV?: Vector4[];
  28338. faceColors?: Color4[];
  28339. updatable?: boolean;
  28340. sideOrientation?: number;
  28341. }, scene: Scene): Mesh;
  28342. /**
  28343. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28344. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28345. * * 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`)
  28346. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28347. * * 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
  28348. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28349. * * 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
  28350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28351. * @param name defines the name of the mesh
  28352. * @param options defines the options used to create the mesh
  28353. * @param scene defines the hosting scene
  28354. * @returns a new Mesh
  28355. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28356. */
  28357. static CreateIcoSphere(name: string, options: {
  28358. radius?: number;
  28359. flat?: boolean;
  28360. subdivisions?: number;
  28361. sideOrientation?: number;
  28362. updatable?: boolean;
  28363. }, scene: Scene): Mesh;
  28364. /**
  28365. * Creates a decal mesh.
  28366. * Please consider using the same method from the MeshBuilder class instead.
  28367. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28368. * @param name defines the name of the mesh
  28369. * @param sourceMesh defines the mesh receiving the decal
  28370. * @param position sets the position of the decal in world coordinates
  28371. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28372. * @param size sets the decal scaling
  28373. * @param angle sets the angle to rotate the decal
  28374. * @returns a new Mesh
  28375. */
  28376. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28377. /**
  28378. * Prepare internal position array for software CPU skinning
  28379. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28380. */
  28381. setPositionsForCPUSkinning(): Float32Array;
  28382. /**
  28383. * Prepare internal normal array for software CPU skinning
  28384. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28385. */
  28386. setNormalsForCPUSkinning(): Float32Array;
  28387. /**
  28388. * Updates the vertex buffer by applying transformation from the bones
  28389. * @param skeleton defines the skeleton to apply to current mesh
  28390. * @returns the current mesh
  28391. */
  28392. applySkeleton(skeleton: Skeleton): Mesh;
  28393. /**
  28394. * 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
  28395. * @param meshes defines the list of meshes to scan
  28396. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28397. */
  28398. static MinMax(meshes: AbstractMesh[]): {
  28399. min: Vector3;
  28400. max: Vector3;
  28401. };
  28402. /**
  28403. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28404. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28405. * @returns a vector3
  28406. */
  28407. static Center(meshesOrMinMaxVector: {
  28408. min: Vector3;
  28409. max: Vector3;
  28410. } | AbstractMesh[]): Vector3;
  28411. /**
  28412. * Merge the array of meshes into a single mesh for performance reasons.
  28413. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28414. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28415. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28416. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28417. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28418. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28419. * @returns a new mesh
  28420. */
  28421. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28422. /** @hidden */
  28423. addInstance(instance: InstancedMesh): void;
  28424. /** @hidden */
  28425. removeInstance(instance: InstancedMesh): void;
  28426. }
  28427. }
  28428. declare module BABYLON {
  28429. /**
  28430. * This is the base class of all the camera used in the application.
  28431. * @see http://doc.babylonjs.com/features/cameras
  28432. */
  28433. export class Camera extends Node {
  28434. /** @hidden */
  28435. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28436. /**
  28437. * This is the default projection mode used by the cameras.
  28438. * It helps recreating a feeling of perspective and better appreciate depth.
  28439. * This is the best way to simulate real life cameras.
  28440. */
  28441. static readonly PERSPECTIVE_CAMERA: number;
  28442. /**
  28443. * This helps creating camera with an orthographic mode.
  28444. * 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.
  28445. */
  28446. static readonly ORTHOGRAPHIC_CAMERA: number;
  28447. /**
  28448. * This is the default FOV mode for perspective cameras.
  28449. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28450. */
  28451. static readonly FOVMODE_VERTICAL_FIXED: number;
  28452. /**
  28453. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28454. */
  28455. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28456. /**
  28457. * This specifies ther is no need for a camera rig.
  28458. * Basically only one eye is rendered corresponding to the camera.
  28459. */
  28460. static readonly RIG_MODE_NONE: number;
  28461. /**
  28462. * Simulates a camera Rig with one blue eye and one red eye.
  28463. * This can be use with 3d blue and red glasses.
  28464. */
  28465. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28466. /**
  28467. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28468. */
  28469. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28470. /**
  28471. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28472. */
  28473. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28474. /**
  28475. * Defines that both eyes of the camera will be rendered over under each other.
  28476. */
  28477. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28478. /**
  28479. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28480. */
  28481. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28482. /**
  28483. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28484. */
  28485. static readonly RIG_MODE_VR: number;
  28486. /**
  28487. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28488. */
  28489. static readonly RIG_MODE_WEBVR: number;
  28490. /**
  28491. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28492. */
  28493. static readonly RIG_MODE_CUSTOM: number;
  28494. /**
  28495. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28496. */
  28497. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28498. /**
  28499. * Define the input manager associated with the camera.
  28500. */
  28501. inputs: CameraInputsManager<Camera>;
  28502. /** @hidden */
  28503. _position: Vector3;
  28504. /**
  28505. * Define the current local position of the camera in the scene
  28506. */
  28507. get position(): Vector3;
  28508. set position(newPosition: Vector3);
  28509. /**
  28510. * The vector the camera should consider as up.
  28511. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28512. */
  28513. upVector: Vector3;
  28514. /**
  28515. * Define the current limit on the left side for an orthographic camera
  28516. * In scene unit
  28517. */
  28518. orthoLeft: Nullable<number>;
  28519. /**
  28520. * Define the current limit on the right side for an orthographic camera
  28521. * In scene unit
  28522. */
  28523. orthoRight: Nullable<number>;
  28524. /**
  28525. * Define the current limit on the bottom side for an orthographic camera
  28526. * In scene unit
  28527. */
  28528. orthoBottom: Nullable<number>;
  28529. /**
  28530. * Define the current limit on the top side for an orthographic camera
  28531. * In scene unit
  28532. */
  28533. orthoTop: Nullable<number>;
  28534. /**
  28535. * Field Of View is set in Radians. (default is 0.8)
  28536. */
  28537. fov: number;
  28538. /**
  28539. * Define the minimum distance the camera can see from.
  28540. * This is important to note that the depth buffer are not infinite and the closer it starts
  28541. * the more your scene might encounter depth fighting issue.
  28542. */
  28543. minZ: number;
  28544. /**
  28545. * Define the maximum distance the camera can see to.
  28546. * This is important to note that the depth buffer are not infinite and the further it end
  28547. * the more your scene might encounter depth fighting issue.
  28548. */
  28549. maxZ: number;
  28550. /**
  28551. * Define the default inertia of the camera.
  28552. * This helps giving a smooth feeling to the camera movement.
  28553. */
  28554. inertia: number;
  28555. /**
  28556. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28557. */
  28558. mode: number;
  28559. /**
  28560. * Define whether the camera is intermediate.
  28561. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28562. */
  28563. isIntermediate: boolean;
  28564. /**
  28565. * Define the viewport of the camera.
  28566. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28567. */
  28568. viewport: Viewport;
  28569. /**
  28570. * Restricts the camera to viewing objects with the same layerMask.
  28571. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28572. */
  28573. layerMask: number;
  28574. /**
  28575. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28576. */
  28577. fovMode: number;
  28578. /**
  28579. * Rig mode of the camera.
  28580. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28581. * This is normally controlled byt the camera themselves as internal use.
  28582. */
  28583. cameraRigMode: number;
  28584. /**
  28585. * Defines the distance between both "eyes" in case of a RIG
  28586. */
  28587. interaxialDistance: number;
  28588. /**
  28589. * Defines if stereoscopic rendering is done side by side or over under.
  28590. */
  28591. isStereoscopicSideBySide: boolean;
  28592. /**
  28593. * 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
  28594. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28595. * else in the scene. (Eg. security camera)
  28596. *
  28597. * 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)
  28598. */
  28599. customRenderTargets: RenderTargetTexture[];
  28600. /**
  28601. * When set, the camera will render to this render target instead of the default canvas
  28602. *
  28603. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28604. */
  28605. outputRenderTarget: Nullable<RenderTargetTexture>;
  28606. /**
  28607. * Observable triggered when the camera view matrix has changed.
  28608. */
  28609. onViewMatrixChangedObservable: Observable<Camera>;
  28610. /**
  28611. * Observable triggered when the camera Projection matrix has changed.
  28612. */
  28613. onProjectionMatrixChangedObservable: Observable<Camera>;
  28614. /**
  28615. * Observable triggered when the inputs have been processed.
  28616. */
  28617. onAfterCheckInputsObservable: Observable<Camera>;
  28618. /**
  28619. * Observable triggered when reset has been called and applied to the camera.
  28620. */
  28621. onRestoreStateObservable: Observable<Camera>;
  28622. /**
  28623. * Is this camera a part of a rig system?
  28624. */
  28625. isRigCamera: boolean;
  28626. /**
  28627. * If isRigCamera set to true this will be set with the parent camera.
  28628. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28629. */
  28630. rigParent?: Camera;
  28631. /** @hidden */
  28632. _cameraRigParams: any;
  28633. /** @hidden */
  28634. _rigCameras: Camera[];
  28635. /** @hidden */
  28636. _rigPostProcess: Nullable<PostProcess>;
  28637. protected _webvrViewMatrix: Matrix;
  28638. /** @hidden */
  28639. _skipRendering: boolean;
  28640. /** @hidden */
  28641. _projectionMatrix: Matrix;
  28642. /** @hidden */
  28643. _postProcesses: Nullable<PostProcess>[];
  28644. /** @hidden */
  28645. _activeMeshes: SmartArray<AbstractMesh>;
  28646. protected _globalPosition: Vector3;
  28647. /** @hidden */
  28648. _computedViewMatrix: Matrix;
  28649. private _doNotComputeProjectionMatrix;
  28650. private _transformMatrix;
  28651. private _frustumPlanes;
  28652. private _refreshFrustumPlanes;
  28653. private _storedFov;
  28654. private _stateStored;
  28655. /**
  28656. * Instantiates a new camera object.
  28657. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28658. * @see http://doc.babylonjs.com/features/cameras
  28659. * @param name Defines the name of the camera in the scene
  28660. * @param position Defines the position of the camera
  28661. * @param scene Defines the scene the camera belongs too
  28662. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28663. */
  28664. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28665. /**
  28666. * Store current camera state (fov, position, etc..)
  28667. * @returns the camera
  28668. */
  28669. storeState(): Camera;
  28670. /**
  28671. * Restores the camera state values if it has been stored. You must call storeState() first
  28672. */
  28673. protected _restoreStateValues(): boolean;
  28674. /**
  28675. * Restored camera state. You must call storeState() first.
  28676. * @returns true if restored and false otherwise
  28677. */
  28678. restoreState(): boolean;
  28679. /**
  28680. * Gets the class name of the camera.
  28681. * @returns the class name
  28682. */
  28683. getClassName(): string;
  28684. /** @hidden */
  28685. readonly _isCamera: boolean;
  28686. /**
  28687. * Gets a string representation of the camera useful for debug purpose.
  28688. * @param fullDetails Defines that a more verboe level of logging is required
  28689. * @returns the string representation
  28690. */
  28691. toString(fullDetails?: boolean): string;
  28692. /**
  28693. * Gets the current world space position of the camera.
  28694. */
  28695. get globalPosition(): Vector3;
  28696. /**
  28697. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28698. * @returns the active meshe list
  28699. */
  28700. getActiveMeshes(): SmartArray<AbstractMesh>;
  28701. /**
  28702. * Check whether a mesh is part of the current active mesh list of the camera
  28703. * @param mesh Defines the mesh to check
  28704. * @returns true if active, false otherwise
  28705. */
  28706. isActiveMesh(mesh: Mesh): boolean;
  28707. /**
  28708. * Is this camera ready to be used/rendered
  28709. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28710. * @return true if the camera is ready
  28711. */
  28712. isReady(completeCheck?: boolean): boolean;
  28713. /** @hidden */
  28714. _initCache(): void;
  28715. /** @hidden */
  28716. _updateCache(ignoreParentClass?: boolean): void;
  28717. /** @hidden */
  28718. _isSynchronized(): boolean;
  28719. /** @hidden */
  28720. _isSynchronizedViewMatrix(): boolean;
  28721. /** @hidden */
  28722. _isSynchronizedProjectionMatrix(): boolean;
  28723. /**
  28724. * Attach the input controls to a specific dom element to get the input from.
  28725. * @param element Defines the element the controls should be listened from
  28726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28727. */
  28728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28729. /**
  28730. * Detach the current controls from the specified dom element.
  28731. * @param element Defines the element to stop listening the inputs from
  28732. */
  28733. detachControl(element: HTMLElement): void;
  28734. /**
  28735. * Update the camera state according to the different inputs gathered during the frame.
  28736. */
  28737. update(): void;
  28738. /** @hidden */
  28739. _checkInputs(): void;
  28740. /** @hidden */
  28741. get rigCameras(): Camera[];
  28742. /**
  28743. * Gets the post process used by the rig cameras
  28744. */
  28745. get rigPostProcess(): Nullable<PostProcess>;
  28746. /**
  28747. * Internal, gets the first post proces.
  28748. * @returns the first post process to be run on this camera.
  28749. */
  28750. _getFirstPostProcess(): Nullable<PostProcess>;
  28751. private _cascadePostProcessesToRigCams;
  28752. /**
  28753. * Attach a post process to the camera.
  28754. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28755. * @param postProcess The post process to attach to the camera
  28756. * @param insertAt The position of the post process in case several of them are in use in the scene
  28757. * @returns the position the post process has been inserted at
  28758. */
  28759. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28760. /**
  28761. * Detach a post process to the camera.
  28762. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28763. * @param postProcess The post process to detach from the camera
  28764. */
  28765. detachPostProcess(postProcess: PostProcess): void;
  28766. /**
  28767. * Gets the current world matrix of the camera
  28768. */
  28769. getWorldMatrix(): Matrix;
  28770. /** @hidden */
  28771. _getViewMatrix(): Matrix;
  28772. /**
  28773. * Gets the current view matrix of the camera.
  28774. * @param force forces the camera to recompute the matrix without looking at the cached state
  28775. * @returns the view matrix
  28776. */
  28777. getViewMatrix(force?: boolean): Matrix;
  28778. /**
  28779. * Freeze the projection matrix.
  28780. * It will prevent the cache check of the camera projection compute and can speed up perf
  28781. * if no parameter of the camera are meant to change
  28782. * @param projection Defines manually a projection if necessary
  28783. */
  28784. freezeProjectionMatrix(projection?: Matrix): void;
  28785. /**
  28786. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28787. */
  28788. unfreezeProjectionMatrix(): void;
  28789. /**
  28790. * Gets the current projection matrix of the camera.
  28791. * @param force forces the camera to recompute the matrix without looking at the cached state
  28792. * @returns the projection matrix
  28793. */
  28794. getProjectionMatrix(force?: boolean): Matrix;
  28795. /**
  28796. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28797. * @returns a Matrix
  28798. */
  28799. getTransformationMatrix(): Matrix;
  28800. private _updateFrustumPlanes;
  28801. /**
  28802. * Checks if a cullable object (mesh...) is in the camera frustum
  28803. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28804. * @param target The object to check
  28805. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28806. * @returns true if the object is in frustum otherwise false
  28807. */
  28808. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28809. /**
  28810. * Checks if a cullable object (mesh...) is in the camera frustum
  28811. * Unlike isInFrustum this cheks the full bounding box
  28812. * @param target The object to check
  28813. * @returns true if the object is in frustum otherwise false
  28814. */
  28815. isCompletelyInFrustum(target: ICullable): boolean;
  28816. /**
  28817. * Gets a ray in the forward direction from the camera.
  28818. * @param length Defines the length of the ray to create
  28819. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28820. * @param origin Defines the start point of the ray which defaults to the camera position
  28821. * @returns the forward ray
  28822. */
  28823. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28824. /**
  28825. * Releases resources associated with this node.
  28826. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28827. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28828. */
  28829. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28830. /** @hidden */
  28831. _isLeftCamera: boolean;
  28832. /**
  28833. * Gets the left camera of a rig setup in case of Rigged Camera
  28834. */
  28835. get isLeftCamera(): boolean;
  28836. /** @hidden */
  28837. _isRightCamera: boolean;
  28838. /**
  28839. * Gets the right camera of a rig setup in case of Rigged Camera
  28840. */
  28841. get isRightCamera(): boolean;
  28842. /**
  28843. * Gets the left camera of a rig setup in case of Rigged Camera
  28844. */
  28845. get leftCamera(): Nullable<FreeCamera>;
  28846. /**
  28847. * Gets the right camera of a rig setup in case of Rigged Camera
  28848. */
  28849. get rightCamera(): Nullable<FreeCamera>;
  28850. /**
  28851. * Gets the left camera target of a rig setup in case of Rigged Camera
  28852. * @returns the target position
  28853. */
  28854. getLeftTarget(): Nullable<Vector3>;
  28855. /**
  28856. * Gets the right camera target of a rig setup in case of Rigged Camera
  28857. * @returns the target position
  28858. */
  28859. getRightTarget(): Nullable<Vector3>;
  28860. /**
  28861. * @hidden
  28862. */
  28863. setCameraRigMode(mode: number, rigParams: any): void;
  28864. /** @hidden */
  28865. static _setStereoscopicRigMode(camera: Camera): void;
  28866. /** @hidden */
  28867. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28868. /** @hidden */
  28869. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28870. /** @hidden */
  28871. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28872. /** @hidden */
  28873. _getVRProjectionMatrix(): Matrix;
  28874. protected _updateCameraRotationMatrix(): void;
  28875. protected _updateWebVRCameraRotationMatrix(): void;
  28876. /**
  28877. * This function MUST be overwritten by the different WebVR cameras available.
  28878. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28879. * @hidden
  28880. */
  28881. _getWebVRProjectionMatrix(): Matrix;
  28882. /**
  28883. * This function MUST be overwritten by the different WebVR cameras available.
  28884. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28885. * @hidden
  28886. */
  28887. _getWebVRViewMatrix(): Matrix;
  28888. /** @hidden */
  28889. setCameraRigParameter(name: string, value: any): void;
  28890. /**
  28891. * needs to be overridden by children so sub has required properties to be copied
  28892. * @hidden
  28893. */
  28894. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28895. /**
  28896. * May need to be overridden by children
  28897. * @hidden
  28898. */
  28899. _updateRigCameras(): void;
  28900. /** @hidden */
  28901. _setupInputs(): void;
  28902. /**
  28903. * Serialiaze the camera setup to a json represention
  28904. * @returns the JSON representation
  28905. */
  28906. serialize(): any;
  28907. /**
  28908. * Clones the current camera.
  28909. * @param name The cloned camera name
  28910. * @returns the cloned camera
  28911. */
  28912. clone(name: string): Camera;
  28913. /**
  28914. * Gets the direction of the camera relative to a given local axis.
  28915. * @param localAxis Defines the reference axis to provide a relative direction.
  28916. * @return the direction
  28917. */
  28918. getDirection(localAxis: Vector3): Vector3;
  28919. /**
  28920. * Returns the current camera absolute rotation
  28921. */
  28922. get absoluteRotation(): Quaternion;
  28923. /**
  28924. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28925. * @param localAxis Defines the reference axis to provide a relative direction.
  28926. * @param result Defines the vector to store the result in
  28927. */
  28928. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28929. /**
  28930. * Gets a camera constructor for a given camera type
  28931. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28932. * @param name The name of the camera the result will be able to instantiate
  28933. * @param scene The scene the result will construct the camera in
  28934. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28935. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28936. * @returns a factory method to construc the camera
  28937. */
  28938. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28939. /**
  28940. * Compute the world matrix of the camera.
  28941. * @returns the camera world matrix
  28942. */
  28943. computeWorldMatrix(): Matrix;
  28944. /**
  28945. * Parse a JSON and creates the camera from the parsed information
  28946. * @param parsedCamera The JSON to parse
  28947. * @param scene The scene to instantiate the camera in
  28948. * @returns the newly constructed camera
  28949. */
  28950. static Parse(parsedCamera: any, scene: Scene): Camera;
  28951. }
  28952. }
  28953. declare module BABYLON {
  28954. /**
  28955. * Class containing static functions to help procedurally build meshes
  28956. */
  28957. export class DiscBuilder {
  28958. /**
  28959. * Creates a plane polygonal mesh. By default, this is a disc
  28960. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28961. * * 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
  28962. * * 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
  28963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28964. * * 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
  28965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28966. * @param name defines the name of the mesh
  28967. * @param options defines the options used to create the mesh
  28968. * @param scene defines the hosting scene
  28969. * @returns the plane polygonal mesh
  28970. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28971. */
  28972. static CreateDisc(name: string, options: {
  28973. radius?: number;
  28974. tessellation?: number;
  28975. arc?: number;
  28976. updatable?: boolean;
  28977. sideOrientation?: number;
  28978. frontUVs?: Vector4;
  28979. backUVs?: Vector4;
  28980. }, scene?: Nullable<Scene>): Mesh;
  28981. }
  28982. }
  28983. declare module BABYLON {
  28984. /**
  28985. * Options to be used when creating a FresnelParameters.
  28986. */
  28987. export type IFresnelParametersCreationOptions = {
  28988. /**
  28989. * Define the color used on edges (grazing angle)
  28990. */
  28991. leftColor?: Color3;
  28992. /**
  28993. * Define the color used on center
  28994. */
  28995. rightColor?: Color3;
  28996. /**
  28997. * Define bias applied to computed fresnel term
  28998. */
  28999. bias?: number;
  29000. /**
  29001. * Defined the power exponent applied to fresnel term
  29002. */
  29003. power?: number;
  29004. /**
  29005. * Define if the fresnel effect is enable or not.
  29006. */
  29007. isEnabled?: boolean;
  29008. };
  29009. /**
  29010. * Serialized format for FresnelParameters.
  29011. */
  29012. export type IFresnelParametersSerialized = {
  29013. /**
  29014. * Define the color used on edges (grazing angle) [as an array]
  29015. */
  29016. leftColor: number[];
  29017. /**
  29018. * Define the color used on center [as an array]
  29019. */
  29020. rightColor: number[];
  29021. /**
  29022. * Define bias applied to computed fresnel term
  29023. */
  29024. bias: number;
  29025. /**
  29026. * Defined the power exponent applied to fresnel term
  29027. */
  29028. power?: number;
  29029. /**
  29030. * Define if the fresnel effect is enable or not.
  29031. */
  29032. isEnabled: boolean;
  29033. };
  29034. /**
  29035. * This represents all the required information to add a fresnel effect on a material:
  29036. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29037. */
  29038. export class FresnelParameters {
  29039. private _isEnabled;
  29040. /**
  29041. * Define if the fresnel effect is enable or not.
  29042. */
  29043. get isEnabled(): boolean;
  29044. set isEnabled(value: boolean);
  29045. /**
  29046. * Define the color used on edges (grazing angle)
  29047. */
  29048. leftColor: Color3;
  29049. /**
  29050. * Define the color used on center
  29051. */
  29052. rightColor: Color3;
  29053. /**
  29054. * Define bias applied to computed fresnel term
  29055. */
  29056. bias: number;
  29057. /**
  29058. * Defined the power exponent applied to fresnel term
  29059. */
  29060. power: number;
  29061. /**
  29062. * Creates a new FresnelParameters object.
  29063. *
  29064. * @param options provide your own settings to optionally to override defaults
  29065. */
  29066. constructor(options?: IFresnelParametersCreationOptions);
  29067. /**
  29068. * Clones the current fresnel and its valuues
  29069. * @returns a clone fresnel configuration
  29070. */
  29071. clone(): FresnelParameters;
  29072. /**
  29073. * Determines equality between FresnelParameters objects
  29074. * @param otherFresnelParameters defines the second operand
  29075. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29076. */
  29077. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29078. /**
  29079. * Serializes the current fresnel parameters to a JSON representation.
  29080. * @return the JSON serialization
  29081. */
  29082. serialize(): IFresnelParametersSerialized;
  29083. /**
  29084. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29085. * @param parsedFresnelParameters Define the JSON representation
  29086. * @returns the parsed parameters
  29087. */
  29088. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29089. }
  29090. }
  29091. declare module BABYLON {
  29092. /**
  29093. * This groups all the flags used to control the materials channel.
  29094. */
  29095. export class MaterialFlags {
  29096. private static _DiffuseTextureEnabled;
  29097. /**
  29098. * Are diffuse textures enabled in the application.
  29099. */
  29100. static get DiffuseTextureEnabled(): boolean;
  29101. static set DiffuseTextureEnabled(value: boolean);
  29102. private static _DetailTextureEnabled;
  29103. /**
  29104. * Are detail textures enabled in the application.
  29105. */
  29106. static get DetailTextureEnabled(): boolean;
  29107. static set DetailTextureEnabled(value: boolean);
  29108. private static _AmbientTextureEnabled;
  29109. /**
  29110. * Are ambient textures enabled in the application.
  29111. */
  29112. static get AmbientTextureEnabled(): boolean;
  29113. static set AmbientTextureEnabled(value: boolean);
  29114. private static _OpacityTextureEnabled;
  29115. /**
  29116. * Are opacity textures enabled in the application.
  29117. */
  29118. static get OpacityTextureEnabled(): boolean;
  29119. static set OpacityTextureEnabled(value: boolean);
  29120. private static _ReflectionTextureEnabled;
  29121. /**
  29122. * Are reflection textures enabled in the application.
  29123. */
  29124. static get ReflectionTextureEnabled(): boolean;
  29125. static set ReflectionTextureEnabled(value: boolean);
  29126. private static _EmissiveTextureEnabled;
  29127. /**
  29128. * Are emissive textures enabled in the application.
  29129. */
  29130. static get EmissiveTextureEnabled(): boolean;
  29131. static set EmissiveTextureEnabled(value: boolean);
  29132. private static _SpecularTextureEnabled;
  29133. /**
  29134. * Are specular textures enabled in the application.
  29135. */
  29136. static get SpecularTextureEnabled(): boolean;
  29137. static set SpecularTextureEnabled(value: boolean);
  29138. private static _BumpTextureEnabled;
  29139. /**
  29140. * Are bump textures enabled in the application.
  29141. */
  29142. static get BumpTextureEnabled(): boolean;
  29143. static set BumpTextureEnabled(value: boolean);
  29144. private static _LightmapTextureEnabled;
  29145. /**
  29146. * Are lightmap textures enabled in the application.
  29147. */
  29148. static get LightmapTextureEnabled(): boolean;
  29149. static set LightmapTextureEnabled(value: boolean);
  29150. private static _RefractionTextureEnabled;
  29151. /**
  29152. * Are refraction textures enabled in the application.
  29153. */
  29154. static get RefractionTextureEnabled(): boolean;
  29155. static set RefractionTextureEnabled(value: boolean);
  29156. private static _ColorGradingTextureEnabled;
  29157. /**
  29158. * Are color grading textures enabled in the application.
  29159. */
  29160. static get ColorGradingTextureEnabled(): boolean;
  29161. static set ColorGradingTextureEnabled(value: boolean);
  29162. private static _FresnelEnabled;
  29163. /**
  29164. * Are fresnels enabled in the application.
  29165. */
  29166. static get FresnelEnabled(): boolean;
  29167. static set FresnelEnabled(value: boolean);
  29168. private static _ClearCoatTextureEnabled;
  29169. /**
  29170. * Are clear coat textures enabled in the application.
  29171. */
  29172. static get ClearCoatTextureEnabled(): boolean;
  29173. static set ClearCoatTextureEnabled(value: boolean);
  29174. private static _ClearCoatBumpTextureEnabled;
  29175. /**
  29176. * Are clear coat bump textures enabled in the application.
  29177. */
  29178. static get ClearCoatBumpTextureEnabled(): boolean;
  29179. static set ClearCoatBumpTextureEnabled(value: boolean);
  29180. private static _ClearCoatTintTextureEnabled;
  29181. /**
  29182. * Are clear coat tint textures enabled in the application.
  29183. */
  29184. static get ClearCoatTintTextureEnabled(): boolean;
  29185. static set ClearCoatTintTextureEnabled(value: boolean);
  29186. private static _SheenTextureEnabled;
  29187. /**
  29188. * Are sheen textures enabled in the application.
  29189. */
  29190. static get SheenTextureEnabled(): boolean;
  29191. static set SheenTextureEnabled(value: boolean);
  29192. private static _AnisotropicTextureEnabled;
  29193. /**
  29194. * Are anisotropic textures enabled in the application.
  29195. */
  29196. static get AnisotropicTextureEnabled(): boolean;
  29197. static set AnisotropicTextureEnabled(value: boolean);
  29198. private static _ThicknessTextureEnabled;
  29199. /**
  29200. * Are thickness textures enabled in the application.
  29201. */
  29202. static get ThicknessTextureEnabled(): boolean;
  29203. static set ThicknessTextureEnabled(value: boolean);
  29204. }
  29205. }
  29206. declare module BABYLON {
  29207. /** @hidden */
  29208. export var defaultFragmentDeclaration: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module BABYLON {
  29214. /** @hidden */
  29215. export var defaultUboDeclaration: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module BABYLON {
  29221. /** @hidden */
  29222. export var lightFragmentDeclaration: {
  29223. name: string;
  29224. shader: string;
  29225. };
  29226. }
  29227. declare module BABYLON {
  29228. /** @hidden */
  29229. export var lightUboDeclaration: {
  29230. name: string;
  29231. shader: string;
  29232. };
  29233. }
  29234. declare module BABYLON {
  29235. /** @hidden */
  29236. export var lightsFragmentFunctions: {
  29237. name: string;
  29238. shader: string;
  29239. };
  29240. }
  29241. declare module BABYLON {
  29242. /** @hidden */
  29243. export var shadowsFragmentFunctions: {
  29244. name: string;
  29245. shader: string;
  29246. };
  29247. }
  29248. declare module BABYLON {
  29249. /** @hidden */
  29250. export var fresnelFunction: {
  29251. name: string;
  29252. shader: string;
  29253. };
  29254. }
  29255. declare module BABYLON {
  29256. /** @hidden */
  29257. export var bumpFragmentMainFunctions: {
  29258. name: string;
  29259. shader: string;
  29260. };
  29261. }
  29262. declare module BABYLON {
  29263. /** @hidden */
  29264. export var bumpFragmentFunctions: {
  29265. name: string;
  29266. shader: string;
  29267. };
  29268. }
  29269. declare module BABYLON {
  29270. /** @hidden */
  29271. export var logDepthDeclaration: {
  29272. name: string;
  29273. shader: string;
  29274. };
  29275. }
  29276. declare module BABYLON {
  29277. /** @hidden */
  29278. export var bumpFragment: {
  29279. name: string;
  29280. shader: string;
  29281. };
  29282. }
  29283. declare module BABYLON {
  29284. /** @hidden */
  29285. export var depthPrePass: {
  29286. name: string;
  29287. shader: string;
  29288. };
  29289. }
  29290. declare module BABYLON {
  29291. /** @hidden */
  29292. export var lightFragment: {
  29293. name: string;
  29294. shader: string;
  29295. };
  29296. }
  29297. declare module BABYLON {
  29298. /** @hidden */
  29299. export var logDepthFragment: {
  29300. name: string;
  29301. shader: string;
  29302. };
  29303. }
  29304. declare module BABYLON {
  29305. /** @hidden */
  29306. export var defaultPixelShader: {
  29307. name: string;
  29308. shader: string;
  29309. };
  29310. }
  29311. declare module BABYLON {
  29312. /** @hidden */
  29313. export var defaultVertexDeclaration: {
  29314. name: string;
  29315. shader: string;
  29316. };
  29317. }
  29318. declare module BABYLON {
  29319. /** @hidden */
  29320. export var bumpVertexDeclaration: {
  29321. name: string;
  29322. shader: string;
  29323. };
  29324. }
  29325. declare module BABYLON {
  29326. /** @hidden */
  29327. export var bumpVertex: {
  29328. name: string;
  29329. shader: string;
  29330. };
  29331. }
  29332. declare module BABYLON {
  29333. /** @hidden */
  29334. export var fogVertex: {
  29335. name: string;
  29336. shader: string;
  29337. };
  29338. }
  29339. declare module BABYLON {
  29340. /** @hidden */
  29341. export var shadowsVertex: {
  29342. name: string;
  29343. shader: string;
  29344. };
  29345. }
  29346. declare module BABYLON {
  29347. /** @hidden */
  29348. export var pointCloudVertex: {
  29349. name: string;
  29350. shader: string;
  29351. };
  29352. }
  29353. declare module BABYLON {
  29354. /** @hidden */
  29355. export var logDepthVertex: {
  29356. name: string;
  29357. shader: string;
  29358. };
  29359. }
  29360. declare module BABYLON {
  29361. /** @hidden */
  29362. export var defaultVertexShader: {
  29363. name: string;
  29364. shader: string;
  29365. };
  29366. }
  29367. declare module BABYLON {
  29368. /**
  29369. * @hidden
  29370. */
  29371. export interface IMaterialDetailMapDefines {
  29372. DETAIL: boolean;
  29373. DETAILDIRECTUV: number;
  29374. DETAIL_NORMALBLENDMETHOD: number;
  29375. /** @hidden */
  29376. _areTexturesDirty: boolean;
  29377. }
  29378. /**
  29379. * Define the code related to the detail map parameters of a material
  29380. *
  29381. * Inspired from:
  29382. * 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
  29383. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29384. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29385. */
  29386. export class DetailMapConfiguration {
  29387. private _texture;
  29388. /**
  29389. * The detail texture of the material.
  29390. */
  29391. texture: Nullable<BaseTexture>;
  29392. /**
  29393. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29394. * Bigger values mean stronger blending
  29395. */
  29396. diffuseBlendLevel: number;
  29397. /**
  29398. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29399. * Bigger values mean stronger blending. Only used with PBR materials
  29400. */
  29401. roughnessBlendLevel: number;
  29402. /**
  29403. * Defines how strong the bump effect from the detail map is
  29404. * Bigger values mean stronger effect
  29405. */
  29406. bumpLevel: number;
  29407. private _normalBlendMethod;
  29408. /**
  29409. * The method used to blend the bump and detail normals together
  29410. */
  29411. normalBlendMethod: number;
  29412. private _isEnabled;
  29413. /**
  29414. * Enable or disable the detail map on this material
  29415. */
  29416. isEnabled: boolean;
  29417. /** @hidden */
  29418. private _internalMarkAllSubMeshesAsTexturesDirty;
  29419. /** @hidden */
  29420. _markAllSubMeshesAsTexturesDirty(): void;
  29421. /**
  29422. * Instantiate a new detail map
  29423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29424. */
  29425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29426. /**
  29427. * Gets whether the submesh is ready to be used or not.
  29428. * @param defines the list of "defines" to update.
  29429. * @param scene defines the scene the material belongs to.
  29430. * @returns - boolean indicating that the submesh is ready or not.
  29431. */
  29432. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29433. /**
  29434. * Update the defines for detail map usage
  29435. * @param defines the list of "defines" to update.
  29436. * @param scene defines the scene the material belongs to.
  29437. */
  29438. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29439. /**
  29440. * Binds the material data.
  29441. * @param uniformBuffer defines the Uniform buffer to fill in.
  29442. * @param scene defines the scene the material belongs to.
  29443. * @param isFrozen defines whether the material is frozen or not.
  29444. */
  29445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29446. /**
  29447. * Checks to see if a texture is used in the material.
  29448. * @param texture - Base texture to use.
  29449. * @returns - Boolean specifying if a texture is used in the material.
  29450. */
  29451. hasTexture(texture: BaseTexture): boolean;
  29452. /**
  29453. * Returns an array of the actively used textures.
  29454. * @param activeTextures Array of BaseTextures
  29455. */
  29456. getActiveTextures(activeTextures: BaseTexture[]): void;
  29457. /**
  29458. * Returns the animatable textures.
  29459. * @param animatables Array of animatable textures.
  29460. */
  29461. getAnimatables(animatables: IAnimatable[]): void;
  29462. /**
  29463. * Disposes the resources of the material.
  29464. * @param forceDisposeTextures - Forces the disposal of all textures.
  29465. */
  29466. dispose(forceDisposeTextures?: boolean): void;
  29467. /**
  29468. * Get the current class name useful for serialization or dynamic coding.
  29469. * @returns "DetailMap"
  29470. */
  29471. getClassName(): string;
  29472. /**
  29473. * Add the required uniforms to the current list.
  29474. * @param uniforms defines the current uniform list.
  29475. */
  29476. static AddUniforms(uniforms: string[]): void;
  29477. /**
  29478. * Add the required samplers to the current list.
  29479. * @param samplers defines the current sampler list.
  29480. */
  29481. static AddSamplers(samplers: string[]): void;
  29482. /**
  29483. * Add the required uniforms to the current buffer.
  29484. * @param uniformBuffer defines the current uniform buffer.
  29485. */
  29486. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29487. /**
  29488. * Makes a duplicate of the current instance into another one.
  29489. * @param detailMap define the instance where to copy the info
  29490. */
  29491. copyTo(detailMap: DetailMapConfiguration): void;
  29492. /**
  29493. * Serializes this detail map instance
  29494. * @returns - An object with the serialized instance.
  29495. */
  29496. serialize(): any;
  29497. /**
  29498. * Parses a detail map setting from a serialized object.
  29499. * @param source - Serialized object.
  29500. * @param scene Defines the scene we are parsing for
  29501. * @param rootUrl Defines the rootUrl to load from
  29502. */
  29503. parse(source: any, scene: Scene, rootUrl: string): void;
  29504. }
  29505. }
  29506. declare module BABYLON {
  29507. /** @hidden */
  29508. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29509. MAINUV1: boolean;
  29510. MAINUV2: boolean;
  29511. DIFFUSE: boolean;
  29512. DIFFUSEDIRECTUV: number;
  29513. DETAIL: boolean;
  29514. DETAILDIRECTUV: number;
  29515. DETAIL_NORMALBLENDMETHOD: number;
  29516. AMBIENT: boolean;
  29517. AMBIENTDIRECTUV: number;
  29518. OPACITY: boolean;
  29519. OPACITYDIRECTUV: number;
  29520. OPACITYRGB: boolean;
  29521. REFLECTION: boolean;
  29522. EMISSIVE: boolean;
  29523. EMISSIVEDIRECTUV: number;
  29524. SPECULAR: boolean;
  29525. SPECULARDIRECTUV: number;
  29526. BUMP: boolean;
  29527. BUMPDIRECTUV: number;
  29528. PARALLAX: boolean;
  29529. PARALLAXOCCLUSION: boolean;
  29530. SPECULAROVERALPHA: boolean;
  29531. CLIPPLANE: boolean;
  29532. CLIPPLANE2: boolean;
  29533. CLIPPLANE3: boolean;
  29534. CLIPPLANE4: boolean;
  29535. CLIPPLANE5: boolean;
  29536. CLIPPLANE6: boolean;
  29537. ALPHATEST: boolean;
  29538. DEPTHPREPASS: boolean;
  29539. ALPHAFROMDIFFUSE: boolean;
  29540. POINTSIZE: boolean;
  29541. FOG: boolean;
  29542. SPECULARTERM: boolean;
  29543. DIFFUSEFRESNEL: boolean;
  29544. OPACITYFRESNEL: boolean;
  29545. REFLECTIONFRESNEL: boolean;
  29546. REFRACTIONFRESNEL: boolean;
  29547. EMISSIVEFRESNEL: boolean;
  29548. FRESNEL: boolean;
  29549. NORMAL: boolean;
  29550. UV1: boolean;
  29551. UV2: boolean;
  29552. VERTEXCOLOR: boolean;
  29553. VERTEXALPHA: boolean;
  29554. NUM_BONE_INFLUENCERS: number;
  29555. BonesPerMesh: number;
  29556. BONETEXTURE: boolean;
  29557. INSTANCES: boolean;
  29558. THIN_INSTANCES: boolean;
  29559. GLOSSINESS: boolean;
  29560. ROUGHNESS: boolean;
  29561. EMISSIVEASILLUMINATION: boolean;
  29562. LINKEMISSIVEWITHDIFFUSE: boolean;
  29563. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29564. LIGHTMAP: boolean;
  29565. LIGHTMAPDIRECTUV: number;
  29566. OBJECTSPACE_NORMALMAP: boolean;
  29567. USELIGHTMAPASSHADOWMAP: boolean;
  29568. REFLECTIONMAP_3D: boolean;
  29569. REFLECTIONMAP_SPHERICAL: boolean;
  29570. REFLECTIONMAP_PLANAR: boolean;
  29571. REFLECTIONMAP_CUBIC: boolean;
  29572. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29573. REFLECTIONMAP_PROJECTION: boolean;
  29574. REFLECTIONMAP_SKYBOX: boolean;
  29575. REFLECTIONMAP_EXPLICIT: boolean;
  29576. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29577. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29578. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29579. INVERTCUBICMAP: boolean;
  29580. LOGARITHMICDEPTH: boolean;
  29581. REFRACTION: boolean;
  29582. REFRACTIONMAP_3D: boolean;
  29583. REFLECTIONOVERALPHA: boolean;
  29584. TWOSIDEDLIGHTING: boolean;
  29585. SHADOWFLOAT: boolean;
  29586. MORPHTARGETS: boolean;
  29587. MORPHTARGETS_NORMAL: boolean;
  29588. MORPHTARGETS_TANGENT: boolean;
  29589. MORPHTARGETS_UV: boolean;
  29590. NUM_MORPH_INFLUENCERS: number;
  29591. NONUNIFORMSCALING: boolean;
  29592. PREMULTIPLYALPHA: boolean;
  29593. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29594. ALPHABLEND: boolean;
  29595. RGBDLIGHTMAP: boolean;
  29596. RGBDREFLECTION: boolean;
  29597. RGBDREFRACTION: boolean;
  29598. IMAGEPROCESSING: boolean;
  29599. VIGNETTE: boolean;
  29600. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29601. VIGNETTEBLENDMODEOPAQUE: boolean;
  29602. TONEMAPPING: boolean;
  29603. TONEMAPPING_ACES: boolean;
  29604. CONTRAST: boolean;
  29605. COLORCURVES: boolean;
  29606. COLORGRADING: boolean;
  29607. COLORGRADING3D: boolean;
  29608. SAMPLER3DGREENDEPTH: boolean;
  29609. SAMPLER3DBGRMAP: boolean;
  29610. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29611. MULTIVIEW: boolean;
  29612. /**
  29613. * If the reflection texture on this material is in linear color space
  29614. * @hidden
  29615. */
  29616. IS_REFLECTION_LINEAR: boolean;
  29617. /**
  29618. * If the refraction texture on this material is in linear color space
  29619. * @hidden
  29620. */
  29621. IS_REFRACTION_LINEAR: boolean;
  29622. EXPOSURE: boolean;
  29623. constructor();
  29624. setReflectionMode(modeToEnable: string): void;
  29625. }
  29626. /**
  29627. * This is the default material used in Babylon. It is the best trade off between quality
  29628. * and performances.
  29629. * @see http://doc.babylonjs.com/babylon101/materials
  29630. */
  29631. export class StandardMaterial extends PushMaterial {
  29632. private _diffuseTexture;
  29633. /**
  29634. * The basic texture of the material as viewed under a light.
  29635. */
  29636. diffuseTexture: Nullable<BaseTexture>;
  29637. private _ambientTexture;
  29638. /**
  29639. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29640. */
  29641. ambientTexture: Nullable<BaseTexture>;
  29642. private _opacityTexture;
  29643. /**
  29644. * Define the transparency of the material from a texture.
  29645. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29646. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29647. */
  29648. opacityTexture: Nullable<BaseTexture>;
  29649. private _reflectionTexture;
  29650. /**
  29651. * Define the texture used to display the reflection.
  29652. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29653. */
  29654. reflectionTexture: Nullable<BaseTexture>;
  29655. private _emissiveTexture;
  29656. /**
  29657. * Define texture of the material as if self lit.
  29658. * This will be mixed in the final result even in the absence of light.
  29659. */
  29660. emissiveTexture: Nullable<BaseTexture>;
  29661. private _specularTexture;
  29662. /**
  29663. * Define how the color and intensity of the highlight given by the light in the material.
  29664. */
  29665. specularTexture: Nullable<BaseTexture>;
  29666. private _bumpTexture;
  29667. /**
  29668. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29669. * 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.
  29670. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29671. */
  29672. bumpTexture: Nullable<BaseTexture>;
  29673. private _lightmapTexture;
  29674. /**
  29675. * Complex lighting can be computationally expensive to compute at runtime.
  29676. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29677. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29678. */
  29679. lightmapTexture: Nullable<BaseTexture>;
  29680. private _refractionTexture;
  29681. /**
  29682. * Define the texture used to display the refraction.
  29683. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29684. */
  29685. refractionTexture: Nullable<BaseTexture>;
  29686. /**
  29687. * The color of the material lit by the environmental background lighting.
  29688. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29689. */
  29690. ambientColor: Color3;
  29691. /**
  29692. * The basic color of the material as viewed under a light.
  29693. */
  29694. diffuseColor: Color3;
  29695. /**
  29696. * Define how the color and intensity of the highlight given by the light in the material.
  29697. */
  29698. specularColor: Color3;
  29699. /**
  29700. * Define the color of the material as if self lit.
  29701. * This will be mixed in the final result even in the absence of light.
  29702. */
  29703. emissiveColor: Color3;
  29704. /**
  29705. * Defines how sharp are the highlights in the material.
  29706. * The bigger the value the sharper giving a more glossy feeling to the result.
  29707. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29708. */
  29709. specularPower: number;
  29710. private _useAlphaFromDiffuseTexture;
  29711. /**
  29712. * Does the transparency come from the diffuse texture alpha channel.
  29713. */
  29714. useAlphaFromDiffuseTexture: boolean;
  29715. private _useEmissiveAsIllumination;
  29716. /**
  29717. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29718. */
  29719. useEmissiveAsIllumination: boolean;
  29720. private _linkEmissiveWithDiffuse;
  29721. /**
  29722. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29723. * the emissive level when the final color is close to one.
  29724. */
  29725. linkEmissiveWithDiffuse: boolean;
  29726. private _useSpecularOverAlpha;
  29727. /**
  29728. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29729. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29730. */
  29731. useSpecularOverAlpha: boolean;
  29732. private _useReflectionOverAlpha;
  29733. /**
  29734. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29735. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29736. */
  29737. useReflectionOverAlpha: boolean;
  29738. private _disableLighting;
  29739. /**
  29740. * Does lights from the scene impacts this material.
  29741. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29742. */
  29743. disableLighting: boolean;
  29744. private _useObjectSpaceNormalMap;
  29745. /**
  29746. * Allows using an object space normal map (instead of tangent space).
  29747. */
  29748. useObjectSpaceNormalMap: boolean;
  29749. private _useParallax;
  29750. /**
  29751. * Is parallax enabled or not.
  29752. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29753. */
  29754. useParallax: boolean;
  29755. private _useParallaxOcclusion;
  29756. /**
  29757. * Is parallax occlusion enabled or not.
  29758. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29759. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29760. */
  29761. useParallaxOcclusion: boolean;
  29762. /**
  29763. * 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.
  29764. */
  29765. parallaxScaleBias: number;
  29766. private _roughness;
  29767. /**
  29768. * Helps to define how blurry the reflections should appears in the material.
  29769. */
  29770. roughness: number;
  29771. /**
  29772. * In case of refraction, define the value of the index of refraction.
  29773. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29774. */
  29775. indexOfRefraction: number;
  29776. /**
  29777. * Invert the refraction texture alongside the y axis.
  29778. * It can be useful with procedural textures or probe for instance.
  29779. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29780. */
  29781. invertRefractionY: boolean;
  29782. /**
  29783. * Defines the alpha limits in alpha test mode.
  29784. */
  29785. alphaCutOff: number;
  29786. private _useLightmapAsShadowmap;
  29787. /**
  29788. * In case of light mapping, define whether the map contains light or shadow informations.
  29789. */
  29790. useLightmapAsShadowmap: boolean;
  29791. private _diffuseFresnelParameters;
  29792. /**
  29793. * Define the diffuse fresnel parameters of the material.
  29794. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29795. */
  29796. diffuseFresnelParameters: FresnelParameters;
  29797. private _opacityFresnelParameters;
  29798. /**
  29799. * Define the opacity fresnel parameters of the material.
  29800. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29801. */
  29802. opacityFresnelParameters: FresnelParameters;
  29803. private _reflectionFresnelParameters;
  29804. /**
  29805. * Define the reflection fresnel parameters of the material.
  29806. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29807. */
  29808. reflectionFresnelParameters: FresnelParameters;
  29809. private _refractionFresnelParameters;
  29810. /**
  29811. * Define the refraction fresnel parameters of the material.
  29812. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29813. */
  29814. refractionFresnelParameters: FresnelParameters;
  29815. private _emissiveFresnelParameters;
  29816. /**
  29817. * Define the emissive fresnel parameters of the material.
  29818. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29819. */
  29820. emissiveFresnelParameters: FresnelParameters;
  29821. private _useReflectionFresnelFromSpecular;
  29822. /**
  29823. * If true automatically deducts the fresnels values from the material specularity.
  29824. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29825. */
  29826. useReflectionFresnelFromSpecular: boolean;
  29827. private _useGlossinessFromSpecularMapAlpha;
  29828. /**
  29829. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29830. */
  29831. useGlossinessFromSpecularMapAlpha: boolean;
  29832. private _maxSimultaneousLights;
  29833. /**
  29834. * Defines the maximum number of lights that can be used in the material
  29835. */
  29836. maxSimultaneousLights: number;
  29837. private _invertNormalMapX;
  29838. /**
  29839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29840. */
  29841. invertNormalMapX: boolean;
  29842. private _invertNormalMapY;
  29843. /**
  29844. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29845. */
  29846. invertNormalMapY: boolean;
  29847. private _twoSidedLighting;
  29848. /**
  29849. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29850. */
  29851. twoSidedLighting: boolean;
  29852. /**
  29853. * Default configuration related to image processing available in the standard Material.
  29854. */
  29855. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29856. /**
  29857. * Gets the image processing configuration used either in this material.
  29858. */
  29859. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29860. /**
  29861. * Sets the Default image processing configuration used either in the this material.
  29862. *
  29863. * If sets to null, the scene one is in use.
  29864. */
  29865. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29866. /**
  29867. * Keep track of the image processing observer to allow dispose and replace.
  29868. */
  29869. private _imageProcessingObserver;
  29870. /**
  29871. * Attaches a new image processing configuration to the Standard Material.
  29872. * @param configuration
  29873. */
  29874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29875. /**
  29876. * Gets wether the color curves effect is enabled.
  29877. */
  29878. get cameraColorCurvesEnabled(): boolean;
  29879. /**
  29880. * Sets wether the color curves effect is enabled.
  29881. */
  29882. set cameraColorCurvesEnabled(value: boolean);
  29883. /**
  29884. * Gets wether the color grading effect is enabled.
  29885. */
  29886. get cameraColorGradingEnabled(): boolean;
  29887. /**
  29888. * Gets wether the color grading effect is enabled.
  29889. */
  29890. set cameraColorGradingEnabled(value: boolean);
  29891. /**
  29892. * Gets wether tonemapping is enabled or not.
  29893. */
  29894. get cameraToneMappingEnabled(): boolean;
  29895. /**
  29896. * Sets wether tonemapping is enabled or not
  29897. */
  29898. set cameraToneMappingEnabled(value: boolean);
  29899. /**
  29900. * The camera exposure used on this material.
  29901. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29902. * This corresponds to a photographic exposure.
  29903. */
  29904. get cameraExposure(): number;
  29905. /**
  29906. * The camera exposure used on this material.
  29907. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29908. * This corresponds to a photographic exposure.
  29909. */
  29910. set cameraExposure(value: number);
  29911. /**
  29912. * Gets The camera contrast used on this material.
  29913. */
  29914. get cameraContrast(): number;
  29915. /**
  29916. * Sets The camera contrast used on this material.
  29917. */
  29918. set cameraContrast(value: number);
  29919. /**
  29920. * Gets the Color Grading 2D Lookup Texture.
  29921. */
  29922. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29923. /**
  29924. * Sets the Color Grading 2D Lookup Texture.
  29925. */
  29926. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29927. /**
  29928. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29929. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29930. * 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;
  29931. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29932. */
  29933. get cameraColorCurves(): Nullable<ColorCurves>;
  29934. /**
  29935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29937. * 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;
  29938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29939. */
  29940. set cameraColorCurves(value: Nullable<ColorCurves>);
  29941. /**
  29942. * Defines the detail map parameters for the material.
  29943. */
  29944. readonly detailMap: DetailMapConfiguration;
  29945. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29946. protected _worldViewProjectionMatrix: Matrix;
  29947. protected _globalAmbientColor: Color3;
  29948. protected _useLogarithmicDepth: boolean;
  29949. protected _rebuildInParallel: boolean;
  29950. /**
  29951. * Instantiates a new standard material.
  29952. * This is the default material used in Babylon. It is the best trade off between quality
  29953. * and performances.
  29954. * @see http://doc.babylonjs.com/babylon101/materials
  29955. * @param name Define the name of the material in the scene
  29956. * @param scene Define the scene the material belong to
  29957. */
  29958. constructor(name: string, scene: Scene);
  29959. /**
  29960. * Gets a boolean indicating that current material needs to register RTT
  29961. */
  29962. get hasRenderTargetTextures(): boolean;
  29963. /**
  29964. * Gets the current class name of the material e.g. "StandardMaterial"
  29965. * Mainly use in serialization.
  29966. * @returns the class name
  29967. */
  29968. getClassName(): string;
  29969. /**
  29970. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29971. * You can try switching to logarithmic depth.
  29972. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29973. */
  29974. get useLogarithmicDepth(): boolean;
  29975. set useLogarithmicDepth(value: boolean);
  29976. /**
  29977. * Specifies if the material will require alpha blending
  29978. * @returns a boolean specifying if alpha blending is needed
  29979. */
  29980. needAlphaBlending(): boolean;
  29981. /**
  29982. * Specifies if this material should be rendered in alpha test mode
  29983. * @returns a boolean specifying if an alpha test is needed.
  29984. */
  29985. needAlphaTesting(): boolean;
  29986. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29987. /**
  29988. * Get the texture used for alpha test purpose.
  29989. * @returns the diffuse texture in case of the standard material.
  29990. */
  29991. getAlphaTestTexture(): Nullable<BaseTexture>;
  29992. /**
  29993. * Get if the submesh is ready to be used and all its information available.
  29994. * Child classes can use it to update shaders
  29995. * @param mesh defines the mesh to check
  29996. * @param subMesh defines which submesh to check
  29997. * @param useInstances specifies that instances should be used
  29998. * @returns a boolean indicating that the submesh is ready or not
  29999. */
  30000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30001. /**
  30002. * Builds the material UBO layouts.
  30003. * Used internally during the effect preparation.
  30004. */
  30005. buildUniformLayout(): void;
  30006. /**
  30007. * Unbinds the material from the mesh
  30008. */
  30009. unbind(): void;
  30010. /**
  30011. * Binds the submesh to this material by preparing the effect and shader to draw
  30012. * @param world defines the world transformation matrix
  30013. * @param mesh defines the mesh containing the submesh
  30014. * @param subMesh defines the submesh to bind the material to
  30015. */
  30016. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30017. /**
  30018. * Get the list of animatables in the material.
  30019. * @returns the list of animatables object used in the material
  30020. */
  30021. getAnimatables(): IAnimatable[];
  30022. /**
  30023. * Gets the active textures from the material
  30024. * @returns an array of textures
  30025. */
  30026. getActiveTextures(): BaseTexture[];
  30027. /**
  30028. * Specifies if the material uses a texture
  30029. * @param texture defines the texture to check against the material
  30030. * @returns a boolean specifying if the material uses the texture
  30031. */
  30032. hasTexture(texture: BaseTexture): boolean;
  30033. /**
  30034. * Disposes the material
  30035. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30036. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30037. */
  30038. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30039. /**
  30040. * Makes a duplicate of the material, and gives it a new name
  30041. * @param name defines the new name for the duplicated material
  30042. * @returns the cloned material
  30043. */
  30044. clone(name: string): StandardMaterial;
  30045. /**
  30046. * Serializes this material in a JSON representation
  30047. * @returns the serialized material object
  30048. */
  30049. serialize(): any;
  30050. /**
  30051. * Creates a standard material from parsed material data
  30052. * @param source defines the JSON representation of the material
  30053. * @param scene defines the hosting scene
  30054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30055. * @returns a new standard material
  30056. */
  30057. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30058. /**
  30059. * Are diffuse textures enabled in the application.
  30060. */
  30061. static get DiffuseTextureEnabled(): boolean;
  30062. static set DiffuseTextureEnabled(value: boolean);
  30063. /**
  30064. * Are detail textures enabled in the application.
  30065. */
  30066. static get DetailTextureEnabled(): boolean;
  30067. static set DetailTextureEnabled(value: boolean);
  30068. /**
  30069. * Are ambient textures enabled in the application.
  30070. */
  30071. static get AmbientTextureEnabled(): boolean;
  30072. static set AmbientTextureEnabled(value: boolean);
  30073. /**
  30074. * Are opacity textures enabled in the application.
  30075. */
  30076. static get OpacityTextureEnabled(): boolean;
  30077. static set OpacityTextureEnabled(value: boolean);
  30078. /**
  30079. * Are reflection textures enabled in the application.
  30080. */
  30081. static get ReflectionTextureEnabled(): boolean;
  30082. static set ReflectionTextureEnabled(value: boolean);
  30083. /**
  30084. * Are emissive textures enabled in the application.
  30085. */
  30086. static get EmissiveTextureEnabled(): boolean;
  30087. static set EmissiveTextureEnabled(value: boolean);
  30088. /**
  30089. * Are specular textures enabled in the application.
  30090. */
  30091. static get SpecularTextureEnabled(): boolean;
  30092. static set SpecularTextureEnabled(value: boolean);
  30093. /**
  30094. * Are bump textures enabled in the application.
  30095. */
  30096. static get BumpTextureEnabled(): boolean;
  30097. static set BumpTextureEnabled(value: boolean);
  30098. /**
  30099. * Are lightmap textures enabled in the application.
  30100. */
  30101. static get LightmapTextureEnabled(): boolean;
  30102. static set LightmapTextureEnabled(value: boolean);
  30103. /**
  30104. * Are refraction textures enabled in the application.
  30105. */
  30106. static get RefractionTextureEnabled(): boolean;
  30107. static set RefractionTextureEnabled(value: boolean);
  30108. /**
  30109. * Are color grading textures enabled in the application.
  30110. */
  30111. static get ColorGradingTextureEnabled(): boolean;
  30112. static set ColorGradingTextureEnabled(value: boolean);
  30113. /**
  30114. * Are fresnels enabled in the application.
  30115. */
  30116. static get FresnelEnabled(): boolean;
  30117. static set FresnelEnabled(value: boolean);
  30118. }
  30119. }
  30120. declare module BABYLON {
  30121. /**
  30122. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30123. *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.
  30124. * The SPS is also a particle system. It provides some methods to manage the particles.
  30125. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30126. *
  30127. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30128. */
  30129. export class SolidParticleSystem implements IDisposable {
  30130. /**
  30131. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30132. * Example : var p = SPS.particles[i];
  30133. */
  30134. particles: SolidParticle[];
  30135. /**
  30136. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30137. */
  30138. nbParticles: number;
  30139. /**
  30140. * If the particles must ever face the camera (default false). Useful for planar particles.
  30141. */
  30142. billboard: boolean;
  30143. /**
  30144. * Recompute normals when adding a shape
  30145. */
  30146. recomputeNormals: boolean;
  30147. /**
  30148. * This a counter ofr your own usage. It's not set by any SPS functions.
  30149. */
  30150. counter: number;
  30151. /**
  30152. * The SPS name. This name is also given to the underlying mesh.
  30153. */
  30154. name: string;
  30155. /**
  30156. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30157. */
  30158. mesh: Mesh;
  30159. /**
  30160. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30161. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30162. */
  30163. vars: any;
  30164. /**
  30165. * This array is populated when the SPS is set as 'pickable'.
  30166. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30167. * Each element of this array is an object `{idx: int, faceId: int}`.
  30168. * `idx` is the picked particle index in the `SPS.particles` array
  30169. * `faceId` is the picked face index counted within this particle.
  30170. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30171. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30172. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30173. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30174. */
  30175. pickedParticles: {
  30176. idx: number;
  30177. faceId: number;
  30178. }[];
  30179. /**
  30180. * This array is populated when the SPS is set as 'pickable'
  30181. * Each key of this array is a submesh index.
  30182. * Each element of this array is a second array defined like this :
  30183. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30184. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30185. * `idx` is the picked particle index in the `SPS.particles` array
  30186. * `faceId` is the picked face index counted within this particle.
  30187. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30188. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30189. */
  30190. pickedBySubMesh: {
  30191. idx: number;
  30192. faceId: number;
  30193. }[][];
  30194. /**
  30195. * This array is populated when `enableDepthSort` is set to true.
  30196. * Each element of this array is an instance of the class DepthSortedParticle.
  30197. */
  30198. depthSortedParticles: DepthSortedParticle[];
  30199. /**
  30200. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30201. * @hidden
  30202. */
  30203. _bSphereOnly: boolean;
  30204. /**
  30205. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30206. * @hidden
  30207. */
  30208. _bSphereRadiusFactor: number;
  30209. private _scene;
  30210. private _positions;
  30211. private _indices;
  30212. private _normals;
  30213. private _colors;
  30214. private _uvs;
  30215. private _indices32;
  30216. private _positions32;
  30217. private _normals32;
  30218. private _fixedNormal32;
  30219. private _colors32;
  30220. private _uvs32;
  30221. private _index;
  30222. private _updatable;
  30223. private _pickable;
  30224. private _isVisibilityBoxLocked;
  30225. private _alwaysVisible;
  30226. private _depthSort;
  30227. private _expandable;
  30228. private _shapeCounter;
  30229. private _copy;
  30230. private _color;
  30231. private _computeParticleColor;
  30232. private _computeParticleTexture;
  30233. private _computeParticleRotation;
  30234. private _computeParticleVertex;
  30235. private _computeBoundingBox;
  30236. private _depthSortParticles;
  30237. private _camera;
  30238. private _mustUnrotateFixedNormals;
  30239. private _particlesIntersect;
  30240. private _needs32Bits;
  30241. private _isNotBuilt;
  30242. private _lastParticleId;
  30243. private _idxOfId;
  30244. private _multimaterialEnabled;
  30245. private _useModelMaterial;
  30246. private _indicesByMaterial;
  30247. private _materialIndexes;
  30248. private _depthSortFunction;
  30249. private _materialSortFunction;
  30250. private _materials;
  30251. private _multimaterial;
  30252. private _materialIndexesById;
  30253. private _defaultMaterial;
  30254. private _autoUpdateSubMeshes;
  30255. private _tmpVertex;
  30256. /**
  30257. * Creates a SPS (Solid Particle System) object.
  30258. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30259. * @param scene (Scene) is the scene in which the SPS is added.
  30260. * @param options defines the options of the sps e.g.
  30261. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30262. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30263. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30264. * * 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.
  30265. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30266. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30267. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30268. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30269. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30270. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30271. */
  30272. constructor(name: string, scene: Scene, options?: {
  30273. updatable?: boolean;
  30274. isPickable?: boolean;
  30275. enableDepthSort?: boolean;
  30276. particleIntersection?: boolean;
  30277. boundingSphereOnly?: boolean;
  30278. bSphereRadiusFactor?: number;
  30279. expandable?: boolean;
  30280. useModelMaterial?: boolean;
  30281. enableMultiMaterial?: boolean;
  30282. });
  30283. /**
  30284. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30285. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30286. * @returns the created mesh
  30287. */
  30288. buildMesh(): Mesh;
  30289. /**
  30290. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30291. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30292. * Thus the particles generated from `digest()` have their property `position` set yet.
  30293. * @param mesh ( Mesh ) is the mesh to be digested
  30294. * @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
  30295. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30296. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30297. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30298. * @returns the current SPS
  30299. */
  30300. digest(mesh: Mesh, options?: {
  30301. facetNb?: number;
  30302. number?: number;
  30303. delta?: number;
  30304. storage?: [];
  30305. }): SolidParticleSystem;
  30306. /**
  30307. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30308. * @hidden
  30309. */
  30310. private _unrotateFixedNormals;
  30311. /**
  30312. * Resets the temporary working copy particle
  30313. * @hidden
  30314. */
  30315. private _resetCopy;
  30316. /**
  30317. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30318. * @param p the current index in the positions array to be updated
  30319. * @param ind the current index in the indices array
  30320. * @param shape a Vector3 array, the shape geometry
  30321. * @param positions the positions array to be updated
  30322. * @param meshInd the shape indices array
  30323. * @param indices the indices array to be updated
  30324. * @param meshUV the shape uv array
  30325. * @param uvs the uv array to be updated
  30326. * @param meshCol the shape color array
  30327. * @param colors the color array to be updated
  30328. * @param meshNor the shape normals array
  30329. * @param normals the normals array to be updated
  30330. * @param idx the particle index
  30331. * @param idxInShape the particle index in its shape
  30332. * @param options the addShape() method passed options
  30333. * @model the particle model
  30334. * @hidden
  30335. */
  30336. private _meshBuilder;
  30337. /**
  30338. * Returns a shape Vector3 array from positions float array
  30339. * @param positions float array
  30340. * @returns a vector3 array
  30341. * @hidden
  30342. */
  30343. private _posToShape;
  30344. /**
  30345. * Returns a shapeUV array from a float uvs (array deep copy)
  30346. * @param uvs as a float array
  30347. * @returns a shapeUV array
  30348. * @hidden
  30349. */
  30350. private _uvsToShapeUV;
  30351. /**
  30352. * Adds a new particle object in the particles array
  30353. * @param idx particle index in particles array
  30354. * @param id particle id
  30355. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30356. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30357. * @param model particle ModelShape object
  30358. * @param shapeId model shape identifier
  30359. * @param idxInShape index of the particle in the current model
  30360. * @param bInfo model bounding info object
  30361. * @param storage target storage array, if any
  30362. * @hidden
  30363. */
  30364. private _addParticle;
  30365. /**
  30366. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30367. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30368. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30369. * @param nb (positive integer) the number of particles to be created from this model
  30370. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30371. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30372. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30373. * @returns the number of shapes in the system
  30374. */
  30375. addShape(mesh: Mesh, nb: number, options?: {
  30376. positionFunction?: any;
  30377. vertexFunction?: any;
  30378. storage?: [];
  30379. }): number;
  30380. /**
  30381. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30382. * @hidden
  30383. */
  30384. private _rebuildParticle;
  30385. /**
  30386. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30387. * @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.
  30388. * @returns the SPS.
  30389. */
  30390. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30391. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30392. * Returns an array with the removed particles.
  30393. * 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.
  30394. * The SPS can't be empty so at least one particle needs to remain in place.
  30395. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30396. * @param start index of the first particle to remove
  30397. * @param end index of the last particle to remove (included)
  30398. * @returns an array populated with the removed particles
  30399. */
  30400. removeParticles(start: number, end: number): SolidParticle[];
  30401. /**
  30402. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30403. * @param solidParticleArray an array populated with Solid Particles objects
  30404. * @returns the SPS
  30405. */
  30406. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30407. /**
  30408. * Creates a new particle and modifies the SPS mesh geometry :
  30409. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30410. * - calls _addParticle() to populate the particle array
  30411. * factorized code from addShape() and insertParticlesFromArray()
  30412. * @param idx particle index in the particles array
  30413. * @param i particle index in its shape
  30414. * @param modelShape particle ModelShape object
  30415. * @param shape shape vertex array
  30416. * @param meshInd shape indices array
  30417. * @param meshUV shape uv array
  30418. * @param meshCol shape color array
  30419. * @param meshNor shape normals array
  30420. * @param bbInfo shape bounding info
  30421. * @param storage target particle storage
  30422. * @options addShape() passed options
  30423. * @hidden
  30424. */
  30425. private _insertNewParticle;
  30426. /**
  30427. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30428. * This method calls `updateParticle()` for each particle of the SPS.
  30429. * For an animated SPS, it is usually called within the render loop.
  30430. * 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.
  30431. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30432. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30433. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30434. * @returns the SPS.
  30435. */
  30436. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30437. /**
  30438. * Disposes the SPS.
  30439. */
  30440. dispose(): void;
  30441. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30442. * idx is the particle index in the SPS
  30443. * faceId is the picked face index counted within this particle.
  30444. * Returns null if the pickInfo can't identify a picked particle.
  30445. * @param pickingInfo (PickingInfo object)
  30446. * @returns {idx: number, faceId: number} or null
  30447. */
  30448. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30449. idx: number;
  30450. faceId: number;
  30451. }>;
  30452. /**
  30453. * Returns a SolidParticle object from its identifier : particle.id
  30454. * @param id (integer) the particle Id
  30455. * @returns the searched particle or null if not found in the SPS.
  30456. */
  30457. getParticleById(id: number): Nullable<SolidParticle>;
  30458. /**
  30459. * Returns a new array populated with the particles having the passed shapeId.
  30460. * @param shapeId (integer) the shape identifier
  30461. * @returns a new solid particle array
  30462. */
  30463. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30464. /**
  30465. * Populates the passed array "ref" with the particles having the passed shapeId.
  30466. * @param shapeId the shape identifier
  30467. * @returns the SPS
  30468. * @param ref
  30469. */
  30470. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30471. /**
  30472. * Computes the required SubMeshes according the materials assigned to the particles.
  30473. * @returns the solid particle system.
  30474. * Does nothing if called before the SPS mesh is built.
  30475. */
  30476. computeSubMeshes(): SolidParticleSystem;
  30477. /**
  30478. * Sorts the solid particles by material when MultiMaterial is enabled.
  30479. * Updates the indices32 array.
  30480. * Updates the indicesByMaterial array.
  30481. * Updates the mesh indices array.
  30482. * @returns the SPS
  30483. * @hidden
  30484. */
  30485. private _sortParticlesByMaterial;
  30486. /**
  30487. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30488. * @hidden
  30489. */
  30490. private _setMaterialIndexesById;
  30491. /**
  30492. * Returns an array with unique values of Materials from the passed array
  30493. * @param array the material array to be checked and filtered
  30494. * @hidden
  30495. */
  30496. private _filterUniqueMaterialId;
  30497. /**
  30498. * Sets a new Standard Material as _defaultMaterial if not already set.
  30499. * @hidden
  30500. */
  30501. private _setDefaultMaterial;
  30502. /**
  30503. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30504. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30505. * @returns the SPS.
  30506. */
  30507. refreshVisibleSize(): SolidParticleSystem;
  30508. /**
  30509. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30510. * @param size the size (float) of the visibility box
  30511. * note : this doesn't lock the SPS mesh bounding box.
  30512. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30513. */
  30514. setVisibilityBox(size: number): void;
  30515. /**
  30516. * Gets whether the SPS as always visible or not
  30517. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30518. */
  30519. get isAlwaysVisible(): boolean;
  30520. /**
  30521. * Sets the SPS as always visible or not
  30522. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30523. */
  30524. set isAlwaysVisible(val: boolean);
  30525. /**
  30526. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30527. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30528. */
  30529. set isVisibilityBoxLocked(val: boolean);
  30530. /**
  30531. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30532. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30533. */
  30534. get isVisibilityBoxLocked(): boolean;
  30535. /**
  30536. * Tells to `setParticles()` to compute the particle rotations or not.
  30537. * Default value : true. The SPS is faster when it's set to false.
  30538. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30539. */
  30540. set computeParticleRotation(val: boolean);
  30541. /**
  30542. * Tells to `setParticles()` to compute the particle colors or not.
  30543. * Default value : true. The SPS is faster when it's set to false.
  30544. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30545. */
  30546. set computeParticleColor(val: boolean);
  30547. set computeParticleTexture(val: boolean);
  30548. /**
  30549. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30550. * Default value : false. The SPS is faster when it's set to false.
  30551. * Note : the particle custom vertex positions aren't stored values.
  30552. */
  30553. set computeParticleVertex(val: boolean);
  30554. /**
  30555. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30556. */
  30557. set computeBoundingBox(val: boolean);
  30558. /**
  30559. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30560. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30561. * Default : `true`
  30562. */
  30563. set depthSortParticles(val: boolean);
  30564. /**
  30565. * Gets if `setParticles()` computes the particle rotations or not.
  30566. * Default value : true. The SPS is faster when it's set to false.
  30567. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30568. */
  30569. get computeParticleRotation(): boolean;
  30570. /**
  30571. * Gets if `setParticles()` computes the particle colors or not.
  30572. * Default value : true. The SPS is faster when it's set to false.
  30573. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30574. */
  30575. get computeParticleColor(): boolean;
  30576. /**
  30577. * Gets if `setParticles()` computes the particle textures or not.
  30578. * Default value : true. The SPS is faster when it's set to false.
  30579. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30580. */
  30581. get computeParticleTexture(): boolean;
  30582. /**
  30583. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30584. * Default value : false. The SPS is faster when it's set to false.
  30585. * Note : the particle custom vertex positions aren't stored values.
  30586. */
  30587. get computeParticleVertex(): boolean;
  30588. /**
  30589. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30590. */
  30591. get computeBoundingBox(): boolean;
  30592. /**
  30593. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30594. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30595. * Default : `true`
  30596. */
  30597. get depthSortParticles(): boolean;
  30598. /**
  30599. * Gets if the SPS is created as expandable at construction time.
  30600. * Default : `false`
  30601. */
  30602. get expandable(): boolean;
  30603. /**
  30604. * Gets if the SPS supports the Multi Materials
  30605. */
  30606. get multimaterialEnabled(): boolean;
  30607. /**
  30608. * Gets if the SPS uses the model materials for its own multimaterial.
  30609. */
  30610. get useModelMaterial(): boolean;
  30611. /**
  30612. * The SPS used material array.
  30613. */
  30614. get materials(): Material[];
  30615. /**
  30616. * Sets the SPS MultiMaterial from the passed materials.
  30617. * Note : the passed array is internally copied and not used then by reference.
  30618. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30619. */
  30620. setMultiMaterial(materials: Material[]): void;
  30621. /**
  30622. * The SPS computed multimaterial object
  30623. */
  30624. get multimaterial(): MultiMaterial;
  30625. set multimaterial(mm: MultiMaterial);
  30626. /**
  30627. * If the subMeshes must be updated on the next call to setParticles()
  30628. */
  30629. get autoUpdateSubMeshes(): boolean;
  30630. set autoUpdateSubMeshes(val: boolean);
  30631. /**
  30632. * This function does nothing. It may be overwritten to set all the particle first values.
  30633. * The SPS doesn't call this function, you may have to call it by your own.
  30634. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30635. */
  30636. initParticles(): void;
  30637. /**
  30638. * This function does nothing. It may be overwritten to recycle a particle.
  30639. * The SPS doesn't call this function, you may have to call it by your own.
  30640. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30641. * @param particle The particle to recycle
  30642. * @returns the recycled particle
  30643. */
  30644. recycleParticle(particle: SolidParticle): SolidParticle;
  30645. /**
  30646. * Updates a particle : this function should be overwritten by the user.
  30647. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30648. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30649. * @example : just set a particle position or velocity and recycle conditions
  30650. * @param particle The particle to update
  30651. * @returns the updated particle
  30652. */
  30653. updateParticle(particle: SolidParticle): SolidParticle;
  30654. /**
  30655. * Updates a vertex of a particle : it can be overwritten by the user.
  30656. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30657. * @param particle the current particle
  30658. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30659. * @param pt the index of the current vertex in the particle shape
  30660. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30661. * @example : just set a vertex particle position or color
  30662. * @returns the sps
  30663. */
  30664. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30665. /**
  30666. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30667. * This does nothing and may be overwritten by the user.
  30668. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30669. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30670. * @param update the boolean update value actually passed to setParticles()
  30671. */
  30672. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30673. /**
  30674. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30675. * This will be passed three parameters.
  30676. * This does nothing and may be overwritten by the user.
  30677. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30678. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30679. * @param update the boolean update value actually passed to setParticles()
  30680. */
  30681. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30682. }
  30683. }
  30684. declare module BABYLON {
  30685. /**
  30686. * Represents one particle of a solid particle system.
  30687. */
  30688. export class SolidParticle {
  30689. /**
  30690. * particle global index
  30691. */
  30692. idx: number;
  30693. /**
  30694. * particle identifier
  30695. */
  30696. id: number;
  30697. /**
  30698. * The color of the particle
  30699. */
  30700. color: Nullable<Color4>;
  30701. /**
  30702. * The world space position of the particle.
  30703. */
  30704. position: Vector3;
  30705. /**
  30706. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30707. */
  30708. rotation: Vector3;
  30709. /**
  30710. * The world space rotation quaternion of the particle.
  30711. */
  30712. rotationQuaternion: Nullable<Quaternion>;
  30713. /**
  30714. * The scaling of the particle.
  30715. */
  30716. scaling: Vector3;
  30717. /**
  30718. * The uvs of the particle.
  30719. */
  30720. uvs: Vector4;
  30721. /**
  30722. * The current speed of the particle.
  30723. */
  30724. velocity: Vector3;
  30725. /**
  30726. * The pivot point in the particle local space.
  30727. */
  30728. pivot: Vector3;
  30729. /**
  30730. * Must the particle be translated from its pivot point in its local space ?
  30731. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30732. * Default : false
  30733. */
  30734. translateFromPivot: boolean;
  30735. /**
  30736. * Is the particle active or not ?
  30737. */
  30738. alive: boolean;
  30739. /**
  30740. * Is the particle visible or not ?
  30741. */
  30742. isVisible: boolean;
  30743. /**
  30744. * Index of this particle in the global "positions" array (Internal use)
  30745. * @hidden
  30746. */
  30747. _pos: number;
  30748. /**
  30749. * @hidden Index of this particle in the global "indices" array (Internal use)
  30750. */
  30751. _ind: number;
  30752. /**
  30753. * @hidden ModelShape of this particle (Internal use)
  30754. */
  30755. _model: ModelShape;
  30756. /**
  30757. * ModelShape id of this particle
  30758. */
  30759. shapeId: number;
  30760. /**
  30761. * Index of the particle in its shape id
  30762. */
  30763. idxInShape: number;
  30764. /**
  30765. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30766. */
  30767. _modelBoundingInfo: BoundingInfo;
  30768. /**
  30769. * @hidden Particle BoundingInfo object (Internal use)
  30770. */
  30771. _boundingInfo: BoundingInfo;
  30772. /**
  30773. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30774. */
  30775. _sps: SolidParticleSystem;
  30776. /**
  30777. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30778. */
  30779. _stillInvisible: boolean;
  30780. /**
  30781. * @hidden Last computed particle rotation matrix
  30782. */
  30783. _rotationMatrix: number[];
  30784. /**
  30785. * Parent particle Id, if any.
  30786. * Default null.
  30787. */
  30788. parentId: Nullable<number>;
  30789. /**
  30790. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30791. */
  30792. materialIndex: Nullable<number>;
  30793. /**
  30794. * Custom object or properties.
  30795. */
  30796. props: Nullable<any>;
  30797. /**
  30798. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30799. * The possible values are :
  30800. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30801. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30802. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30803. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30804. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30805. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30806. * */
  30807. cullingStrategy: number;
  30808. /**
  30809. * @hidden Internal global position in the SPS.
  30810. */
  30811. _globalPosition: Vector3;
  30812. /**
  30813. * Creates a Solid Particle object.
  30814. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30815. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30816. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30817. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30818. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30819. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30820. * @param shapeId (integer) is the model shape identifier in the SPS.
  30821. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30822. * @param sps defines the sps it is associated to
  30823. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30824. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30825. */
  30826. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30827. /**
  30828. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30829. * @param target the particle target
  30830. * @returns the current particle
  30831. */
  30832. copyToRef(target: SolidParticle): SolidParticle;
  30833. /**
  30834. * Legacy support, changed scale to scaling
  30835. */
  30836. get scale(): Vector3;
  30837. /**
  30838. * Legacy support, changed scale to scaling
  30839. */
  30840. set scale(scale: Vector3);
  30841. /**
  30842. * Legacy support, changed quaternion to rotationQuaternion
  30843. */
  30844. get quaternion(): Nullable<Quaternion>;
  30845. /**
  30846. * Legacy support, changed quaternion to rotationQuaternion
  30847. */
  30848. set quaternion(q: Nullable<Quaternion>);
  30849. /**
  30850. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30851. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30852. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30853. * @returns true if it intersects
  30854. */
  30855. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30856. /**
  30857. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30858. * A particle is in the frustum if its bounding box intersects the frustum
  30859. * @param frustumPlanes defines the frustum to test
  30860. * @returns true if the particle is in the frustum planes
  30861. */
  30862. isInFrustum(frustumPlanes: Plane[]): boolean;
  30863. /**
  30864. * get the rotation matrix of the particle
  30865. * @hidden
  30866. */
  30867. getRotationMatrix(m: Matrix): void;
  30868. }
  30869. /**
  30870. * Represents the shape of the model used by one particle of a solid particle system.
  30871. * SPS internal tool, don't use it manually.
  30872. */
  30873. export class ModelShape {
  30874. /**
  30875. * The shape id
  30876. * @hidden
  30877. */
  30878. shapeID: number;
  30879. /**
  30880. * flat array of model positions (internal use)
  30881. * @hidden
  30882. */
  30883. _shape: Vector3[];
  30884. /**
  30885. * flat array of model UVs (internal use)
  30886. * @hidden
  30887. */
  30888. _shapeUV: number[];
  30889. /**
  30890. * color array of the model
  30891. * @hidden
  30892. */
  30893. _shapeColors: number[];
  30894. /**
  30895. * indices array of the model
  30896. * @hidden
  30897. */
  30898. _indices: number[];
  30899. /**
  30900. * normals array of the model
  30901. * @hidden
  30902. */
  30903. _normals: number[];
  30904. /**
  30905. * length of the shape in the model indices array (internal use)
  30906. * @hidden
  30907. */
  30908. _indicesLength: number;
  30909. /**
  30910. * Custom position function (internal use)
  30911. * @hidden
  30912. */
  30913. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30914. /**
  30915. * Custom vertex function (internal use)
  30916. * @hidden
  30917. */
  30918. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30919. /**
  30920. * Model material (internal use)
  30921. * @hidden
  30922. */
  30923. _material: Nullable<Material>;
  30924. /**
  30925. * 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.
  30926. * SPS internal tool, don't use it manually.
  30927. * @hidden
  30928. */
  30929. 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>);
  30930. }
  30931. /**
  30932. * Represents a Depth Sorted Particle in the solid particle system.
  30933. * @hidden
  30934. */
  30935. export class DepthSortedParticle {
  30936. /**
  30937. * Particle index
  30938. */
  30939. idx: number;
  30940. /**
  30941. * Index of the particle in the "indices" array
  30942. */
  30943. ind: number;
  30944. /**
  30945. * Length of the particle shape in the "indices" array
  30946. */
  30947. indicesLength: number;
  30948. /**
  30949. * Squared distance from the particle to the camera
  30950. */
  30951. sqDistance: number;
  30952. /**
  30953. * Material index when used with MultiMaterials
  30954. */
  30955. materialIndex: number;
  30956. /**
  30957. * Creates a new sorted particle
  30958. * @param materialIndex
  30959. */
  30960. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30961. }
  30962. /**
  30963. * Represents a solid particle vertex
  30964. */
  30965. export class SolidParticleVertex {
  30966. /**
  30967. * Vertex position
  30968. */
  30969. position: Vector3;
  30970. /**
  30971. * Vertex color
  30972. */
  30973. color: Color4;
  30974. /**
  30975. * Vertex UV
  30976. */
  30977. uv: Vector2;
  30978. /**
  30979. * Creates a new solid particle vertex
  30980. */
  30981. constructor();
  30982. /** Vertex x coordinate */
  30983. get x(): number;
  30984. set x(val: number);
  30985. /** Vertex y coordinate */
  30986. get y(): number;
  30987. set y(val: number);
  30988. /** Vertex z coordinate */
  30989. get z(): number;
  30990. set z(val: number);
  30991. }
  30992. }
  30993. declare module BABYLON {
  30994. /**
  30995. * @hidden
  30996. */
  30997. export class _MeshCollisionData {
  30998. _checkCollisions: boolean;
  30999. _collisionMask: number;
  31000. _collisionGroup: number;
  31001. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31002. _collider: Nullable<Collider>;
  31003. _oldPositionForCollisions: Vector3;
  31004. _diffPositionForCollisions: Vector3;
  31005. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31006. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31007. }
  31008. }
  31009. declare module BABYLON {
  31010. /** @hidden */
  31011. class _FacetDataStorage {
  31012. facetPositions: Vector3[];
  31013. facetNormals: Vector3[];
  31014. facetPartitioning: number[][];
  31015. facetNb: number;
  31016. partitioningSubdivisions: number;
  31017. partitioningBBoxRatio: number;
  31018. facetDataEnabled: boolean;
  31019. facetParameters: any;
  31020. bbSize: Vector3;
  31021. subDiv: {
  31022. max: number;
  31023. X: number;
  31024. Y: number;
  31025. Z: number;
  31026. };
  31027. facetDepthSort: boolean;
  31028. facetDepthSortEnabled: boolean;
  31029. depthSortedIndices: IndicesArray;
  31030. depthSortedFacets: {
  31031. ind: number;
  31032. sqDistance: number;
  31033. }[];
  31034. facetDepthSortFunction: (f1: {
  31035. ind: number;
  31036. sqDistance: number;
  31037. }, f2: {
  31038. ind: number;
  31039. sqDistance: number;
  31040. }) => number;
  31041. facetDepthSortFrom: Vector3;
  31042. facetDepthSortOrigin: Vector3;
  31043. invertedMatrix: Matrix;
  31044. }
  31045. /**
  31046. * @hidden
  31047. **/
  31048. class _InternalAbstractMeshDataInfo {
  31049. _hasVertexAlpha: boolean;
  31050. _useVertexColors: boolean;
  31051. _numBoneInfluencers: number;
  31052. _applyFog: boolean;
  31053. _receiveShadows: boolean;
  31054. _facetData: _FacetDataStorage;
  31055. _visibility: number;
  31056. _skeleton: Nullable<Skeleton>;
  31057. _layerMask: number;
  31058. _computeBonesUsingShaders: boolean;
  31059. _isActive: boolean;
  31060. _onlyForInstances: boolean;
  31061. _isActiveIntermediate: boolean;
  31062. _onlyForInstancesIntermediate: boolean;
  31063. _actAsRegularMesh: boolean;
  31064. }
  31065. /**
  31066. * Class used to store all common mesh properties
  31067. */
  31068. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31069. /** No occlusion */
  31070. static OCCLUSION_TYPE_NONE: number;
  31071. /** Occlusion set to optimisitic */
  31072. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31073. /** Occlusion set to strict */
  31074. static OCCLUSION_TYPE_STRICT: number;
  31075. /** Use an accurante occlusion algorithm */
  31076. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31077. /** Use a conservative occlusion algorithm */
  31078. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31079. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31080. * Test order :
  31081. * Is the bounding sphere outside the frustum ?
  31082. * If not, are the bounding box vertices outside the frustum ?
  31083. * It not, then the cullable object is in the frustum.
  31084. */
  31085. static readonly CULLINGSTRATEGY_STANDARD: number;
  31086. /** Culling strategy : Bounding Sphere Only.
  31087. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31088. * It's also less accurate than the standard because some not visible objects can still be selected.
  31089. * Test : is the bounding sphere outside the frustum ?
  31090. * If not, then the cullable object is in the frustum.
  31091. */
  31092. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31093. /** Culling strategy : Optimistic Inclusion.
  31094. * This in an inclusion test first, then the standard exclusion test.
  31095. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31096. * 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.
  31097. * Anyway, it's as accurate as the standard strategy.
  31098. * Test :
  31099. * Is the cullable object bounding sphere center in the frustum ?
  31100. * If not, apply the default culling strategy.
  31101. */
  31102. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31103. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31104. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31105. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31106. * 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.
  31107. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31108. * Test :
  31109. * Is the cullable object bounding sphere center in the frustum ?
  31110. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31111. */
  31112. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31113. /**
  31114. * No billboard
  31115. */
  31116. static get BILLBOARDMODE_NONE(): number;
  31117. /** Billboard on X axis */
  31118. static get BILLBOARDMODE_X(): number;
  31119. /** Billboard on Y axis */
  31120. static get BILLBOARDMODE_Y(): number;
  31121. /** Billboard on Z axis */
  31122. static get BILLBOARDMODE_Z(): number;
  31123. /** Billboard on all axes */
  31124. static get BILLBOARDMODE_ALL(): number;
  31125. /** Billboard on using position instead of orientation */
  31126. static get BILLBOARDMODE_USE_POSITION(): number;
  31127. /** @hidden */
  31128. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31129. /**
  31130. * The culling strategy to use to check whether the mesh must be rendered or not.
  31131. * This value can be changed at any time and will be used on the next render mesh selection.
  31132. * The possible values are :
  31133. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31134. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31135. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31136. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31137. * Please read each static variable documentation to get details about the culling process.
  31138. * */
  31139. cullingStrategy: number;
  31140. /**
  31141. * Gets the number of facets in the mesh
  31142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31143. */
  31144. get facetNb(): number;
  31145. /**
  31146. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31148. */
  31149. get partitioningSubdivisions(): number;
  31150. set partitioningSubdivisions(nb: number);
  31151. /**
  31152. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31153. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31155. */
  31156. get partitioningBBoxRatio(): number;
  31157. set partitioningBBoxRatio(ratio: number);
  31158. /**
  31159. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31160. * Works only for updatable meshes.
  31161. * Doesn't work with multi-materials
  31162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31163. */
  31164. get mustDepthSortFacets(): boolean;
  31165. set mustDepthSortFacets(sort: boolean);
  31166. /**
  31167. * The location (Vector3) where the facet depth sort must be computed from.
  31168. * By default, the active camera position.
  31169. * Used only when facet depth sort is enabled
  31170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31171. */
  31172. get facetDepthSortFrom(): Vector3;
  31173. set facetDepthSortFrom(location: Vector3);
  31174. /**
  31175. * gets a boolean indicating if facetData is enabled
  31176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31177. */
  31178. get isFacetDataEnabled(): boolean;
  31179. /** @hidden */
  31180. _updateNonUniformScalingState(value: boolean): boolean;
  31181. /**
  31182. * An event triggered when this mesh collides with another one
  31183. */
  31184. onCollideObservable: Observable<AbstractMesh>;
  31185. /** Set a function to call when this mesh collides with another one */
  31186. set onCollide(callback: () => void);
  31187. /**
  31188. * An event triggered when the collision's position changes
  31189. */
  31190. onCollisionPositionChangeObservable: Observable<Vector3>;
  31191. /** Set a function to call when the collision's position changes */
  31192. set onCollisionPositionChange(callback: () => void);
  31193. /**
  31194. * An event triggered when material is changed
  31195. */
  31196. onMaterialChangedObservable: Observable<AbstractMesh>;
  31197. /**
  31198. * Gets or sets the orientation for POV movement & rotation
  31199. */
  31200. definedFacingForward: boolean;
  31201. /** @hidden */
  31202. _occlusionQuery: Nullable<WebGLQuery>;
  31203. /** @hidden */
  31204. _renderingGroup: Nullable<RenderingGroup>;
  31205. /**
  31206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31207. */
  31208. get visibility(): number;
  31209. /**
  31210. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31211. */
  31212. set visibility(value: number);
  31213. /** Gets or sets the alpha index used to sort transparent meshes
  31214. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31215. */
  31216. alphaIndex: number;
  31217. /**
  31218. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31219. */
  31220. isVisible: boolean;
  31221. /**
  31222. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31223. */
  31224. isPickable: boolean;
  31225. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31226. showSubMeshesBoundingBox: boolean;
  31227. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31229. */
  31230. isBlocker: boolean;
  31231. /**
  31232. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31233. */
  31234. enablePointerMoveEvents: boolean;
  31235. /**
  31236. * Specifies the rendering group id for this mesh (0 by default)
  31237. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31238. */
  31239. renderingGroupId: number;
  31240. private _material;
  31241. /** Gets or sets current material */
  31242. get material(): Nullable<Material>;
  31243. set material(value: Nullable<Material>);
  31244. /**
  31245. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31246. * @see http://doc.babylonjs.com/babylon101/shadows
  31247. */
  31248. get receiveShadows(): boolean;
  31249. set receiveShadows(value: boolean);
  31250. /** Defines color to use when rendering outline */
  31251. outlineColor: Color3;
  31252. /** Define width to use when rendering outline */
  31253. outlineWidth: number;
  31254. /** Defines color to use when rendering overlay */
  31255. overlayColor: Color3;
  31256. /** Defines alpha to use when rendering overlay */
  31257. overlayAlpha: number;
  31258. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31259. get hasVertexAlpha(): boolean;
  31260. set hasVertexAlpha(value: boolean);
  31261. /** 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) */
  31262. get useVertexColors(): boolean;
  31263. set useVertexColors(value: boolean);
  31264. /**
  31265. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31266. */
  31267. get computeBonesUsingShaders(): boolean;
  31268. set computeBonesUsingShaders(value: boolean);
  31269. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31270. get numBoneInfluencers(): number;
  31271. set numBoneInfluencers(value: number);
  31272. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31273. get applyFog(): boolean;
  31274. set applyFog(value: boolean);
  31275. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31276. useOctreeForRenderingSelection: boolean;
  31277. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31278. useOctreeForPicking: boolean;
  31279. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31280. useOctreeForCollisions: boolean;
  31281. /**
  31282. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31283. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31284. */
  31285. get layerMask(): number;
  31286. set layerMask(value: number);
  31287. /**
  31288. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31289. */
  31290. alwaysSelectAsActiveMesh: boolean;
  31291. /**
  31292. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31293. */
  31294. doNotSyncBoundingInfo: boolean;
  31295. /**
  31296. * Gets or sets the current action manager
  31297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31298. */
  31299. actionManager: Nullable<AbstractActionManager>;
  31300. private _meshCollisionData;
  31301. /**
  31302. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31304. */
  31305. ellipsoid: Vector3;
  31306. /**
  31307. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31308. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31309. */
  31310. ellipsoidOffset: Vector3;
  31311. /**
  31312. * Gets or sets a collision mask used to mask collisions (default is -1).
  31313. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31314. */
  31315. get collisionMask(): number;
  31316. set collisionMask(mask: number);
  31317. /**
  31318. * Gets or sets the current collision group mask (-1 by default).
  31319. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31320. */
  31321. get collisionGroup(): number;
  31322. set collisionGroup(mask: number);
  31323. /**
  31324. * Gets or sets current surrounding meshes (null by default).
  31325. *
  31326. * By default collision detection is tested against every mesh in the scene.
  31327. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31328. * meshes will be tested for the collision.
  31329. *
  31330. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31331. */
  31332. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31333. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31334. /**
  31335. * Defines edge width used when edgesRenderer is enabled
  31336. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31337. */
  31338. edgesWidth: number;
  31339. /**
  31340. * Defines edge color used when edgesRenderer is enabled
  31341. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31342. */
  31343. edgesColor: Color4;
  31344. /** @hidden */
  31345. _edgesRenderer: Nullable<IEdgesRenderer>;
  31346. /** @hidden */
  31347. _masterMesh: Nullable<AbstractMesh>;
  31348. /** @hidden */
  31349. _boundingInfo: Nullable<BoundingInfo>;
  31350. /** @hidden */
  31351. _renderId: number;
  31352. /**
  31353. * Gets or sets the list of subMeshes
  31354. * @see http://doc.babylonjs.com/how_to/multi_materials
  31355. */
  31356. subMeshes: SubMesh[];
  31357. /** @hidden */
  31358. _intersectionsInProgress: AbstractMesh[];
  31359. /** @hidden */
  31360. _unIndexed: boolean;
  31361. /** @hidden */
  31362. _lightSources: Light[];
  31363. /** Gets the list of lights affecting that mesh */
  31364. get lightSources(): Light[];
  31365. /** @hidden */
  31366. get _positions(): Nullable<Vector3[]>;
  31367. /** @hidden */
  31368. _waitingData: {
  31369. lods: Nullable<any>;
  31370. actions: Nullable<any>;
  31371. freezeWorldMatrix: Nullable<boolean>;
  31372. };
  31373. /** @hidden */
  31374. _bonesTransformMatrices: Nullable<Float32Array>;
  31375. /** @hidden */
  31376. _transformMatrixTexture: Nullable<RawTexture>;
  31377. /**
  31378. * Gets or sets a skeleton to apply skining transformations
  31379. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31380. */
  31381. set skeleton(value: Nullable<Skeleton>);
  31382. get skeleton(): Nullable<Skeleton>;
  31383. /**
  31384. * An event triggered when the mesh is rebuilt.
  31385. */
  31386. onRebuildObservable: Observable<AbstractMesh>;
  31387. /**
  31388. * Creates a new AbstractMesh
  31389. * @param name defines the name of the mesh
  31390. * @param scene defines the hosting scene
  31391. */
  31392. constructor(name: string, scene?: Nullable<Scene>);
  31393. /**
  31394. * Returns the string "AbstractMesh"
  31395. * @returns "AbstractMesh"
  31396. */
  31397. getClassName(): string;
  31398. /**
  31399. * Gets a string representation of the current mesh
  31400. * @param fullDetails defines a boolean indicating if full details must be included
  31401. * @returns a string representation of the current mesh
  31402. */
  31403. toString(fullDetails?: boolean): string;
  31404. /**
  31405. * @hidden
  31406. */
  31407. protected _getEffectiveParent(): Nullable<Node>;
  31408. /** @hidden */
  31409. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31410. /** @hidden */
  31411. _rebuild(): void;
  31412. /** @hidden */
  31413. _resyncLightSources(): void;
  31414. /** @hidden */
  31415. _resyncLightSource(light: Light): void;
  31416. /** @hidden */
  31417. _unBindEffect(): void;
  31418. /** @hidden */
  31419. _removeLightSource(light: Light, dispose: boolean): void;
  31420. private _markSubMeshesAsDirty;
  31421. /** @hidden */
  31422. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31423. /** @hidden */
  31424. _markSubMeshesAsAttributesDirty(): void;
  31425. /** @hidden */
  31426. _markSubMeshesAsMiscDirty(): void;
  31427. /**
  31428. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31429. */
  31430. get scaling(): Vector3;
  31431. set scaling(newScaling: Vector3);
  31432. /**
  31433. * Returns true if the mesh is blocked. Implemented by child classes
  31434. */
  31435. get isBlocked(): boolean;
  31436. /**
  31437. * Returns the mesh itself by default. Implemented by child classes
  31438. * @param camera defines the camera to use to pick the right LOD level
  31439. * @returns the currentAbstractMesh
  31440. */
  31441. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31442. /**
  31443. * Returns 0 by default. Implemented by child classes
  31444. * @returns an integer
  31445. */
  31446. getTotalVertices(): number;
  31447. /**
  31448. * Returns a positive integer : the total number of indices in this mesh geometry.
  31449. * @returns the numner of indices or zero if the mesh has no geometry.
  31450. */
  31451. getTotalIndices(): number;
  31452. /**
  31453. * Returns null by default. Implemented by child classes
  31454. * @returns null
  31455. */
  31456. getIndices(): Nullable<IndicesArray>;
  31457. /**
  31458. * Returns the array of the requested vertex data kind. Implemented by child classes
  31459. * @param kind defines the vertex data kind to use
  31460. * @returns null
  31461. */
  31462. getVerticesData(kind: string): Nullable<FloatArray>;
  31463. /**
  31464. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31465. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31466. * Note that a new underlying VertexBuffer object is created each call.
  31467. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31468. * @param kind defines vertex data kind:
  31469. * * VertexBuffer.PositionKind
  31470. * * VertexBuffer.UVKind
  31471. * * VertexBuffer.UV2Kind
  31472. * * VertexBuffer.UV3Kind
  31473. * * VertexBuffer.UV4Kind
  31474. * * VertexBuffer.UV5Kind
  31475. * * VertexBuffer.UV6Kind
  31476. * * VertexBuffer.ColorKind
  31477. * * VertexBuffer.MatricesIndicesKind
  31478. * * VertexBuffer.MatricesIndicesExtraKind
  31479. * * VertexBuffer.MatricesWeightsKind
  31480. * * VertexBuffer.MatricesWeightsExtraKind
  31481. * @param data defines the data source
  31482. * @param updatable defines if the data must be flagged as updatable (or static)
  31483. * @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
  31484. * @returns the current mesh
  31485. */
  31486. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31487. /**
  31488. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31489. * If the mesh has no geometry, it is simply returned as it is.
  31490. * @param kind defines vertex data kind:
  31491. * * VertexBuffer.PositionKind
  31492. * * VertexBuffer.UVKind
  31493. * * VertexBuffer.UV2Kind
  31494. * * VertexBuffer.UV3Kind
  31495. * * VertexBuffer.UV4Kind
  31496. * * VertexBuffer.UV5Kind
  31497. * * VertexBuffer.UV6Kind
  31498. * * VertexBuffer.ColorKind
  31499. * * VertexBuffer.MatricesIndicesKind
  31500. * * VertexBuffer.MatricesIndicesExtraKind
  31501. * * VertexBuffer.MatricesWeightsKind
  31502. * * VertexBuffer.MatricesWeightsExtraKind
  31503. * @param data defines the data source
  31504. * @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
  31505. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31506. * @returns the current mesh
  31507. */
  31508. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31509. /**
  31510. * Sets the mesh indices,
  31511. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31512. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31513. * @param totalVertices Defines the total number of vertices
  31514. * @returns the current mesh
  31515. */
  31516. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31517. /**
  31518. * Gets a boolean indicating if specific vertex data is present
  31519. * @param kind defines the vertex data kind to use
  31520. * @returns true is data kind is present
  31521. */
  31522. isVerticesDataPresent(kind: string): boolean;
  31523. /**
  31524. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31525. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31526. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31527. * @returns a BoundingInfo
  31528. */
  31529. getBoundingInfo(): BoundingInfo;
  31530. /**
  31531. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31532. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31533. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31534. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31535. * @returns the current mesh
  31536. */
  31537. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31538. /**
  31539. * Overwrite the current bounding info
  31540. * @param boundingInfo defines the new bounding info
  31541. * @returns the current mesh
  31542. */
  31543. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31544. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31545. get useBones(): boolean;
  31546. /** @hidden */
  31547. _preActivate(): void;
  31548. /** @hidden */
  31549. _preActivateForIntermediateRendering(renderId: number): void;
  31550. /** @hidden */
  31551. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31552. /** @hidden */
  31553. _postActivate(): void;
  31554. /** @hidden */
  31555. _freeze(): void;
  31556. /** @hidden */
  31557. _unFreeze(): void;
  31558. /**
  31559. * Gets the current world matrix
  31560. * @returns a Matrix
  31561. */
  31562. getWorldMatrix(): Matrix;
  31563. /** @hidden */
  31564. _getWorldMatrixDeterminant(): number;
  31565. /**
  31566. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31567. */
  31568. get isAnInstance(): boolean;
  31569. /**
  31570. * Gets a boolean indicating if this mesh has instances
  31571. */
  31572. get hasInstances(): boolean;
  31573. /**
  31574. * Gets a boolean indicating if this mesh has thin instances
  31575. */
  31576. get hasThinInstances(): boolean;
  31577. /**
  31578. * Perform relative position change from the point of view of behind the front of the mesh.
  31579. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31580. * Supports definition of mesh facing forward or backward
  31581. * @param amountRight defines the distance on the right axis
  31582. * @param amountUp defines the distance on the up axis
  31583. * @param amountForward defines the distance on the forward axis
  31584. * @returns the current mesh
  31585. */
  31586. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31587. /**
  31588. * Calculate relative position change from the point of view of behind the front of the mesh.
  31589. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31590. * Supports definition of mesh facing forward or backward
  31591. * @param amountRight defines the distance on the right axis
  31592. * @param amountUp defines the distance on the up axis
  31593. * @param amountForward defines the distance on the forward axis
  31594. * @returns the new displacement vector
  31595. */
  31596. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31597. /**
  31598. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31599. * Supports definition of mesh facing forward or backward
  31600. * @param flipBack defines the flip
  31601. * @param twirlClockwise defines the twirl
  31602. * @param tiltRight defines the tilt
  31603. * @returns the current mesh
  31604. */
  31605. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31606. /**
  31607. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31608. * Supports definition of mesh facing forward or backward.
  31609. * @param flipBack defines the flip
  31610. * @param twirlClockwise defines the twirl
  31611. * @param tiltRight defines the tilt
  31612. * @returns the new rotation vector
  31613. */
  31614. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31615. /**
  31616. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31617. * This means the mesh underlying bounding box and sphere are recomputed.
  31618. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31619. * @returns the current mesh
  31620. */
  31621. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31622. /** @hidden */
  31623. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31624. /** @hidden */
  31625. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31626. /** @hidden */
  31627. _updateBoundingInfo(): AbstractMesh;
  31628. /** @hidden */
  31629. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31630. /** @hidden */
  31631. protected _afterComputeWorldMatrix(): void;
  31632. /** @hidden */
  31633. get _effectiveMesh(): AbstractMesh;
  31634. /**
  31635. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31636. * A mesh is in the frustum if its bounding box intersects the frustum
  31637. * @param frustumPlanes defines the frustum to test
  31638. * @returns true if the mesh is in the frustum planes
  31639. */
  31640. isInFrustum(frustumPlanes: Plane[]): boolean;
  31641. /**
  31642. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31643. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31644. * @param frustumPlanes defines the frustum to test
  31645. * @returns true if the mesh is completely in the frustum planes
  31646. */
  31647. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31648. /**
  31649. * True if the mesh intersects another mesh or a SolidParticle object
  31650. * @param mesh defines a target mesh or SolidParticle to test
  31651. * @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)
  31652. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31653. * @returns true if there is an intersection
  31654. */
  31655. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31656. /**
  31657. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31658. * @param point defines the point to test
  31659. * @returns true if there is an intersection
  31660. */
  31661. intersectsPoint(point: Vector3): boolean;
  31662. /**
  31663. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31664. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31665. */
  31666. get checkCollisions(): boolean;
  31667. set checkCollisions(collisionEnabled: boolean);
  31668. /**
  31669. * Gets Collider object used to compute collisions (not physics)
  31670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31671. */
  31672. get collider(): Nullable<Collider>;
  31673. /**
  31674. * Move the mesh using collision engine
  31675. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31676. * @param displacement defines the requested displacement vector
  31677. * @returns the current mesh
  31678. */
  31679. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31680. private _onCollisionPositionChange;
  31681. /** @hidden */
  31682. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31683. /** @hidden */
  31684. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31685. /** @hidden */
  31686. _checkCollision(collider: Collider): AbstractMesh;
  31687. /** @hidden */
  31688. _generatePointsArray(): boolean;
  31689. /**
  31690. * Checks if the passed Ray intersects with the mesh
  31691. * @param ray defines the ray to use
  31692. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31694. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31695. * @returns the picking info
  31696. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31697. */
  31698. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31699. /**
  31700. * Clones the current mesh
  31701. * @param name defines the mesh name
  31702. * @param newParent defines the new mesh parent
  31703. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31704. * @returns the new mesh
  31705. */
  31706. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31707. /**
  31708. * Disposes all the submeshes of the current meshnp
  31709. * @returns the current mesh
  31710. */
  31711. releaseSubMeshes(): AbstractMesh;
  31712. /**
  31713. * Releases resources associated with this abstract mesh.
  31714. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31715. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31716. */
  31717. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31718. /**
  31719. * Adds the passed mesh as a child to the current mesh
  31720. * @param mesh defines the child mesh
  31721. * @returns the current mesh
  31722. */
  31723. addChild(mesh: AbstractMesh): AbstractMesh;
  31724. /**
  31725. * Removes the passed mesh from the current mesh children list
  31726. * @param mesh defines the child mesh
  31727. * @returns the current mesh
  31728. */
  31729. removeChild(mesh: AbstractMesh): AbstractMesh;
  31730. /** @hidden */
  31731. private _initFacetData;
  31732. /**
  31733. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31734. * This method can be called within the render loop.
  31735. * 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
  31736. * @returns the current mesh
  31737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31738. */
  31739. updateFacetData(): AbstractMesh;
  31740. /**
  31741. * Returns the facetLocalNormals array.
  31742. * The normals are expressed in the mesh local spac
  31743. * @returns an array of Vector3
  31744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31745. */
  31746. getFacetLocalNormals(): Vector3[];
  31747. /**
  31748. * Returns the facetLocalPositions array.
  31749. * The facet positions are expressed in the mesh local space
  31750. * @returns an array of Vector3
  31751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31752. */
  31753. getFacetLocalPositions(): Vector3[];
  31754. /**
  31755. * Returns the facetLocalPartioning array
  31756. * @returns an array of array of numbers
  31757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31758. */
  31759. getFacetLocalPartitioning(): number[][];
  31760. /**
  31761. * Returns the i-th facet position in the world system.
  31762. * This method allocates a new Vector3 per call
  31763. * @param i defines the facet index
  31764. * @returns a new Vector3
  31765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31766. */
  31767. getFacetPosition(i: number): Vector3;
  31768. /**
  31769. * Sets the reference Vector3 with the i-th facet position in the world system
  31770. * @param i defines the facet index
  31771. * @param ref defines the target vector
  31772. * @returns the current mesh
  31773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31774. */
  31775. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31776. /**
  31777. * Returns the i-th facet normal in the world system.
  31778. * This method allocates a new Vector3 per call
  31779. * @param i defines the facet index
  31780. * @returns a new Vector3
  31781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31782. */
  31783. getFacetNormal(i: number): Vector3;
  31784. /**
  31785. * Sets the reference Vector3 with the i-th facet normal in the world system
  31786. * @param i defines the facet index
  31787. * @param ref defines the target vector
  31788. * @returns the current mesh
  31789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31790. */
  31791. getFacetNormalToRef(i: number, ref: Vector3): this;
  31792. /**
  31793. * 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)
  31794. * @param x defines x coordinate
  31795. * @param y defines y coordinate
  31796. * @param z defines z coordinate
  31797. * @returns the array of facet indexes
  31798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31799. */
  31800. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31801. /**
  31802. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31803. * @param projected sets as the (x,y,z) world projection on the facet
  31804. * @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
  31805. * @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
  31806. * @param x defines x coordinate
  31807. * @param y defines y coordinate
  31808. * @param z defines z coordinate
  31809. * @returns the face index if found (or null instead)
  31810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31811. */
  31812. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31813. /**
  31814. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31815. * @param projected sets as the (x,y,z) local projection on the facet
  31816. * @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
  31817. * @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
  31818. * @param x defines x coordinate
  31819. * @param y defines y coordinate
  31820. * @param z defines z coordinate
  31821. * @returns the face index if found (or null instead)
  31822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31823. */
  31824. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31825. /**
  31826. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31827. * @returns the parameters
  31828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31829. */
  31830. getFacetDataParameters(): any;
  31831. /**
  31832. * Disables the feature FacetData and frees the related memory
  31833. * @returns the current mesh
  31834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31835. */
  31836. disableFacetData(): AbstractMesh;
  31837. /**
  31838. * Updates the AbstractMesh indices array
  31839. * @param indices defines the data source
  31840. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31841. * @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)
  31842. * @returns the current mesh
  31843. */
  31844. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31845. /**
  31846. * Creates new normals data for the mesh
  31847. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31848. * @returns the current mesh
  31849. */
  31850. createNormals(updatable: boolean): AbstractMesh;
  31851. /**
  31852. * Align the mesh with a normal
  31853. * @param normal defines the normal to use
  31854. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31855. * @returns the current mesh
  31856. */
  31857. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31858. /** @hidden */
  31859. _checkOcclusionQuery(): boolean;
  31860. /**
  31861. * Disables the mesh edge rendering mode
  31862. * @returns the currentAbstractMesh
  31863. */
  31864. disableEdgesRendering(): AbstractMesh;
  31865. /**
  31866. * Enables the edge rendering mode on the mesh.
  31867. * This mode makes the mesh edges visible
  31868. * @param epsilon defines the maximal distance between two angles to detect a face
  31869. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31870. * @returns the currentAbstractMesh
  31871. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31872. */
  31873. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31874. }
  31875. }
  31876. declare module BABYLON {
  31877. /**
  31878. * Interface used to define ActionEvent
  31879. */
  31880. export interface IActionEvent {
  31881. /** The mesh or sprite that triggered the action */
  31882. source: any;
  31883. /** The X mouse cursor position at the time of the event */
  31884. pointerX: number;
  31885. /** The Y mouse cursor position at the time of the event */
  31886. pointerY: number;
  31887. /** The mesh that is currently pointed at (can be null) */
  31888. meshUnderPointer: Nullable<AbstractMesh>;
  31889. /** the original (browser) event that triggered the ActionEvent */
  31890. sourceEvent?: any;
  31891. /** additional data for the event */
  31892. additionalData?: any;
  31893. }
  31894. /**
  31895. * ActionEvent is the event being sent when an action is triggered.
  31896. */
  31897. export class ActionEvent implements IActionEvent {
  31898. /** The mesh or sprite that triggered the action */
  31899. source: any;
  31900. /** The X mouse cursor position at the time of the event */
  31901. pointerX: number;
  31902. /** The Y mouse cursor position at the time of the event */
  31903. pointerY: number;
  31904. /** The mesh that is currently pointed at (can be null) */
  31905. meshUnderPointer: Nullable<AbstractMesh>;
  31906. /** the original (browser) event that triggered the ActionEvent */
  31907. sourceEvent?: any;
  31908. /** additional data for the event */
  31909. additionalData?: any;
  31910. /**
  31911. * Creates a new ActionEvent
  31912. * @param source The mesh or sprite that triggered the action
  31913. * @param pointerX The X mouse cursor position at the time of the event
  31914. * @param pointerY The Y mouse cursor position at the time of the event
  31915. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31916. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31917. * @param additionalData additional data for the event
  31918. */
  31919. constructor(
  31920. /** The mesh or sprite that triggered the action */
  31921. source: any,
  31922. /** The X mouse cursor position at the time of the event */
  31923. pointerX: number,
  31924. /** The Y mouse cursor position at the time of the event */
  31925. pointerY: number,
  31926. /** The mesh that is currently pointed at (can be null) */
  31927. meshUnderPointer: Nullable<AbstractMesh>,
  31928. /** the original (browser) event that triggered the ActionEvent */
  31929. sourceEvent?: any,
  31930. /** additional data for the event */
  31931. additionalData?: any);
  31932. /**
  31933. * Helper function to auto-create an ActionEvent from a source mesh.
  31934. * @param source The source mesh that triggered the event
  31935. * @param evt The original (browser) event
  31936. * @param additionalData additional data for the event
  31937. * @returns the new ActionEvent
  31938. */
  31939. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31940. /**
  31941. * Helper function to auto-create an ActionEvent from a source sprite
  31942. * @param source The source sprite that triggered the event
  31943. * @param scene Scene associated with the sprite
  31944. * @param evt The original (browser) event
  31945. * @param additionalData additional data for the event
  31946. * @returns the new ActionEvent
  31947. */
  31948. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31949. /**
  31950. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31951. * @param scene the scene where the event occurred
  31952. * @param evt The original (browser) event
  31953. * @returns the new ActionEvent
  31954. */
  31955. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31956. /**
  31957. * Helper function to auto-create an ActionEvent from a primitive
  31958. * @param prim defines the target primitive
  31959. * @param pointerPos defines the pointer position
  31960. * @param evt The original (browser) event
  31961. * @param additionalData additional data for the event
  31962. * @returns the new ActionEvent
  31963. */
  31964. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31965. }
  31966. }
  31967. declare module BABYLON {
  31968. /**
  31969. * Abstract class used to decouple action Manager from scene and meshes.
  31970. * Do not instantiate.
  31971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31972. */
  31973. export abstract class AbstractActionManager implements IDisposable {
  31974. /** Gets the list of active triggers */
  31975. static Triggers: {
  31976. [key: string]: number;
  31977. };
  31978. /** Gets the cursor to use when hovering items */
  31979. hoverCursor: string;
  31980. /** Gets the list of actions */
  31981. actions: IAction[];
  31982. /**
  31983. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31984. */
  31985. isRecursive: boolean;
  31986. /**
  31987. * Releases all associated resources
  31988. */
  31989. abstract dispose(): void;
  31990. /**
  31991. * Does this action manager has pointer triggers
  31992. */
  31993. abstract get hasPointerTriggers(): boolean;
  31994. /**
  31995. * Does this action manager has pick triggers
  31996. */
  31997. abstract get hasPickTriggers(): boolean;
  31998. /**
  31999. * Process a specific trigger
  32000. * @param trigger defines the trigger to process
  32001. * @param evt defines the event details to be processed
  32002. */
  32003. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32004. /**
  32005. * Does this action manager handles actions of any of the given triggers
  32006. * @param triggers defines the triggers to be tested
  32007. * @return a boolean indicating whether one (or more) of the triggers is handled
  32008. */
  32009. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32010. /**
  32011. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32012. * speed.
  32013. * @param triggerA defines the trigger to be tested
  32014. * @param triggerB defines the trigger to be tested
  32015. * @return a boolean indicating whether one (or more) of the triggers is handled
  32016. */
  32017. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32018. /**
  32019. * Does this action manager handles actions of a given trigger
  32020. * @param trigger defines the trigger to be tested
  32021. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32022. * @return whether the trigger is handled
  32023. */
  32024. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32025. /**
  32026. * Serialize this manager to a JSON object
  32027. * @param name defines the property name to store this manager
  32028. * @returns a JSON representation of this manager
  32029. */
  32030. abstract serialize(name: string): any;
  32031. /**
  32032. * Registers an action to this action manager
  32033. * @param action defines the action to be registered
  32034. * @return the action amended (prepared) after registration
  32035. */
  32036. abstract registerAction(action: IAction): Nullable<IAction>;
  32037. /**
  32038. * Unregisters an action to this action manager
  32039. * @param action defines the action to be unregistered
  32040. * @return a boolean indicating whether the action has been unregistered
  32041. */
  32042. abstract unregisterAction(action: IAction): Boolean;
  32043. /**
  32044. * Does exist one action manager with at least one trigger
  32045. **/
  32046. static get HasTriggers(): boolean;
  32047. /**
  32048. * Does exist one action manager with at least one pick trigger
  32049. **/
  32050. static get HasPickTriggers(): boolean;
  32051. /**
  32052. * Does exist one action manager that handles actions of a given trigger
  32053. * @param trigger defines the trigger to be tested
  32054. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32055. **/
  32056. static HasSpecificTrigger(trigger: number): boolean;
  32057. }
  32058. }
  32059. declare module BABYLON {
  32060. /**
  32061. * Defines how a node can be built from a string name.
  32062. */
  32063. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32064. /**
  32065. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32066. */
  32067. export class Node implements IBehaviorAware<Node> {
  32068. /** @hidden */
  32069. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32070. private static _NodeConstructors;
  32071. /**
  32072. * Add a new node constructor
  32073. * @param type defines the type name of the node to construct
  32074. * @param constructorFunc defines the constructor function
  32075. */
  32076. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32077. /**
  32078. * Returns a node constructor based on type name
  32079. * @param type defines the type name
  32080. * @param name defines the new node name
  32081. * @param scene defines the hosting scene
  32082. * @param options defines optional options to transmit to constructors
  32083. * @returns the new constructor or null
  32084. */
  32085. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32086. /**
  32087. * Gets or sets the name of the node
  32088. */
  32089. name: string;
  32090. /**
  32091. * Gets or sets the id of the node
  32092. */
  32093. id: string;
  32094. /**
  32095. * Gets or sets the unique id of the node
  32096. */
  32097. uniqueId: number;
  32098. /**
  32099. * Gets or sets a string used to store user defined state for the node
  32100. */
  32101. state: string;
  32102. /**
  32103. * Gets or sets an object used to store user defined information for the node
  32104. */
  32105. metadata: any;
  32106. /**
  32107. * For internal use only. Please do not use.
  32108. */
  32109. reservedDataStore: any;
  32110. /**
  32111. * List of inspectable custom properties (used by the Inspector)
  32112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32113. */
  32114. inspectableCustomProperties: IInspectable[];
  32115. private _doNotSerialize;
  32116. /**
  32117. * Gets or sets a boolean used to define if the node must be serialized
  32118. */
  32119. get doNotSerialize(): boolean;
  32120. set doNotSerialize(value: boolean);
  32121. /** @hidden */
  32122. _isDisposed: boolean;
  32123. /**
  32124. * Gets a list of Animations associated with the node
  32125. */
  32126. animations: Animation[];
  32127. protected _ranges: {
  32128. [name: string]: Nullable<AnimationRange>;
  32129. };
  32130. /**
  32131. * Callback raised when the node is ready to be used
  32132. */
  32133. onReady: Nullable<(node: Node) => void>;
  32134. private _isEnabled;
  32135. private _isParentEnabled;
  32136. private _isReady;
  32137. /** @hidden */
  32138. _currentRenderId: number;
  32139. private _parentUpdateId;
  32140. /** @hidden */
  32141. _childUpdateId: number;
  32142. /** @hidden */
  32143. _waitingParentId: Nullable<string>;
  32144. /** @hidden */
  32145. _scene: Scene;
  32146. /** @hidden */
  32147. _cache: any;
  32148. private _parentNode;
  32149. private _children;
  32150. /** @hidden */
  32151. _worldMatrix: Matrix;
  32152. /** @hidden */
  32153. _worldMatrixDeterminant: number;
  32154. /** @hidden */
  32155. _worldMatrixDeterminantIsDirty: boolean;
  32156. /** @hidden */
  32157. private _sceneRootNodesIndex;
  32158. /**
  32159. * Gets a boolean indicating if the node has been disposed
  32160. * @returns true if the node was disposed
  32161. */
  32162. isDisposed(): boolean;
  32163. /**
  32164. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32165. * @see https://doc.babylonjs.com/how_to/parenting
  32166. */
  32167. set parent(parent: Nullable<Node>);
  32168. get parent(): Nullable<Node>;
  32169. /** @hidden */
  32170. _addToSceneRootNodes(): void;
  32171. /** @hidden */
  32172. _removeFromSceneRootNodes(): void;
  32173. private _animationPropertiesOverride;
  32174. /**
  32175. * Gets or sets the animation properties override
  32176. */
  32177. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32178. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32179. /**
  32180. * Gets a string idenfifying the name of the class
  32181. * @returns "Node" string
  32182. */
  32183. getClassName(): string;
  32184. /** @hidden */
  32185. readonly _isNode: boolean;
  32186. /**
  32187. * An event triggered when the mesh is disposed
  32188. */
  32189. onDisposeObservable: Observable<Node>;
  32190. private _onDisposeObserver;
  32191. /**
  32192. * Sets a callback that will be raised when the node will be disposed
  32193. */
  32194. set onDispose(callback: () => void);
  32195. /**
  32196. * Creates a new Node
  32197. * @param name the name and id to be given to this node
  32198. * @param scene the scene this node will be added to
  32199. */
  32200. constructor(name: string, scene?: Nullable<Scene>);
  32201. /**
  32202. * Gets the scene of the node
  32203. * @returns a scene
  32204. */
  32205. getScene(): Scene;
  32206. /**
  32207. * Gets the engine of the node
  32208. * @returns a Engine
  32209. */
  32210. getEngine(): Engine;
  32211. private _behaviors;
  32212. /**
  32213. * Attach a behavior to the node
  32214. * @see http://doc.babylonjs.com/features/behaviour
  32215. * @param behavior defines the behavior to attach
  32216. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32217. * @returns the current Node
  32218. */
  32219. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32220. /**
  32221. * Remove an attached behavior
  32222. * @see http://doc.babylonjs.com/features/behaviour
  32223. * @param behavior defines the behavior to attach
  32224. * @returns the current Node
  32225. */
  32226. removeBehavior(behavior: Behavior<Node>): Node;
  32227. /**
  32228. * Gets the list of attached behaviors
  32229. * @see http://doc.babylonjs.com/features/behaviour
  32230. */
  32231. get behaviors(): Behavior<Node>[];
  32232. /**
  32233. * Gets an attached behavior by name
  32234. * @param name defines the name of the behavior to look for
  32235. * @see http://doc.babylonjs.com/features/behaviour
  32236. * @returns null if behavior was not found else the requested behavior
  32237. */
  32238. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32239. /**
  32240. * Returns the latest update of the World matrix
  32241. * @returns a Matrix
  32242. */
  32243. getWorldMatrix(): Matrix;
  32244. /** @hidden */
  32245. _getWorldMatrixDeterminant(): number;
  32246. /**
  32247. * Returns directly the latest state of the mesh World matrix.
  32248. * A Matrix is returned.
  32249. */
  32250. get worldMatrixFromCache(): Matrix;
  32251. /** @hidden */
  32252. _initCache(): void;
  32253. /** @hidden */
  32254. updateCache(force?: boolean): void;
  32255. /** @hidden */
  32256. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32257. /** @hidden */
  32258. _updateCache(ignoreParentClass?: boolean): void;
  32259. /** @hidden */
  32260. _isSynchronized(): boolean;
  32261. /** @hidden */
  32262. _markSyncedWithParent(): void;
  32263. /** @hidden */
  32264. isSynchronizedWithParent(): boolean;
  32265. /** @hidden */
  32266. isSynchronized(): boolean;
  32267. /**
  32268. * Is this node ready to be used/rendered
  32269. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32270. * @return true if the node is ready
  32271. */
  32272. isReady(completeCheck?: boolean): boolean;
  32273. /**
  32274. * Is this node enabled?
  32275. * 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
  32276. * @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
  32277. * @return whether this node (and its parent) is enabled
  32278. */
  32279. isEnabled(checkAncestors?: boolean): boolean;
  32280. /** @hidden */
  32281. protected _syncParentEnabledState(): void;
  32282. /**
  32283. * Set the enabled state of this node
  32284. * @param value defines the new enabled state
  32285. */
  32286. setEnabled(value: boolean): void;
  32287. /**
  32288. * Is this node a descendant of the given node?
  32289. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32290. * @param ancestor defines the parent node to inspect
  32291. * @returns a boolean indicating if this node is a descendant of the given node
  32292. */
  32293. isDescendantOf(ancestor: Node): boolean;
  32294. /** @hidden */
  32295. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32296. /**
  32297. * Will return all nodes that have this node as ascendant
  32298. * @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
  32299. * @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
  32300. * @return all children nodes of all types
  32301. */
  32302. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32303. /**
  32304. * Get all child-meshes of this node
  32305. * @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)
  32306. * @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
  32307. * @returns an array of AbstractMesh
  32308. */
  32309. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32310. /**
  32311. * Get all direct children of this node
  32312. * @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
  32313. * @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)
  32314. * @returns an array of Node
  32315. */
  32316. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32317. /** @hidden */
  32318. _setReady(state: boolean): void;
  32319. /**
  32320. * Get an animation by name
  32321. * @param name defines the name of the animation to look for
  32322. * @returns null if not found else the requested animation
  32323. */
  32324. getAnimationByName(name: string): Nullable<Animation>;
  32325. /**
  32326. * Creates an animation range for this node
  32327. * @param name defines the name of the range
  32328. * @param from defines the starting key
  32329. * @param to defines the end key
  32330. */
  32331. createAnimationRange(name: string, from: number, to: number): void;
  32332. /**
  32333. * Delete a specific animation range
  32334. * @param name defines the name of the range to delete
  32335. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32336. */
  32337. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32338. /**
  32339. * Get an animation range by name
  32340. * @param name defines the name of the animation range to look for
  32341. * @returns null if not found else the requested animation range
  32342. */
  32343. getAnimationRange(name: string): Nullable<AnimationRange>;
  32344. /**
  32345. * Gets the list of all animation ranges defined on this node
  32346. * @returns an array
  32347. */
  32348. getAnimationRanges(): Nullable<AnimationRange>[];
  32349. /**
  32350. * Will start the animation sequence
  32351. * @param name defines the range frames for animation sequence
  32352. * @param loop defines if the animation should loop (false by default)
  32353. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32354. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32355. * @returns the object created for this animation. If range does not exist, it will return null
  32356. */
  32357. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32358. /**
  32359. * Serialize animation ranges into a JSON compatible object
  32360. * @returns serialization object
  32361. */
  32362. serializeAnimationRanges(): any;
  32363. /**
  32364. * Computes the world matrix of the node
  32365. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32366. * @returns the world matrix
  32367. */
  32368. computeWorldMatrix(force?: boolean): Matrix;
  32369. /**
  32370. * Releases resources associated with this node.
  32371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32373. */
  32374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32375. /**
  32376. * Parse animation range data from a serialization object and store them into a given node
  32377. * @param node defines where to store the animation ranges
  32378. * @param parsedNode defines the serialization object to read data from
  32379. * @param scene defines the hosting scene
  32380. */
  32381. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32382. /**
  32383. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32384. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32385. * @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
  32386. * @returns the new bounding vectors
  32387. */
  32388. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32389. min: Vector3;
  32390. max: Vector3;
  32391. };
  32392. }
  32393. }
  32394. declare module BABYLON {
  32395. /**
  32396. * @hidden
  32397. */
  32398. export class _IAnimationState {
  32399. key: number;
  32400. repeatCount: number;
  32401. workValue?: any;
  32402. loopMode?: number;
  32403. offsetValue?: any;
  32404. highLimitValue?: any;
  32405. }
  32406. /**
  32407. * Class used to store any kind of animation
  32408. */
  32409. export class Animation {
  32410. /**Name of the animation */
  32411. name: string;
  32412. /**Property to animate */
  32413. targetProperty: string;
  32414. /**The frames per second of the animation */
  32415. framePerSecond: number;
  32416. /**The data type of the animation */
  32417. dataType: number;
  32418. /**The loop mode of the animation */
  32419. loopMode?: number | undefined;
  32420. /**Specifies if blending should be enabled */
  32421. enableBlending?: boolean | undefined;
  32422. /**
  32423. * Use matrix interpolation instead of using direct key value when animating matrices
  32424. */
  32425. static AllowMatricesInterpolation: boolean;
  32426. /**
  32427. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32428. */
  32429. static AllowMatrixDecomposeForInterpolation: boolean;
  32430. /** Define the Url to load snippets */
  32431. static SnippetUrl: string;
  32432. /** Snippet ID if the animation was created from the snippet server */
  32433. snippetId: string;
  32434. /**
  32435. * Stores the key frames of the animation
  32436. */
  32437. private _keys;
  32438. /**
  32439. * Stores the easing function of the animation
  32440. */
  32441. private _easingFunction;
  32442. /**
  32443. * @hidden Internal use only
  32444. */
  32445. _runtimeAnimations: RuntimeAnimation[];
  32446. /**
  32447. * The set of event that will be linked to this animation
  32448. */
  32449. private _events;
  32450. /**
  32451. * Stores an array of target property paths
  32452. */
  32453. targetPropertyPath: string[];
  32454. /**
  32455. * Stores the blending speed of the animation
  32456. */
  32457. blendingSpeed: number;
  32458. /**
  32459. * Stores the animation ranges for the animation
  32460. */
  32461. private _ranges;
  32462. /**
  32463. * @hidden Internal use
  32464. */
  32465. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32466. /**
  32467. * Sets up an animation
  32468. * @param property The property to animate
  32469. * @param animationType The animation type to apply
  32470. * @param framePerSecond The frames per second of the animation
  32471. * @param easingFunction The easing function used in the animation
  32472. * @returns The created animation
  32473. */
  32474. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32475. /**
  32476. * Create and start an animation on a node
  32477. * @param name defines the name of the global animation that will be run on all nodes
  32478. * @param node defines the root node where the animation will take place
  32479. * @param targetProperty defines property to animate
  32480. * @param framePerSecond defines the number of frame per second yo use
  32481. * @param totalFrame defines the number of frames in total
  32482. * @param from defines the initial value
  32483. * @param to defines the final value
  32484. * @param loopMode defines which loop mode you want to use (off by default)
  32485. * @param easingFunction defines the easing function to use (linear by default)
  32486. * @param onAnimationEnd defines the callback to call when animation end
  32487. * @returns the animatable created for this animation
  32488. */
  32489. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32490. /**
  32491. * Create and start an animation on a node and its descendants
  32492. * @param name defines the name of the global animation that will be run on all nodes
  32493. * @param node defines the root node where the animation will take place
  32494. * @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
  32495. * @param targetProperty defines property to animate
  32496. * @param framePerSecond defines the number of frame per second to use
  32497. * @param totalFrame defines the number of frames in total
  32498. * @param from defines the initial value
  32499. * @param to defines the final value
  32500. * @param loopMode defines which loop mode you want to use (off by default)
  32501. * @param easingFunction defines the easing function to use (linear by default)
  32502. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32503. * @returns the list of animatables created for all nodes
  32504. * @example https://www.babylonjs-playground.com/#MH0VLI
  32505. */
  32506. 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[]>;
  32507. /**
  32508. * Creates a new animation, merges it with the existing animations and starts it
  32509. * @param name Name of the animation
  32510. * @param node Node which contains the scene that begins the animations
  32511. * @param targetProperty Specifies which property to animate
  32512. * @param framePerSecond The frames per second of the animation
  32513. * @param totalFrame The total number of frames
  32514. * @param from The frame at the beginning of the animation
  32515. * @param to The frame at the end of the animation
  32516. * @param loopMode Specifies the loop mode of the animation
  32517. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32518. * @param onAnimationEnd Callback to run once the animation is complete
  32519. * @returns Nullable animation
  32520. */
  32521. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32522. /**
  32523. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32524. * @param sourceAnimation defines the Animation containing keyframes to convert
  32525. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32526. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32527. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32528. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32529. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32530. */
  32531. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32532. /**
  32533. * Transition property of an host to the target Value
  32534. * @param property The property to transition
  32535. * @param targetValue The target Value of the property
  32536. * @param host The object where the property to animate belongs
  32537. * @param scene Scene used to run the animation
  32538. * @param frameRate Framerate (in frame/s) to use
  32539. * @param transition The transition type we want to use
  32540. * @param duration The duration of the animation, in milliseconds
  32541. * @param onAnimationEnd Callback trigger at the end of the animation
  32542. * @returns Nullable animation
  32543. */
  32544. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32545. /**
  32546. * Return the array of runtime animations currently using this animation
  32547. */
  32548. get runtimeAnimations(): RuntimeAnimation[];
  32549. /**
  32550. * Specifies if any of the runtime animations are currently running
  32551. */
  32552. get hasRunningRuntimeAnimations(): boolean;
  32553. /**
  32554. * Initializes the animation
  32555. * @param name Name of the animation
  32556. * @param targetProperty Property to animate
  32557. * @param framePerSecond The frames per second of the animation
  32558. * @param dataType The data type of the animation
  32559. * @param loopMode The loop mode of the animation
  32560. * @param enableBlending Specifies if blending should be enabled
  32561. */
  32562. constructor(
  32563. /**Name of the animation */
  32564. name: string,
  32565. /**Property to animate */
  32566. targetProperty: string,
  32567. /**The frames per second of the animation */
  32568. framePerSecond: number,
  32569. /**The data type of the animation */
  32570. dataType: number,
  32571. /**The loop mode of the animation */
  32572. loopMode?: number | undefined,
  32573. /**Specifies if blending should be enabled */
  32574. enableBlending?: boolean | undefined);
  32575. /**
  32576. * Converts the animation to a string
  32577. * @param fullDetails support for multiple levels of logging within scene loading
  32578. * @returns String form of the animation
  32579. */
  32580. toString(fullDetails?: boolean): string;
  32581. /**
  32582. * Add an event to this animation
  32583. * @param event Event to add
  32584. */
  32585. addEvent(event: AnimationEvent): void;
  32586. /**
  32587. * Remove all events found at the given frame
  32588. * @param frame The frame to remove events from
  32589. */
  32590. removeEvents(frame: number): void;
  32591. /**
  32592. * Retrieves all the events from the animation
  32593. * @returns Events from the animation
  32594. */
  32595. getEvents(): AnimationEvent[];
  32596. /**
  32597. * Creates an animation range
  32598. * @param name Name of the animation range
  32599. * @param from Starting frame of the animation range
  32600. * @param to Ending frame of the animation
  32601. */
  32602. createRange(name: string, from: number, to: number): void;
  32603. /**
  32604. * Deletes an animation range by name
  32605. * @param name Name of the animation range to delete
  32606. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32607. */
  32608. deleteRange(name: string, deleteFrames?: boolean): void;
  32609. /**
  32610. * Gets the animation range by name, or null if not defined
  32611. * @param name Name of the animation range
  32612. * @returns Nullable animation range
  32613. */
  32614. getRange(name: string): Nullable<AnimationRange>;
  32615. /**
  32616. * Gets the key frames from the animation
  32617. * @returns The key frames of the animation
  32618. */
  32619. getKeys(): Array<IAnimationKey>;
  32620. /**
  32621. * Gets the highest frame rate of the animation
  32622. * @returns Highest frame rate of the animation
  32623. */
  32624. getHighestFrame(): number;
  32625. /**
  32626. * Gets the easing function of the animation
  32627. * @returns Easing function of the animation
  32628. */
  32629. getEasingFunction(): IEasingFunction;
  32630. /**
  32631. * Sets the easing function of the animation
  32632. * @param easingFunction A custom mathematical formula for animation
  32633. */
  32634. setEasingFunction(easingFunction: EasingFunction): void;
  32635. /**
  32636. * Interpolates a scalar linearly
  32637. * @param startValue Start value of the animation curve
  32638. * @param endValue End value of the animation curve
  32639. * @param gradient Scalar amount to interpolate
  32640. * @returns Interpolated scalar value
  32641. */
  32642. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32643. /**
  32644. * Interpolates a scalar cubically
  32645. * @param startValue Start value of the animation curve
  32646. * @param outTangent End tangent of the animation
  32647. * @param endValue End value of the animation curve
  32648. * @param inTangent Start tangent of the animation curve
  32649. * @param gradient Scalar amount to interpolate
  32650. * @returns Interpolated scalar value
  32651. */
  32652. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32653. /**
  32654. * Interpolates a quaternion using a spherical linear interpolation
  32655. * @param startValue Start value of the animation curve
  32656. * @param endValue End value of the animation curve
  32657. * @param gradient Scalar amount to interpolate
  32658. * @returns Interpolated quaternion value
  32659. */
  32660. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32661. /**
  32662. * Interpolates a quaternion cubically
  32663. * @param startValue Start value of the animation curve
  32664. * @param outTangent End tangent of the animation curve
  32665. * @param endValue End value of the animation curve
  32666. * @param inTangent Start tangent of the animation curve
  32667. * @param gradient Scalar amount to interpolate
  32668. * @returns Interpolated quaternion value
  32669. */
  32670. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32671. /**
  32672. * Interpolates a Vector3 linearl
  32673. * @param startValue Start value of the animation curve
  32674. * @param endValue End value of the animation curve
  32675. * @param gradient Scalar amount to interpolate
  32676. * @returns Interpolated scalar value
  32677. */
  32678. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32679. /**
  32680. * Interpolates a Vector3 cubically
  32681. * @param startValue Start value of the animation curve
  32682. * @param outTangent End tangent of the animation
  32683. * @param endValue End value of the animation curve
  32684. * @param inTangent Start tangent of the animation curve
  32685. * @param gradient Scalar amount to interpolate
  32686. * @returns InterpolatedVector3 value
  32687. */
  32688. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32689. /**
  32690. * Interpolates a Vector2 linearly
  32691. * @param startValue Start value of the animation curve
  32692. * @param endValue End value of the animation curve
  32693. * @param gradient Scalar amount to interpolate
  32694. * @returns Interpolated Vector2 value
  32695. */
  32696. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32697. /**
  32698. * Interpolates a Vector2 cubically
  32699. * @param startValue Start value of the animation curve
  32700. * @param outTangent End tangent of the animation
  32701. * @param endValue End value of the animation curve
  32702. * @param inTangent Start tangent of the animation curve
  32703. * @param gradient Scalar amount to interpolate
  32704. * @returns Interpolated Vector2 value
  32705. */
  32706. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32707. /**
  32708. * Interpolates a size linearly
  32709. * @param startValue Start value of the animation curve
  32710. * @param endValue End value of the animation curve
  32711. * @param gradient Scalar amount to interpolate
  32712. * @returns Interpolated Size value
  32713. */
  32714. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32715. /**
  32716. * Interpolates a Color3 linearly
  32717. * @param startValue Start value of the animation curve
  32718. * @param endValue End value of the animation curve
  32719. * @param gradient Scalar amount to interpolate
  32720. * @returns Interpolated Color3 value
  32721. */
  32722. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32723. /**
  32724. * Interpolates a Color4 linearly
  32725. * @param startValue Start value of the animation curve
  32726. * @param endValue End value of the animation curve
  32727. * @param gradient Scalar amount to interpolate
  32728. * @returns Interpolated Color3 value
  32729. */
  32730. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32731. /**
  32732. * @hidden Internal use only
  32733. */
  32734. _getKeyValue(value: any): any;
  32735. /**
  32736. * @hidden Internal use only
  32737. */
  32738. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32739. /**
  32740. * Defines the function to use to interpolate matrices
  32741. * @param startValue defines the start matrix
  32742. * @param endValue defines the end matrix
  32743. * @param gradient defines the gradient between both matrices
  32744. * @param result defines an optional target matrix where to store the interpolation
  32745. * @returns the interpolated matrix
  32746. */
  32747. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32748. /**
  32749. * Makes a copy of the animation
  32750. * @returns Cloned animation
  32751. */
  32752. clone(): Animation;
  32753. /**
  32754. * Sets the key frames of the animation
  32755. * @param values The animation key frames to set
  32756. */
  32757. setKeys(values: Array<IAnimationKey>): void;
  32758. /**
  32759. * Serializes the animation to an object
  32760. * @returns Serialized object
  32761. */
  32762. serialize(): any;
  32763. /**
  32764. * Float animation type
  32765. */
  32766. static readonly ANIMATIONTYPE_FLOAT: number;
  32767. /**
  32768. * Vector3 animation type
  32769. */
  32770. static readonly ANIMATIONTYPE_VECTOR3: number;
  32771. /**
  32772. * Quaternion animation type
  32773. */
  32774. static readonly ANIMATIONTYPE_QUATERNION: number;
  32775. /**
  32776. * Matrix animation type
  32777. */
  32778. static readonly ANIMATIONTYPE_MATRIX: number;
  32779. /**
  32780. * Color3 animation type
  32781. */
  32782. static readonly ANIMATIONTYPE_COLOR3: number;
  32783. /**
  32784. * Color3 animation type
  32785. */
  32786. static readonly ANIMATIONTYPE_COLOR4: number;
  32787. /**
  32788. * Vector2 animation type
  32789. */
  32790. static readonly ANIMATIONTYPE_VECTOR2: number;
  32791. /**
  32792. * Size animation type
  32793. */
  32794. static readonly ANIMATIONTYPE_SIZE: number;
  32795. /**
  32796. * Relative Loop Mode
  32797. */
  32798. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32799. /**
  32800. * Cycle Loop Mode
  32801. */
  32802. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32803. /**
  32804. * Constant Loop Mode
  32805. */
  32806. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32807. /** @hidden */
  32808. static _UniversalLerp(left: any, right: any, amount: number): any;
  32809. /**
  32810. * Parses an animation object and creates an animation
  32811. * @param parsedAnimation Parsed animation object
  32812. * @returns Animation object
  32813. */
  32814. static Parse(parsedAnimation: any): Animation;
  32815. /**
  32816. * Appends the serialized animations from the source animations
  32817. * @param source Source containing the animations
  32818. * @param destination Target to store the animations
  32819. */
  32820. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32821. /**
  32822. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32823. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32824. * @param url defines the url to load from
  32825. * @returns a promise that will resolve to the new animation or an array of animations
  32826. */
  32827. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32828. /**
  32829. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32830. * @param snippetId defines the snippet to load
  32831. * @returns a promise that will resolve to the new animation or a new array of animations
  32832. */
  32833. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32834. }
  32835. }
  32836. declare module BABYLON {
  32837. /**
  32838. * Interface containing an array of animations
  32839. */
  32840. export interface IAnimatable {
  32841. /**
  32842. * Array of animations
  32843. */
  32844. animations: Nullable<Array<Animation>>;
  32845. }
  32846. }
  32847. declare module BABYLON {
  32848. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32849. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32850. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32851. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32852. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32853. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32854. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32855. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32856. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32857. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32858. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32859. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32860. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32861. /**
  32862. * Decorator used to define property that can be serialized as reference to a camera
  32863. * @param sourceName defines the name of the property to decorate
  32864. */
  32865. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32866. /**
  32867. * Class used to help serialization objects
  32868. */
  32869. export class SerializationHelper {
  32870. /** @hidden */
  32871. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32872. /** @hidden */
  32873. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32874. /** @hidden */
  32875. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32876. /** @hidden */
  32877. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32878. /**
  32879. * Appends the serialized animations from the source animations
  32880. * @param source Source containing the animations
  32881. * @param destination Target to store the animations
  32882. */
  32883. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32884. /**
  32885. * Static function used to serialized a specific entity
  32886. * @param entity defines the entity to serialize
  32887. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32888. * @returns a JSON compatible object representing the serialization of the entity
  32889. */
  32890. static Serialize<T>(entity: T, serializationObject?: any): any;
  32891. /**
  32892. * Creates a new entity from a serialization data object
  32893. * @param creationFunction defines a function used to instanciated the new entity
  32894. * @param source defines the source serialization data
  32895. * @param scene defines the hosting scene
  32896. * @param rootUrl defines the root url for resources
  32897. * @returns a new entity
  32898. */
  32899. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32900. /**
  32901. * Clones an object
  32902. * @param creationFunction defines the function used to instanciate the new object
  32903. * @param source defines the source object
  32904. * @returns the cloned object
  32905. */
  32906. static Clone<T>(creationFunction: () => T, source: T): T;
  32907. /**
  32908. * Instanciates a new object based on a source one (some data will be shared between both object)
  32909. * @param creationFunction defines the function used to instanciate the new object
  32910. * @param source defines the source object
  32911. * @returns the new object
  32912. */
  32913. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32914. }
  32915. }
  32916. declare module BABYLON {
  32917. /**
  32918. * Base class of all the textures in babylon.
  32919. * It groups all the common properties the materials, post process, lights... might need
  32920. * in order to make a correct use of the texture.
  32921. */
  32922. export class BaseTexture implements IAnimatable {
  32923. /**
  32924. * Default anisotropic filtering level for the application.
  32925. * It is set to 4 as a good tradeoff between perf and quality.
  32926. */
  32927. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32928. /**
  32929. * Gets or sets the unique id of the texture
  32930. */
  32931. uniqueId: number;
  32932. /**
  32933. * Define the name of the texture.
  32934. */
  32935. name: string;
  32936. /**
  32937. * Gets or sets an object used to store user defined information.
  32938. */
  32939. metadata: any;
  32940. /**
  32941. * For internal use only. Please do not use.
  32942. */
  32943. reservedDataStore: any;
  32944. private _hasAlpha;
  32945. /**
  32946. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32947. */
  32948. set hasAlpha(value: boolean);
  32949. get hasAlpha(): boolean;
  32950. /**
  32951. * Defines if the alpha value should be determined via the rgb values.
  32952. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32953. */
  32954. getAlphaFromRGB: boolean;
  32955. /**
  32956. * Intensity or strength of the texture.
  32957. * It is commonly used by materials to fine tune the intensity of the texture
  32958. */
  32959. level: number;
  32960. /**
  32961. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32962. * This is part of the texture as textures usually maps to one uv set.
  32963. */
  32964. coordinatesIndex: number;
  32965. private _coordinatesMode;
  32966. /**
  32967. * How a texture is mapped.
  32968. *
  32969. * | Value | Type | Description |
  32970. * | ----- | ----------------------------------- | ----------- |
  32971. * | 0 | EXPLICIT_MODE | |
  32972. * | 1 | SPHERICAL_MODE | |
  32973. * | 2 | PLANAR_MODE | |
  32974. * | 3 | CUBIC_MODE | |
  32975. * | 4 | PROJECTION_MODE | |
  32976. * | 5 | SKYBOX_MODE | |
  32977. * | 6 | INVCUBIC_MODE | |
  32978. * | 7 | EQUIRECTANGULAR_MODE | |
  32979. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32980. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32981. */
  32982. set coordinatesMode(value: number);
  32983. get coordinatesMode(): number;
  32984. /**
  32985. * | Value | Type | Description |
  32986. * | ----- | ------------------ | ----------- |
  32987. * | 0 | CLAMP_ADDRESSMODE | |
  32988. * | 1 | WRAP_ADDRESSMODE | |
  32989. * | 2 | MIRROR_ADDRESSMODE | |
  32990. */
  32991. wrapU: number;
  32992. /**
  32993. * | Value | Type | Description |
  32994. * | ----- | ------------------ | ----------- |
  32995. * | 0 | CLAMP_ADDRESSMODE | |
  32996. * | 1 | WRAP_ADDRESSMODE | |
  32997. * | 2 | MIRROR_ADDRESSMODE | |
  32998. */
  32999. wrapV: number;
  33000. /**
  33001. * | Value | Type | Description |
  33002. * | ----- | ------------------ | ----------- |
  33003. * | 0 | CLAMP_ADDRESSMODE | |
  33004. * | 1 | WRAP_ADDRESSMODE | |
  33005. * | 2 | MIRROR_ADDRESSMODE | |
  33006. */
  33007. wrapR: number;
  33008. /**
  33009. * With compliant hardware and browser (supporting anisotropic filtering)
  33010. * this defines the level of anisotropic filtering in the texture.
  33011. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33012. */
  33013. anisotropicFilteringLevel: number;
  33014. /**
  33015. * Define if the texture is a cube texture or if false a 2d texture.
  33016. */
  33017. get isCube(): boolean;
  33018. set isCube(value: boolean);
  33019. /**
  33020. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33021. */
  33022. get is3D(): boolean;
  33023. set is3D(value: boolean);
  33024. /**
  33025. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33026. */
  33027. get is2DArray(): boolean;
  33028. set is2DArray(value: boolean);
  33029. /**
  33030. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33031. * HDR texture are usually stored in linear space.
  33032. * This only impacts the PBR and Background materials
  33033. */
  33034. gammaSpace: boolean;
  33035. /**
  33036. * Gets or sets whether or not the texture contains RGBD data.
  33037. */
  33038. get isRGBD(): boolean;
  33039. set isRGBD(value: boolean);
  33040. /**
  33041. * Is Z inverted in the texture (useful in a cube texture).
  33042. */
  33043. invertZ: boolean;
  33044. /**
  33045. * Are mip maps generated for this texture or not.
  33046. */
  33047. get noMipmap(): boolean;
  33048. /**
  33049. * @hidden
  33050. */
  33051. lodLevelInAlpha: boolean;
  33052. /**
  33053. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33054. */
  33055. get lodGenerationOffset(): number;
  33056. set lodGenerationOffset(value: number);
  33057. /**
  33058. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33059. */
  33060. get lodGenerationScale(): number;
  33061. set lodGenerationScale(value: number);
  33062. /**
  33063. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33064. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33065. * average roughness values.
  33066. */
  33067. get linearSpecularLOD(): boolean;
  33068. set linearSpecularLOD(value: boolean);
  33069. /**
  33070. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33071. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33072. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33073. */
  33074. get irradianceTexture(): Nullable<BaseTexture>;
  33075. set irradianceTexture(value: Nullable<BaseTexture>);
  33076. /**
  33077. * Define if the texture is a render target.
  33078. */
  33079. isRenderTarget: boolean;
  33080. /**
  33081. * Define the unique id of the texture in the scene.
  33082. */
  33083. get uid(): string;
  33084. /** @hidden */
  33085. _prefiltered: boolean;
  33086. /**
  33087. * Return a string representation of the texture.
  33088. * @returns the texture as a string
  33089. */
  33090. toString(): string;
  33091. /**
  33092. * Get the class name of the texture.
  33093. * @returns "BaseTexture"
  33094. */
  33095. getClassName(): string;
  33096. /**
  33097. * Define the list of animation attached to the texture.
  33098. */
  33099. animations: Animation[];
  33100. /**
  33101. * An event triggered when the texture is disposed.
  33102. */
  33103. onDisposeObservable: Observable<BaseTexture>;
  33104. private _onDisposeObserver;
  33105. /**
  33106. * Callback triggered when the texture has been disposed.
  33107. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33108. */
  33109. set onDispose(callback: () => void);
  33110. /**
  33111. * Define the current state of the loading sequence when in delayed load mode.
  33112. */
  33113. delayLoadState: number;
  33114. private _scene;
  33115. private _engine;
  33116. /** @hidden */
  33117. _texture: Nullable<InternalTexture>;
  33118. private _uid;
  33119. /**
  33120. * Define if the texture is preventinga material to render or not.
  33121. * If not and the texture is not ready, the engine will use a default black texture instead.
  33122. */
  33123. get isBlocking(): boolean;
  33124. /**
  33125. * Instantiates a new BaseTexture.
  33126. * Base class of all the textures in babylon.
  33127. * It groups all the common properties the materials, post process, lights... might need
  33128. * in order to make a correct use of the texture.
  33129. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33130. */
  33131. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33132. /**
  33133. * Get the scene the texture belongs to.
  33134. * @returns the scene or null if undefined
  33135. */
  33136. getScene(): Nullable<Scene>;
  33137. /** @hidden */
  33138. protected _getEngine(): Nullable<ThinEngine>;
  33139. /**
  33140. * Get the texture transform matrix used to offset tile the texture for istance.
  33141. * @returns the transformation matrix
  33142. */
  33143. getTextureMatrix(): Matrix;
  33144. /**
  33145. * Get the texture reflection matrix used to rotate/transform the reflection.
  33146. * @returns the reflection matrix
  33147. */
  33148. getReflectionTextureMatrix(): Matrix;
  33149. /**
  33150. * Get the underlying lower level texture from Babylon.
  33151. * @returns the insternal texture
  33152. */
  33153. getInternalTexture(): Nullable<InternalTexture>;
  33154. /**
  33155. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33156. * @returns true if ready or not blocking
  33157. */
  33158. isReadyOrNotBlocking(): boolean;
  33159. /**
  33160. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33161. * @returns true if fully ready
  33162. */
  33163. isReady(): boolean;
  33164. private _cachedSize;
  33165. /**
  33166. * Get the size of the texture.
  33167. * @returns the texture size.
  33168. */
  33169. getSize(): ISize;
  33170. /**
  33171. * Get the base size of the texture.
  33172. * It can be different from the size if the texture has been resized for POT for instance
  33173. * @returns the base size
  33174. */
  33175. getBaseSize(): ISize;
  33176. /**
  33177. * Update the sampling mode of the texture.
  33178. * Default is Trilinear mode.
  33179. *
  33180. * | Value | Type | Description |
  33181. * | ----- | ------------------ | ----------- |
  33182. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33183. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33184. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33185. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33186. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33187. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33188. * | 7 | NEAREST_LINEAR | |
  33189. * | 8 | NEAREST_NEAREST | |
  33190. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33191. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33192. * | 11 | LINEAR_LINEAR | |
  33193. * | 12 | LINEAR_NEAREST | |
  33194. *
  33195. * > _mag_: magnification filter (close to the viewer)
  33196. * > _min_: minification filter (far from the viewer)
  33197. * > _mip_: filter used between mip map levels
  33198. *@param samplingMode Define the new sampling mode of the texture
  33199. */
  33200. updateSamplingMode(samplingMode: number): void;
  33201. /**
  33202. * Scales the texture if is `canRescale()`
  33203. * @param ratio the resize factor we want to use to rescale
  33204. */
  33205. scale(ratio: number): void;
  33206. /**
  33207. * Get if the texture can rescale.
  33208. */
  33209. get canRescale(): boolean;
  33210. /** @hidden */
  33211. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33212. /** @hidden */
  33213. _rebuild(): void;
  33214. /**
  33215. * Triggers the load sequence in delayed load mode.
  33216. */
  33217. delayLoad(): void;
  33218. /**
  33219. * Clones the texture.
  33220. * @returns the cloned texture
  33221. */
  33222. clone(): Nullable<BaseTexture>;
  33223. /**
  33224. * Get the texture underlying type (INT, FLOAT...)
  33225. */
  33226. get textureType(): number;
  33227. /**
  33228. * Get the texture underlying format (RGB, RGBA...)
  33229. */
  33230. get textureFormat(): number;
  33231. /**
  33232. * Indicates that textures need to be re-calculated for all materials
  33233. */
  33234. protected _markAllSubMeshesAsTexturesDirty(): void;
  33235. /**
  33236. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33237. * This will returns an RGBA array buffer containing either in values (0-255) or
  33238. * float values (0-1) depending of the underlying buffer type.
  33239. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33240. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33241. * @param buffer defines a user defined buffer to fill with data (can be null)
  33242. * @returns The Array buffer containing the pixels data.
  33243. */
  33244. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33245. /**
  33246. * Release and destroy the underlying lower level texture aka internalTexture.
  33247. */
  33248. releaseInternalTexture(): void;
  33249. /** @hidden */
  33250. get _lodTextureHigh(): Nullable<BaseTexture>;
  33251. /** @hidden */
  33252. get _lodTextureMid(): Nullable<BaseTexture>;
  33253. /** @hidden */
  33254. get _lodTextureLow(): Nullable<BaseTexture>;
  33255. /**
  33256. * Dispose the texture and release its associated resources.
  33257. */
  33258. dispose(): void;
  33259. /**
  33260. * Serialize the texture into a JSON representation that can be parsed later on.
  33261. * @returns the JSON representation of the texture
  33262. */
  33263. serialize(): any;
  33264. /**
  33265. * Helper function to be called back once a list of texture contains only ready textures.
  33266. * @param textures Define the list of textures to wait for
  33267. * @param callback Define the callback triggered once the entire list will be ready
  33268. */
  33269. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33270. private static _isScene;
  33271. }
  33272. }
  33273. declare module BABYLON {
  33274. /**
  33275. * Options to be used when creating an effect.
  33276. */
  33277. export interface IEffectCreationOptions {
  33278. /**
  33279. * Atrributes that will be used in the shader.
  33280. */
  33281. attributes: string[];
  33282. /**
  33283. * Uniform varible names that will be set in the shader.
  33284. */
  33285. uniformsNames: string[];
  33286. /**
  33287. * Uniform buffer variable names that will be set in the shader.
  33288. */
  33289. uniformBuffersNames: string[];
  33290. /**
  33291. * Sampler texture variable names that will be set in the shader.
  33292. */
  33293. samplers: string[];
  33294. /**
  33295. * Define statements that will be set in the shader.
  33296. */
  33297. defines: any;
  33298. /**
  33299. * Possible fallbacks for this effect to improve performance when needed.
  33300. */
  33301. fallbacks: Nullable<IEffectFallbacks>;
  33302. /**
  33303. * Callback that will be called when the shader is compiled.
  33304. */
  33305. onCompiled: Nullable<(effect: Effect) => void>;
  33306. /**
  33307. * Callback that will be called if an error occurs during shader compilation.
  33308. */
  33309. onError: Nullable<(effect: Effect, errors: string) => void>;
  33310. /**
  33311. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33312. */
  33313. indexParameters?: any;
  33314. /**
  33315. * Max number of lights that can be used in the shader.
  33316. */
  33317. maxSimultaneousLights?: number;
  33318. /**
  33319. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33320. */
  33321. transformFeedbackVaryings?: Nullable<string[]>;
  33322. /**
  33323. * 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
  33324. */
  33325. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33326. }
  33327. /**
  33328. * Effect containing vertex and fragment shader that can be executed on an object.
  33329. */
  33330. export class Effect implements IDisposable {
  33331. /**
  33332. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33333. */
  33334. static ShadersRepository: string;
  33335. /**
  33336. * Enable logging of the shader code when a compilation error occurs
  33337. */
  33338. static LogShaderCodeOnCompilationError: boolean;
  33339. /**
  33340. * Name of the effect.
  33341. */
  33342. name: any;
  33343. /**
  33344. * String container all the define statements that should be set on the shader.
  33345. */
  33346. defines: string;
  33347. /**
  33348. * Callback that will be called when the shader is compiled.
  33349. */
  33350. onCompiled: Nullable<(effect: Effect) => void>;
  33351. /**
  33352. * Callback that will be called if an error occurs during shader compilation.
  33353. */
  33354. onError: Nullable<(effect: Effect, errors: string) => void>;
  33355. /**
  33356. * Callback that will be called when effect is bound.
  33357. */
  33358. onBind: Nullable<(effect: Effect) => void>;
  33359. /**
  33360. * Unique ID of the effect.
  33361. */
  33362. uniqueId: number;
  33363. /**
  33364. * Observable that will be called when the shader is compiled.
  33365. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33366. */
  33367. onCompileObservable: Observable<Effect>;
  33368. /**
  33369. * Observable that will be called if an error occurs during shader compilation.
  33370. */
  33371. onErrorObservable: Observable<Effect>;
  33372. /** @hidden */
  33373. _onBindObservable: Nullable<Observable<Effect>>;
  33374. /**
  33375. * @hidden
  33376. * Specifies if the effect was previously ready
  33377. */
  33378. _wasPreviouslyReady: boolean;
  33379. /**
  33380. * Observable that will be called when effect is bound.
  33381. */
  33382. get onBindObservable(): Observable<Effect>;
  33383. /** @hidden */
  33384. _bonesComputationForcedToCPU: boolean;
  33385. private static _uniqueIdSeed;
  33386. private _engine;
  33387. private _uniformBuffersNames;
  33388. private _uniformBuffersNamesList;
  33389. private _uniformsNames;
  33390. private _samplerList;
  33391. private _samplers;
  33392. private _isReady;
  33393. private _compilationError;
  33394. private _allFallbacksProcessed;
  33395. private _attributesNames;
  33396. private _attributes;
  33397. private _attributeLocationByName;
  33398. private _uniforms;
  33399. /**
  33400. * Key for the effect.
  33401. * @hidden
  33402. */
  33403. _key: string;
  33404. private _indexParameters;
  33405. private _fallbacks;
  33406. private _vertexSourceCode;
  33407. private _fragmentSourceCode;
  33408. private _vertexSourceCodeOverride;
  33409. private _fragmentSourceCodeOverride;
  33410. private _transformFeedbackVaryings;
  33411. /**
  33412. * Compiled shader to webGL program.
  33413. * @hidden
  33414. */
  33415. _pipelineContext: Nullable<IPipelineContext>;
  33416. private _valueCache;
  33417. private static _baseCache;
  33418. /**
  33419. * Instantiates an effect.
  33420. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33421. * @param baseName Name of the effect.
  33422. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33423. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33424. * @param samplers List of sampler variables that will be passed to the shader.
  33425. * @param engine Engine to be used to render the effect
  33426. * @param defines Define statements to be added to the shader.
  33427. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33428. * @param onCompiled Callback that will be called when the shader is compiled.
  33429. * @param onError Callback that will be called if an error occurs during shader compilation.
  33430. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33431. */
  33432. 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);
  33433. private _useFinalCode;
  33434. /**
  33435. * Unique key for this effect
  33436. */
  33437. get key(): string;
  33438. /**
  33439. * If the effect has been compiled and prepared.
  33440. * @returns if the effect is compiled and prepared.
  33441. */
  33442. isReady(): boolean;
  33443. private _isReadyInternal;
  33444. /**
  33445. * The engine the effect was initialized with.
  33446. * @returns the engine.
  33447. */
  33448. getEngine(): Engine;
  33449. /**
  33450. * The pipeline context for this effect
  33451. * @returns the associated pipeline context
  33452. */
  33453. getPipelineContext(): Nullable<IPipelineContext>;
  33454. /**
  33455. * The set of names of attribute variables for the shader.
  33456. * @returns An array of attribute names.
  33457. */
  33458. getAttributesNames(): string[];
  33459. /**
  33460. * Returns the attribute at the given index.
  33461. * @param index The index of the attribute.
  33462. * @returns The location of the attribute.
  33463. */
  33464. getAttributeLocation(index: number): number;
  33465. /**
  33466. * Returns the attribute based on the name of the variable.
  33467. * @param name of the attribute to look up.
  33468. * @returns the attribute location.
  33469. */
  33470. getAttributeLocationByName(name: string): number;
  33471. /**
  33472. * The number of attributes.
  33473. * @returns the numnber of attributes.
  33474. */
  33475. getAttributesCount(): number;
  33476. /**
  33477. * Gets the index of a uniform variable.
  33478. * @param uniformName of the uniform to look up.
  33479. * @returns the index.
  33480. */
  33481. getUniformIndex(uniformName: string): number;
  33482. /**
  33483. * Returns the attribute based on the name of the variable.
  33484. * @param uniformName of the uniform to look up.
  33485. * @returns the location of the uniform.
  33486. */
  33487. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33488. /**
  33489. * Returns an array of sampler variable names
  33490. * @returns The array of sampler variable names.
  33491. */
  33492. getSamplers(): string[];
  33493. /**
  33494. * Returns an array of uniform variable names
  33495. * @returns The array of uniform variable names.
  33496. */
  33497. getUniformNames(): string[];
  33498. /**
  33499. * Returns an array of uniform buffer variable names
  33500. * @returns The array of uniform buffer variable names.
  33501. */
  33502. getUniformBuffersNames(): string[];
  33503. /**
  33504. * Returns the index parameters used to create the effect
  33505. * @returns The index parameters object
  33506. */
  33507. getIndexParameters(): any;
  33508. /**
  33509. * The error from the last compilation.
  33510. * @returns the error string.
  33511. */
  33512. getCompilationError(): string;
  33513. /**
  33514. * Gets a boolean indicating that all fallbacks were used during compilation
  33515. * @returns true if all fallbacks were used
  33516. */
  33517. allFallbacksProcessed(): boolean;
  33518. /**
  33519. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33520. * @param func The callback to be used.
  33521. */
  33522. executeWhenCompiled(func: (effect: Effect) => void): void;
  33523. private _checkIsReady;
  33524. private _loadShader;
  33525. /**
  33526. * Gets the vertex shader source code of this effect
  33527. */
  33528. get vertexSourceCode(): string;
  33529. /**
  33530. * Gets the fragment shader source code of this effect
  33531. */
  33532. get fragmentSourceCode(): string;
  33533. /**
  33534. * Recompiles the webGL program
  33535. * @param vertexSourceCode The source code for the vertex shader.
  33536. * @param fragmentSourceCode The source code for the fragment shader.
  33537. * @param onCompiled Callback called when completed.
  33538. * @param onError Callback called on error.
  33539. * @hidden
  33540. */
  33541. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33542. /**
  33543. * Prepares the effect
  33544. * @hidden
  33545. */
  33546. _prepareEffect(): void;
  33547. private _getShaderCodeAndErrorLine;
  33548. private _processCompilationErrors;
  33549. /**
  33550. * Checks if the effect is supported. (Must be called after compilation)
  33551. */
  33552. get isSupported(): boolean;
  33553. /**
  33554. * Binds a texture to the engine to be used as output of the shader.
  33555. * @param channel Name of the output variable.
  33556. * @param texture Texture to bind.
  33557. * @hidden
  33558. */
  33559. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33560. /**
  33561. * Sets a texture on the engine to be used in the shader.
  33562. * @param channel Name of the sampler variable.
  33563. * @param texture Texture to set.
  33564. */
  33565. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33566. /**
  33567. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33568. * @param channel Name of the sampler variable.
  33569. * @param texture Texture to set.
  33570. */
  33571. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33572. /**
  33573. * Sets an array of textures on the engine to be used in the shader.
  33574. * @param channel Name of the variable.
  33575. * @param textures Textures to set.
  33576. */
  33577. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33578. /**
  33579. * 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)
  33580. * @param channel Name of the sampler variable.
  33581. * @param postProcess Post process to get the input texture from.
  33582. */
  33583. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33584. /**
  33585. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33586. * 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)
  33587. * @param channel Name of the sampler variable.
  33588. * @param postProcess Post process to get the output texture from.
  33589. */
  33590. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33591. /** @hidden */
  33592. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33593. /** @hidden */
  33594. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33595. /** @hidden */
  33596. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33597. /** @hidden */
  33598. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33599. /**
  33600. * Binds a buffer to a uniform.
  33601. * @param buffer Buffer to bind.
  33602. * @param name Name of the uniform variable to bind to.
  33603. */
  33604. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33605. /**
  33606. * Binds block to a uniform.
  33607. * @param blockName Name of the block to bind.
  33608. * @param index Index to bind.
  33609. */
  33610. bindUniformBlock(blockName: string, index: number): void;
  33611. /**
  33612. * Sets an interger value on a uniform variable.
  33613. * @param uniformName Name of the variable.
  33614. * @param value Value to be set.
  33615. * @returns this effect.
  33616. */
  33617. setInt(uniformName: string, value: number): Effect;
  33618. /**
  33619. * Sets an int array on a uniform variable.
  33620. * @param uniformName Name of the variable.
  33621. * @param array array to be set.
  33622. * @returns this effect.
  33623. */
  33624. setIntArray(uniformName: string, array: Int32Array): Effect;
  33625. /**
  33626. * 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)
  33627. * @param uniformName Name of the variable.
  33628. * @param array array to be set.
  33629. * @returns this effect.
  33630. */
  33631. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33632. /**
  33633. * 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)
  33634. * @param uniformName Name of the variable.
  33635. * @param array array to be set.
  33636. * @returns this effect.
  33637. */
  33638. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33639. /**
  33640. * 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)
  33641. * @param uniformName Name of the variable.
  33642. * @param array array to be set.
  33643. * @returns this effect.
  33644. */
  33645. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33646. /**
  33647. * Sets an float array on a uniform variable.
  33648. * @param uniformName Name of the variable.
  33649. * @param array array to be set.
  33650. * @returns this effect.
  33651. */
  33652. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33653. /**
  33654. * 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)
  33655. * @param uniformName Name of the variable.
  33656. * @param array array to be set.
  33657. * @returns this effect.
  33658. */
  33659. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33660. /**
  33661. * 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)
  33662. * @param uniformName Name of the variable.
  33663. * @param array array to be set.
  33664. * @returns this effect.
  33665. */
  33666. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33667. /**
  33668. * 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)
  33669. * @param uniformName Name of the variable.
  33670. * @param array array to be set.
  33671. * @returns this effect.
  33672. */
  33673. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33674. /**
  33675. * Sets an array on a uniform variable.
  33676. * @param uniformName Name of the variable.
  33677. * @param array array to be set.
  33678. * @returns this effect.
  33679. */
  33680. setArray(uniformName: string, array: number[]): Effect;
  33681. /**
  33682. * 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)
  33683. * @param uniformName Name of the variable.
  33684. * @param array array to be set.
  33685. * @returns this effect.
  33686. */
  33687. setArray2(uniformName: string, array: number[]): Effect;
  33688. /**
  33689. * 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)
  33690. * @param uniformName Name of the variable.
  33691. * @param array array to be set.
  33692. * @returns this effect.
  33693. */
  33694. setArray3(uniformName: string, array: number[]): Effect;
  33695. /**
  33696. * 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)
  33697. * @param uniformName Name of the variable.
  33698. * @param array array to be set.
  33699. * @returns this effect.
  33700. */
  33701. setArray4(uniformName: string, array: number[]): Effect;
  33702. /**
  33703. * Sets matrices on a uniform variable.
  33704. * @param uniformName Name of the variable.
  33705. * @param matrices matrices to be set.
  33706. * @returns this effect.
  33707. */
  33708. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33709. /**
  33710. * Sets matrix on a uniform variable.
  33711. * @param uniformName Name of the variable.
  33712. * @param matrix matrix to be set.
  33713. * @returns this effect.
  33714. */
  33715. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33716. /**
  33717. * 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)
  33718. * @param uniformName Name of the variable.
  33719. * @param matrix matrix to be set.
  33720. * @returns this effect.
  33721. */
  33722. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33723. /**
  33724. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33725. * @param uniformName Name of the variable.
  33726. * @param matrix matrix to be set.
  33727. * @returns this effect.
  33728. */
  33729. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33730. /**
  33731. * Sets a float on a uniform variable.
  33732. * @param uniformName Name of the variable.
  33733. * @param value value to be set.
  33734. * @returns this effect.
  33735. */
  33736. setFloat(uniformName: string, value: number): Effect;
  33737. /**
  33738. * Sets a boolean on a uniform variable.
  33739. * @param uniformName Name of the variable.
  33740. * @param bool value to be set.
  33741. * @returns this effect.
  33742. */
  33743. setBool(uniformName: string, bool: boolean): Effect;
  33744. /**
  33745. * Sets a Vector2 on a uniform variable.
  33746. * @param uniformName Name of the variable.
  33747. * @param vector2 vector2 to be set.
  33748. * @returns this effect.
  33749. */
  33750. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33751. /**
  33752. * Sets a float2 on a uniform variable.
  33753. * @param uniformName Name of the variable.
  33754. * @param x First float in float2.
  33755. * @param y Second float in float2.
  33756. * @returns this effect.
  33757. */
  33758. setFloat2(uniformName: string, x: number, y: number): Effect;
  33759. /**
  33760. * Sets a Vector3 on a uniform variable.
  33761. * @param uniformName Name of the variable.
  33762. * @param vector3 Value to be set.
  33763. * @returns this effect.
  33764. */
  33765. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33766. /**
  33767. * Sets a float3 on a uniform variable.
  33768. * @param uniformName Name of the variable.
  33769. * @param x First float in float3.
  33770. * @param y Second float in float3.
  33771. * @param z Third float in float3.
  33772. * @returns this effect.
  33773. */
  33774. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33775. /**
  33776. * Sets a Vector4 on a uniform variable.
  33777. * @param uniformName Name of the variable.
  33778. * @param vector4 Value to be set.
  33779. * @returns this effect.
  33780. */
  33781. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33782. /**
  33783. * Sets a float4 on a uniform variable.
  33784. * @param uniformName Name of the variable.
  33785. * @param x First float in float4.
  33786. * @param y Second float in float4.
  33787. * @param z Third float in float4.
  33788. * @param w Fourth float in float4.
  33789. * @returns this effect.
  33790. */
  33791. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33792. /**
  33793. * Sets a Color3 on a uniform variable.
  33794. * @param uniformName Name of the variable.
  33795. * @param color3 Value to be set.
  33796. * @returns this effect.
  33797. */
  33798. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33799. /**
  33800. * Sets a Color4 on a uniform variable.
  33801. * @param uniformName Name of the variable.
  33802. * @param color3 Value to be set.
  33803. * @param alpha Alpha value to be set.
  33804. * @returns this effect.
  33805. */
  33806. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33807. /**
  33808. * Sets a Color4 on a uniform variable
  33809. * @param uniformName defines the name of the variable
  33810. * @param color4 defines the value to be set
  33811. * @returns this effect.
  33812. */
  33813. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33814. /** Release all associated resources */
  33815. dispose(): void;
  33816. /**
  33817. * This function will add a new shader to the shader store
  33818. * @param name the name of the shader
  33819. * @param pixelShader optional pixel shader content
  33820. * @param vertexShader optional vertex shader content
  33821. */
  33822. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33823. /**
  33824. * Store of each shader (The can be looked up using effect.key)
  33825. */
  33826. static ShadersStore: {
  33827. [key: string]: string;
  33828. };
  33829. /**
  33830. * Store of each included file for a shader (The can be looked up using effect.key)
  33831. */
  33832. static IncludesShadersStore: {
  33833. [key: string]: string;
  33834. };
  33835. /**
  33836. * Resets the cache of effects.
  33837. */
  33838. static ResetCache(): void;
  33839. }
  33840. }
  33841. declare module BABYLON {
  33842. /**
  33843. * Interface used to describe the capabilities of the engine relatively to the current browser
  33844. */
  33845. export interface EngineCapabilities {
  33846. /** Maximum textures units per fragment shader */
  33847. maxTexturesImageUnits: number;
  33848. /** Maximum texture units per vertex shader */
  33849. maxVertexTextureImageUnits: number;
  33850. /** Maximum textures units in the entire pipeline */
  33851. maxCombinedTexturesImageUnits: number;
  33852. /** Maximum texture size */
  33853. maxTextureSize: number;
  33854. /** Maximum texture samples */
  33855. maxSamples?: number;
  33856. /** Maximum cube texture size */
  33857. maxCubemapTextureSize: number;
  33858. /** Maximum render texture size */
  33859. maxRenderTextureSize: number;
  33860. /** Maximum number of vertex attributes */
  33861. maxVertexAttribs: number;
  33862. /** Maximum number of varyings */
  33863. maxVaryingVectors: number;
  33864. /** Maximum number of uniforms per vertex shader */
  33865. maxVertexUniformVectors: number;
  33866. /** Maximum number of uniforms per fragment shader */
  33867. maxFragmentUniformVectors: number;
  33868. /** Defines if standard derivates (dx/dy) are supported */
  33869. standardDerivatives: boolean;
  33870. /** Defines if s3tc texture compression is supported */
  33871. s3tc?: WEBGL_compressed_texture_s3tc;
  33872. /** Defines if pvrtc texture compression is supported */
  33873. pvrtc: any;
  33874. /** Defines if etc1 texture compression is supported */
  33875. etc1: any;
  33876. /** Defines if etc2 texture compression is supported */
  33877. etc2: any;
  33878. /** Defines if astc texture compression is supported */
  33879. astc: any;
  33880. /** Defines if float textures are supported */
  33881. textureFloat: boolean;
  33882. /** Defines if vertex array objects are supported */
  33883. vertexArrayObject: boolean;
  33884. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33885. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33886. /** Gets the maximum level of anisotropy supported */
  33887. maxAnisotropy: number;
  33888. /** Defines if instancing is supported */
  33889. instancedArrays: boolean;
  33890. /** Defines if 32 bits indices are supported */
  33891. uintIndices: boolean;
  33892. /** Defines if high precision shaders are supported */
  33893. highPrecisionShaderSupported: boolean;
  33894. /** Defines if depth reading in the fragment shader is supported */
  33895. fragmentDepthSupported: boolean;
  33896. /** Defines if float texture linear filtering is supported*/
  33897. textureFloatLinearFiltering: boolean;
  33898. /** Defines if rendering to float textures is supported */
  33899. textureFloatRender: boolean;
  33900. /** Defines if half float textures are supported*/
  33901. textureHalfFloat: boolean;
  33902. /** Defines if half float texture linear filtering is supported*/
  33903. textureHalfFloatLinearFiltering: boolean;
  33904. /** Defines if rendering to half float textures is supported */
  33905. textureHalfFloatRender: boolean;
  33906. /** Defines if textureLOD shader command is supported */
  33907. textureLOD: boolean;
  33908. /** Defines if draw buffers extension is supported */
  33909. drawBuffersExtension: boolean;
  33910. /** Defines if depth textures are supported */
  33911. depthTextureExtension: boolean;
  33912. /** Defines if float color buffer are supported */
  33913. colorBufferFloat: boolean;
  33914. /** Gets disjoint timer query extension (null if not supported) */
  33915. timerQuery?: EXT_disjoint_timer_query;
  33916. /** Defines if timestamp can be used with timer query */
  33917. canUseTimestampForTimerQuery: boolean;
  33918. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33919. multiview?: any;
  33920. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33921. oculusMultiview?: any;
  33922. /** Function used to let the system compiles shaders in background */
  33923. parallelShaderCompile?: {
  33924. COMPLETION_STATUS_KHR: number;
  33925. };
  33926. /** Max number of texture samples for MSAA */
  33927. maxMSAASamples: number;
  33928. /** Defines if the blend min max extension is supported */
  33929. blendMinMax: boolean;
  33930. }
  33931. }
  33932. declare module BABYLON {
  33933. /**
  33934. * @hidden
  33935. **/
  33936. export class DepthCullingState {
  33937. private _isDepthTestDirty;
  33938. private _isDepthMaskDirty;
  33939. private _isDepthFuncDirty;
  33940. private _isCullFaceDirty;
  33941. private _isCullDirty;
  33942. private _isZOffsetDirty;
  33943. private _isFrontFaceDirty;
  33944. private _depthTest;
  33945. private _depthMask;
  33946. private _depthFunc;
  33947. private _cull;
  33948. private _cullFace;
  33949. private _zOffset;
  33950. private _frontFace;
  33951. /**
  33952. * Initializes the state.
  33953. */
  33954. constructor();
  33955. get isDirty(): boolean;
  33956. get zOffset(): number;
  33957. set zOffset(value: number);
  33958. get cullFace(): Nullable<number>;
  33959. set cullFace(value: Nullable<number>);
  33960. get cull(): Nullable<boolean>;
  33961. set cull(value: Nullable<boolean>);
  33962. get depthFunc(): Nullable<number>;
  33963. set depthFunc(value: Nullable<number>);
  33964. get depthMask(): boolean;
  33965. set depthMask(value: boolean);
  33966. get depthTest(): boolean;
  33967. set depthTest(value: boolean);
  33968. get frontFace(): Nullable<number>;
  33969. set frontFace(value: Nullable<number>);
  33970. reset(): void;
  33971. apply(gl: WebGLRenderingContext): void;
  33972. }
  33973. }
  33974. declare module BABYLON {
  33975. /**
  33976. * @hidden
  33977. **/
  33978. export class StencilState {
  33979. /** 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 */
  33980. static readonly ALWAYS: number;
  33981. /** Passed to stencilOperation to specify that stencil value must be kept */
  33982. static readonly KEEP: number;
  33983. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33984. static readonly REPLACE: number;
  33985. private _isStencilTestDirty;
  33986. private _isStencilMaskDirty;
  33987. private _isStencilFuncDirty;
  33988. private _isStencilOpDirty;
  33989. private _stencilTest;
  33990. private _stencilMask;
  33991. private _stencilFunc;
  33992. private _stencilFuncRef;
  33993. private _stencilFuncMask;
  33994. private _stencilOpStencilFail;
  33995. private _stencilOpDepthFail;
  33996. private _stencilOpStencilDepthPass;
  33997. get isDirty(): boolean;
  33998. get stencilFunc(): number;
  33999. set stencilFunc(value: number);
  34000. get stencilFuncRef(): number;
  34001. set stencilFuncRef(value: number);
  34002. get stencilFuncMask(): number;
  34003. set stencilFuncMask(value: number);
  34004. get stencilOpStencilFail(): number;
  34005. set stencilOpStencilFail(value: number);
  34006. get stencilOpDepthFail(): number;
  34007. set stencilOpDepthFail(value: number);
  34008. get stencilOpStencilDepthPass(): number;
  34009. set stencilOpStencilDepthPass(value: number);
  34010. get stencilMask(): number;
  34011. set stencilMask(value: number);
  34012. get stencilTest(): boolean;
  34013. set stencilTest(value: boolean);
  34014. constructor();
  34015. reset(): void;
  34016. apply(gl: WebGLRenderingContext): void;
  34017. }
  34018. }
  34019. declare module BABYLON {
  34020. /**
  34021. * @hidden
  34022. **/
  34023. export class AlphaState {
  34024. private _isAlphaBlendDirty;
  34025. private _isBlendFunctionParametersDirty;
  34026. private _isBlendEquationParametersDirty;
  34027. private _isBlendConstantsDirty;
  34028. private _alphaBlend;
  34029. private _blendFunctionParameters;
  34030. private _blendEquationParameters;
  34031. private _blendConstants;
  34032. /**
  34033. * Initializes the state.
  34034. */
  34035. constructor();
  34036. get isDirty(): boolean;
  34037. get alphaBlend(): boolean;
  34038. set alphaBlend(value: boolean);
  34039. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34040. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34041. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34042. reset(): void;
  34043. apply(gl: WebGLRenderingContext): void;
  34044. }
  34045. }
  34046. declare module BABYLON {
  34047. /** @hidden */
  34048. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34049. attributeProcessor(attribute: string): string;
  34050. varyingProcessor(varying: string, isFragment: boolean): string;
  34051. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34052. }
  34053. }
  34054. declare module BABYLON {
  34055. /**
  34056. * Interface for attribute information associated with buffer instanciation
  34057. */
  34058. export interface InstancingAttributeInfo {
  34059. /**
  34060. * Name of the GLSL attribute
  34061. * if attribute index is not specified, this is used to retrieve the index from the effect
  34062. */
  34063. attributeName: string;
  34064. /**
  34065. * Index/offset of the attribute in the vertex shader
  34066. * if not specified, this will be computes from the name.
  34067. */
  34068. index?: number;
  34069. /**
  34070. * size of the attribute, 1, 2, 3 or 4
  34071. */
  34072. attributeSize: number;
  34073. /**
  34074. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34075. */
  34076. offset: number;
  34077. /**
  34078. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34079. * default to 1
  34080. */
  34081. divisor?: number;
  34082. /**
  34083. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34084. * default is FLOAT
  34085. */
  34086. attributeType?: number;
  34087. /**
  34088. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34089. */
  34090. normalized?: boolean;
  34091. }
  34092. }
  34093. declare module BABYLON {
  34094. interface ThinEngine {
  34095. /**
  34096. * Update a video texture
  34097. * @param texture defines the texture to update
  34098. * @param video defines the video element to use
  34099. * @param invertY defines if data must be stored with Y axis inverted
  34100. */
  34101. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34102. }
  34103. }
  34104. declare module BABYLON {
  34105. /**
  34106. * Settings for finer control over video usage
  34107. */
  34108. export interface VideoTextureSettings {
  34109. /**
  34110. * Applies `autoplay` to video, if specified
  34111. */
  34112. autoPlay?: boolean;
  34113. /**
  34114. * Applies `loop` to video, if specified
  34115. */
  34116. loop?: boolean;
  34117. /**
  34118. * Automatically updates internal texture from video at every frame in the render loop
  34119. */
  34120. autoUpdateTexture: boolean;
  34121. /**
  34122. * Image src displayed during the video loading or until the user interacts with the video.
  34123. */
  34124. poster?: string;
  34125. }
  34126. /**
  34127. * If you want to display a video in your scene, this is the special texture for that.
  34128. * This special texture works similar to other textures, with the exception of a few parameters.
  34129. * @see https://doc.babylonjs.com/how_to/video_texture
  34130. */
  34131. export class VideoTexture extends Texture {
  34132. /**
  34133. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34134. */
  34135. readonly autoUpdateTexture: boolean;
  34136. /**
  34137. * The video instance used by the texture internally
  34138. */
  34139. readonly video: HTMLVideoElement;
  34140. private _onUserActionRequestedObservable;
  34141. /**
  34142. * Event triggerd when a dom action is required by the user to play the video.
  34143. * This happens due to recent changes in browser policies preventing video to auto start.
  34144. */
  34145. get onUserActionRequestedObservable(): Observable<Texture>;
  34146. private _generateMipMaps;
  34147. private _stillImageCaptured;
  34148. private _displayingPosterTexture;
  34149. private _settings;
  34150. private _createInternalTextureOnEvent;
  34151. private _frameId;
  34152. private _currentSrc;
  34153. /**
  34154. * Creates a video texture.
  34155. * If you want to display a video in your scene, this is the special texture for that.
  34156. * This special texture works similar to other textures, with the exception of a few parameters.
  34157. * @see https://doc.babylonjs.com/how_to/video_texture
  34158. * @param name optional name, will detect from video source, if not defined
  34159. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34160. * @param scene is obviously the current scene.
  34161. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34162. * @param invertY is false by default but can be used to invert video on Y axis
  34163. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34164. * @param settings allows finer control over video usage
  34165. */
  34166. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34167. private _getName;
  34168. private _getVideo;
  34169. private _createInternalTexture;
  34170. private reset;
  34171. /**
  34172. * @hidden Internal method to initiate `update`.
  34173. */
  34174. _rebuild(): void;
  34175. /**
  34176. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34177. */
  34178. update(): void;
  34179. /**
  34180. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34181. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34182. */
  34183. updateTexture(isVisible: boolean): void;
  34184. protected _updateInternalTexture: () => void;
  34185. /**
  34186. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34187. * @param url New url.
  34188. */
  34189. updateURL(url: string): void;
  34190. /**
  34191. * Clones the texture.
  34192. * @returns the cloned texture
  34193. */
  34194. clone(): VideoTexture;
  34195. /**
  34196. * Dispose the texture and release its associated resources.
  34197. */
  34198. dispose(): void;
  34199. /**
  34200. * Creates a video texture straight from a stream.
  34201. * @param scene Define the scene the texture should be created in
  34202. * @param stream Define the stream the texture should be created from
  34203. * @returns The created video texture as a promise
  34204. */
  34205. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34206. /**
  34207. * Creates a video texture straight from your WebCam video feed.
  34208. * @param scene Define the scene the texture should be created in
  34209. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34210. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34211. * @returns The created video texture as a promise
  34212. */
  34213. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34214. minWidth: number;
  34215. maxWidth: number;
  34216. minHeight: number;
  34217. maxHeight: number;
  34218. deviceId: string;
  34219. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34220. /**
  34221. * Creates a video texture straight from your WebCam video feed.
  34222. * @param scene Define the scene the texture should be created in
  34223. * @param onReady Define a callback to triggered once the texture will be ready
  34224. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34225. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34226. */
  34227. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34228. minWidth: number;
  34229. maxWidth: number;
  34230. minHeight: number;
  34231. maxHeight: number;
  34232. deviceId: string;
  34233. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34234. }
  34235. }
  34236. declare module BABYLON {
  34237. /**
  34238. * Defines the interface used by objects working like Scene
  34239. * @hidden
  34240. */
  34241. export interface ISceneLike {
  34242. _addPendingData(data: any): void;
  34243. _removePendingData(data: any): void;
  34244. offlineProvider: IOfflineProvider;
  34245. }
  34246. /** Interface defining initialization parameters for Engine class */
  34247. export interface EngineOptions extends WebGLContextAttributes {
  34248. /**
  34249. * Defines if the engine should no exceed a specified device ratio
  34250. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34251. */
  34252. limitDeviceRatio?: number;
  34253. /**
  34254. * Defines if webvr should be enabled automatically
  34255. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34256. */
  34257. autoEnableWebVR?: boolean;
  34258. /**
  34259. * Defines if webgl2 should be turned off even if supported
  34260. * @see http://doc.babylonjs.com/features/webgl2
  34261. */
  34262. disableWebGL2Support?: boolean;
  34263. /**
  34264. * Defines if webaudio should be initialized as well
  34265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34266. */
  34267. audioEngine?: boolean;
  34268. /**
  34269. * Defines if animations should run using a deterministic lock step
  34270. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34271. */
  34272. deterministicLockstep?: boolean;
  34273. /** Defines the maximum steps to use with deterministic lock step mode */
  34274. lockstepMaxSteps?: number;
  34275. /** Defines the seconds between each deterministic lock step */
  34276. timeStep?: number;
  34277. /**
  34278. * Defines that engine should ignore context lost events
  34279. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34280. */
  34281. doNotHandleContextLost?: boolean;
  34282. /**
  34283. * Defines that engine should ignore modifying touch action attribute and style
  34284. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34285. */
  34286. doNotHandleTouchAction?: boolean;
  34287. /**
  34288. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34289. */
  34290. useHighPrecisionFloats?: boolean;
  34291. /**
  34292. * Make the canvas XR Compatible for XR sessions
  34293. */
  34294. xrCompatible?: boolean;
  34295. }
  34296. /**
  34297. * The base engine class (root of all engines)
  34298. */
  34299. export class ThinEngine {
  34300. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34301. static ExceptionList: ({
  34302. key: string;
  34303. capture: string;
  34304. captureConstraint: number;
  34305. targets: string[];
  34306. } | {
  34307. key: string;
  34308. capture: null;
  34309. captureConstraint: null;
  34310. targets: string[];
  34311. })[];
  34312. /** @hidden */
  34313. static _TextureLoaders: IInternalTextureLoader[];
  34314. /**
  34315. * Returns the current npm package of the sdk
  34316. */
  34317. static get NpmPackage(): string;
  34318. /**
  34319. * Returns the current version of the framework
  34320. */
  34321. static get Version(): string;
  34322. /**
  34323. * Returns a string describing the current engine
  34324. */
  34325. get description(): string;
  34326. /**
  34327. * Gets or sets the epsilon value used by collision engine
  34328. */
  34329. static CollisionsEpsilon: number;
  34330. /**
  34331. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34332. */
  34333. static get ShadersRepository(): string;
  34334. static set ShadersRepository(value: string);
  34335. /** @hidden */
  34336. _shaderProcessor: IShaderProcessor;
  34337. /**
  34338. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34339. */
  34340. forcePOTTextures: boolean;
  34341. /**
  34342. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34343. */
  34344. isFullscreen: boolean;
  34345. /**
  34346. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34347. */
  34348. cullBackFaces: boolean;
  34349. /**
  34350. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34351. */
  34352. renderEvenInBackground: boolean;
  34353. /**
  34354. * Gets or sets a boolean indicating that cache can be kept between frames
  34355. */
  34356. preventCacheWipeBetweenFrames: boolean;
  34357. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34358. validateShaderPrograms: boolean;
  34359. /**
  34360. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34361. * This can provide greater z depth for distant objects.
  34362. */
  34363. useReverseDepthBuffer: boolean;
  34364. /**
  34365. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34366. */
  34367. disableUniformBuffers: boolean;
  34368. /** @hidden */
  34369. _uniformBuffers: UniformBuffer[];
  34370. /**
  34371. * Gets a boolean indicating that the engine supports uniform buffers
  34372. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34373. */
  34374. get supportsUniformBuffers(): boolean;
  34375. /** @hidden */
  34376. _gl: WebGLRenderingContext;
  34377. /** @hidden */
  34378. _webGLVersion: number;
  34379. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34380. protected _windowIsBackground: boolean;
  34381. protected _creationOptions: EngineOptions;
  34382. protected _highPrecisionShadersAllowed: boolean;
  34383. /** @hidden */
  34384. get _shouldUseHighPrecisionShader(): boolean;
  34385. /**
  34386. * Gets a boolean indicating that only power of 2 textures are supported
  34387. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34388. */
  34389. get needPOTTextures(): boolean;
  34390. /** @hidden */
  34391. _badOS: boolean;
  34392. /** @hidden */
  34393. _badDesktopOS: boolean;
  34394. private _hardwareScalingLevel;
  34395. /** @hidden */
  34396. _caps: EngineCapabilities;
  34397. private _isStencilEnable;
  34398. private _glVersion;
  34399. private _glRenderer;
  34400. private _glVendor;
  34401. /** @hidden */
  34402. _videoTextureSupported: boolean;
  34403. protected _renderingQueueLaunched: boolean;
  34404. protected _activeRenderLoops: (() => void)[];
  34405. /**
  34406. * Observable signaled when a context lost event is raised
  34407. */
  34408. onContextLostObservable: Observable<ThinEngine>;
  34409. /**
  34410. * Observable signaled when a context restored event is raised
  34411. */
  34412. onContextRestoredObservable: Observable<ThinEngine>;
  34413. private _onContextLost;
  34414. private _onContextRestored;
  34415. protected _contextWasLost: boolean;
  34416. /** @hidden */
  34417. _doNotHandleContextLost: boolean;
  34418. /**
  34419. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34421. */
  34422. get doNotHandleContextLost(): boolean;
  34423. set doNotHandleContextLost(value: boolean);
  34424. /**
  34425. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34426. */
  34427. disableVertexArrayObjects: boolean;
  34428. /** @hidden */
  34429. protected _colorWrite: boolean;
  34430. /** @hidden */
  34431. protected _colorWriteChanged: boolean;
  34432. /** @hidden */
  34433. protected _depthCullingState: DepthCullingState;
  34434. /** @hidden */
  34435. protected _stencilState: StencilState;
  34436. /** @hidden */
  34437. _alphaState: AlphaState;
  34438. /** @hidden */
  34439. _alphaMode: number;
  34440. /** @hidden */
  34441. _alphaEquation: number;
  34442. /** @hidden */
  34443. _internalTexturesCache: InternalTexture[];
  34444. /** @hidden */
  34445. protected _activeChannel: number;
  34446. private _currentTextureChannel;
  34447. /** @hidden */
  34448. protected _boundTexturesCache: {
  34449. [key: string]: Nullable<InternalTexture>;
  34450. };
  34451. /** @hidden */
  34452. protected _currentEffect: Nullable<Effect>;
  34453. /** @hidden */
  34454. protected _currentProgram: Nullable<WebGLProgram>;
  34455. private _compiledEffects;
  34456. private _vertexAttribArraysEnabled;
  34457. /** @hidden */
  34458. protected _cachedViewport: Nullable<IViewportLike>;
  34459. private _cachedVertexArrayObject;
  34460. /** @hidden */
  34461. protected _cachedVertexBuffers: any;
  34462. /** @hidden */
  34463. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34464. /** @hidden */
  34465. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34466. /** @hidden */
  34467. _currentRenderTarget: Nullable<InternalTexture>;
  34468. private _uintIndicesCurrentlySet;
  34469. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34470. /** @hidden */
  34471. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34472. /** @hidden */
  34473. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34474. private _currentBufferPointers;
  34475. private _currentInstanceLocations;
  34476. private _currentInstanceBuffers;
  34477. private _textureUnits;
  34478. /** @hidden */
  34479. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34480. /** @hidden */
  34481. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34482. /** @hidden */
  34483. _boundRenderFunction: any;
  34484. private _vaoRecordInProgress;
  34485. private _mustWipeVertexAttributes;
  34486. private _emptyTexture;
  34487. private _emptyCubeTexture;
  34488. private _emptyTexture3D;
  34489. private _emptyTexture2DArray;
  34490. /** @hidden */
  34491. _frameHandler: number;
  34492. private _nextFreeTextureSlots;
  34493. private _maxSimultaneousTextures;
  34494. private _activeRequests;
  34495. /** @hidden */
  34496. _transformTextureUrl: Nullable<(url: string) => string>;
  34497. protected get _supportsHardwareTextureRescaling(): boolean;
  34498. private _framebufferDimensionsObject;
  34499. /**
  34500. * sets the object from which width and height will be taken from when getting render width and height
  34501. * Will fallback to the gl object
  34502. * @param dimensions the framebuffer width and height that will be used.
  34503. */
  34504. set framebufferDimensionsObject(dimensions: Nullable<{
  34505. framebufferWidth: number;
  34506. framebufferHeight: number;
  34507. }>);
  34508. /**
  34509. * Gets the current viewport
  34510. */
  34511. get currentViewport(): Nullable<IViewportLike>;
  34512. /**
  34513. * Gets the default empty texture
  34514. */
  34515. get emptyTexture(): InternalTexture;
  34516. /**
  34517. * Gets the default empty 3D texture
  34518. */
  34519. get emptyTexture3D(): InternalTexture;
  34520. /**
  34521. * Gets the default empty 2D array texture
  34522. */
  34523. get emptyTexture2DArray(): InternalTexture;
  34524. /**
  34525. * Gets the default empty cube texture
  34526. */
  34527. get emptyCubeTexture(): InternalTexture;
  34528. /**
  34529. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34530. */
  34531. readonly premultipliedAlpha: boolean;
  34532. /**
  34533. * Observable event triggered before each texture is initialized
  34534. */
  34535. onBeforeTextureInitObservable: Observable<Texture>;
  34536. /**
  34537. * Creates a new engine
  34538. * @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
  34539. * @param antialias defines enable antialiasing (default: false)
  34540. * @param options defines further options to be sent to the getContext() function
  34541. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34542. */
  34543. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34544. private _rebuildInternalTextures;
  34545. private _rebuildEffects;
  34546. /**
  34547. * Gets a boolean indicating if all created effects are ready
  34548. * @returns true if all effects are ready
  34549. */
  34550. areAllEffectsReady(): boolean;
  34551. protected _rebuildBuffers(): void;
  34552. protected _initGLContext(): void;
  34553. /**
  34554. * Gets version of the current webGL context
  34555. */
  34556. get webGLVersion(): number;
  34557. /**
  34558. * Gets a string idenfifying the name of the class
  34559. * @returns "Engine" string
  34560. */
  34561. getClassName(): string;
  34562. /**
  34563. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34564. */
  34565. get isStencilEnable(): boolean;
  34566. /** @hidden */
  34567. _prepareWorkingCanvas(): void;
  34568. /**
  34569. * Reset the texture cache to empty state
  34570. */
  34571. resetTextureCache(): void;
  34572. /**
  34573. * Gets an object containing information about the current webGL context
  34574. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34575. */
  34576. getGlInfo(): {
  34577. vendor: string;
  34578. renderer: string;
  34579. version: string;
  34580. };
  34581. /**
  34582. * Defines the hardware scaling level.
  34583. * By default the hardware scaling level is computed from the window device ratio.
  34584. * 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.
  34585. * @param level defines the level to use
  34586. */
  34587. setHardwareScalingLevel(level: number): void;
  34588. /**
  34589. * Gets the current hardware scaling level.
  34590. * By default the hardware scaling level is computed from the window device ratio.
  34591. * 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.
  34592. * @returns a number indicating the current hardware scaling level
  34593. */
  34594. getHardwareScalingLevel(): number;
  34595. /**
  34596. * Gets the list of loaded textures
  34597. * @returns an array containing all loaded textures
  34598. */
  34599. getLoadedTexturesCache(): InternalTexture[];
  34600. /**
  34601. * Gets the object containing all engine capabilities
  34602. * @returns the EngineCapabilities object
  34603. */
  34604. getCaps(): EngineCapabilities;
  34605. /**
  34606. * stop executing a render loop function and remove it from the execution array
  34607. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34608. */
  34609. stopRenderLoop(renderFunction?: () => void): void;
  34610. /** @hidden */
  34611. _renderLoop(): void;
  34612. /**
  34613. * Gets the HTML canvas attached with the current webGL context
  34614. * @returns a HTML canvas
  34615. */
  34616. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34617. /**
  34618. * Gets host window
  34619. * @returns the host window object
  34620. */
  34621. getHostWindow(): Nullable<Window>;
  34622. /**
  34623. * Gets the current render width
  34624. * @param useScreen defines if screen size must be used (or the current render target if any)
  34625. * @returns a number defining the current render width
  34626. */
  34627. getRenderWidth(useScreen?: boolean): number;
  34628. /**
  34629. * Gets the current render height
  34630. * @param useScreen defines if screen size must be used (or the current render target if any)
  34631. * @returns a number defining the current render height
  34632. */
  34633. getRenderHeight(useScreen?: boolean): number;
  34634. /**
  34635. * Can be used to override the current requestAnimationFrame requester.
  34636. * @hidden
  34637. */
  34638. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34639. /**
  34640. * Register and execute a render loop. The engine can have more than one render function
  34641. * @param renderFunction defines the function to continuously execute
  34642. */
  34643. runRenderLoop(renderFunction: () => void): void;
  34644. /**
  34645. * Clear the current render buffer or the current render target (if any is set up)
  34646. * @param color defines the color to use
  34647. * @param backBuffer defines if the back buffer must be cleared
  34648. * @param depth defines if the depth buffer must be cleared
  34649. * @param stencil defines if the stencil buffer must be cleared
  34650. */
  34651. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34652. private _viewportCached;
  34653. /** @hidden */
  34654. _viewport(x: number, y: number, width: number, height: number): void;
  34655. /**
  34656. * Set the WebGL's viewport
  34657. * @param viewport defines the viewport element to be used
  34658. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34659. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34660. */
  34661. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34662. /**
  34663. * Begin a new frame
  34664. */
  34665. beginFrame(): void;
  34666. /**
  34667. * Enf the current frame
  34668. */
  34669. endFrame(): void;
  34670. /**
  34671. * Resize the view according to the canvas' size
  34672. */
  34673. resize(): void;
  34674. /**
  34675. * Force a specific size of the canvas
  34676. * @param width defines the new canvas' width
  34677. * @param height defines the new canvas' height
  34678. */
  34679. setSize(width: number, height: number): void;
  34680. /**
  34681. * Binds the frame buffer to the specified texture.
  34682. * @param texture The texture to render to or null for the default canvas
  34683. * @param faceIndex The face of the texture to render to in case of cube texture
  34684. * @param requiredWidth The width of the target to render to
  34685. * @param requiredHeight The height of the target to render to
  34686. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34687. * @param lodLevel defines the lod level to bind to the frame buffer
  34688. * @param layer defines the 2d array index to bind to frame buffer to
  34689. */
  34690. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34691. /** @hidden */
  34692. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34693. /**
  34694. * Unbind the current render target texture from the webGL context
  34695. * @param texture defines the render target texture to unbind
  34696. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34697. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34698. */
  34699. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34700. /**
  34701. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34702. */
  34703. flushFramebuffer(): void;
  34704. /**
  34705. * Unbind the current render target and bind the default framebuffer
  34706. */
  34707. restoreDefaultFramebuffer(): void;
  34708. /** @hidden */
  34709. protected _resetVertexBufferBinding(): void;
  34710. /**
  34711. * Creates a vertex buffer
  34712. * @param data the data for the vertex buffer
  34713. * @returns the new WebGL static buffer
  34714. */
  34715. createVertexBuffer(data: DataArray): DataBuffer;
  34716. private _createVertexBuffer;
  34717. /**
  34718. * Creates a dynamic vertex buffer
  34719. * @param data the data for the dynamic vertex buffer
  34720. * @returns the new WebGL dynamic buffer
  34721. */
  34722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34723. protected _resetIndexBufferBinding(): void;
  34724. /**
  34725. * Creates a new index buffer
  34726. * @param indices defines the content of the index buffer
  34727. * @param updatable defines if the index buffer must be updatable
  34728. * @returns a new webGL buffer
  34729. */
  34730. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34731. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34732. /**
  34733. * Bind a webGL buffer to the webGL context
  34734. * @param buffer defines the buffer to bind
  34735. */
  34736. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34737. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34738. private bindBuffer;
  34739. /**
  34740. * update the bound buffer with the given data
  34741. * @param data defines the data to update
  34742. */
  34743. updateArrayBuffer(data: Float32Array): void;
  34744. private _vertexAttribPointer;
  34745. /** @hidden */
  34746. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34747. private _bindVertexBuffersAttributes;
  34748. /**
  34749. * Records a vertex array object
  34750. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34751. * @param vertexBuffers defines the list of vertex buffers to store
  34752. * @param indexBuffer defines the index buffer to store
  34753. * @param effect defines the effect to store
  34754. * @returns the new vertex array object
  34755. */
  34756. recordVertexArrayObject(vertexBuffers: {
  34757. [key: string]: VertexBuffer;
  34758. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34759. /**
  34760. * Bind a specific vertex array object
  34761. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34762. * @param vertexArrayObject defines the vertex array object to bind
  34763. * @param indexBuffer defines the index buffer to bind
  34764. */
  34765. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34766. /**
  34767. * Bind webGl buffers directly to the webGL context
  34768. * @param vertexBuffer defines the vertex buffer to bind
  34769. * @param indexBuffer defines the index buffer to bind
  34770. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34771. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34772. * @param effect defines the effect associated with the vertex buffer
  34773. */
  34774. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34775. private _unbindVertexArrayObject;
  34776. /**
  34777. * Bind a list of vertex buffers to the webGL context
  34778. * @param vertexBuffers defines the list of vertex buffers to bind
  34779. * @param indexBuffer defines the index buffer to bind
  34780. * @param effect defines the effect associated with the vertex buffers
  34781. */
  34782. bindBuffers(vertexBuffers: {
  34783. [key: string]: Nullable<VertexBuffer>;
  34784. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34785. /**
  34786. * Unbind all instance attributes
  34787. */
  34788. unbindInstanceAttributes(): void;
  34789. /**
  34790. * Release and free the memory of a vertex array object
  34791. * @param vao defines the vertex array object to delete
  34792. */
  34793. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34794. /** @hidden */
  34795. _releaseBuffer(buffer: DataBuffer): boolean;
  34796. protected _deleteBuffer(buffer: DataBuffer): void;
  34797. /**
  34798. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34799. * @param instancesBuffer defines the webGL buffer to update and bind
  34800. * @param data defines the data to store in the buffer
  34801. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34802. */
  34803. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34804. /**
  34805. * Bind the content of a webGL buffer used with instantiation
  34806. * @param instancesBuffer defines the webGL buffer to bind
  34807. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34808. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34809. */
  34810. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34811. /**
  34812. * Disable the instance attribute corresponding to the name in parameter
  34813. * @param name defines the name of the attribute to disable
  34814. */
  34815. disableInstanceAttributeByName(name: string): void;
  34816. /**
  34817. * Disable the instance attribute corresponding to the location in parameter
  34818. * @param attributeLocation defines the attribute location of the attribute to disable
  34819. */
  34820. disableInstanceAttribute(attributeLocation: number): void;
  34821. /**
  34822. * Disable the attribute corresponding to the location in parameter
  34823. * @param attributeLocation defines the attribute location of the attribute to disable
  34824. */
  34825. disableAttributeByIndex(attributeLocation: number): void;
  34826. /**
  34827. * Send a draw order
  34828. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34829. * @param indexStart defines the starting index
  34830. * @param indexCount defines the number of index to draw
  34831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34832. */
  34833. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34834. /**
  34835. * Draw a list of points
  34836. * @param verticesStart defines the index of first vertex to draw
  34837. * @param verticesCount defines the count of vertices to draw
  34838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34839. */
  34840. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34841. /**
  34842. * Draw a list of unindexed primitives
  34843. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34844. * @param verticesStart defines the index of first vertex to draw
  34845. * @param verticesCount defines the count of vertices to draw
  34846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34847. */
  34848. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34849. /**
  34850. * Draw a list of indexed primitives
  34851. * @param fillMode defines the primitive to use
  34852. * @param indexStart defines the starting index
  34853. * @param indexCount defines the number of index to draw
  34854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34855. */
  34856. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34857. /**
  34858. * Draw a list of unindexed primitives
  34859. * @param fillMode defines the primitive to use
  34860. * @param verticesStart defines the index of first vertex to draw
  34861. * @param verticesCount defines the count of vertices to draw
  34862. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34863. */
  34864. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34865. private _drawMode;
  34866. /** @hidden */
  34867. protected _reportDrawCall(): void;
  34868. /** @hidden */
  34869. _releaseEffect(effect: Effect): void;
  34870. /** @hidden */
  34871. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34872. /**
  34873. * Create a new effect (used to store vertex/fragment shaders)
  34874. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34875. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34876. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34877. * @param samplers defines an array of string used to represent textures
  34878. * @param defines defines the string containing the defines to use to compile the shaders
  34879. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34880. * @param onCompiled defines a function to call when the effect creation is successful
  34881. * @param onError defines a function to call when the effect creation has failed
  34882. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34883. * @returns the new Effect
  34884. */
  34885. 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;
  34886. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34887. private _compileShader;
  34888. private _compileRawShader;
  34889. /** @hidden */
  34890. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34891. /**
  34892. * Directly creates a webGL program
  34893. * @param pipelineContext defines the pipeline context to attach to
  34894. * @param vertexCode defines the vertex shader code to use
  34895. * @param fragmentCode defines the fragment shader code to use
  34896. * @param context defines the webGL context to use (if not set, the current one will be used)
  34897. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34898. * @returns the new webGL program
  34899. */
  34900. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34901. /**
  34902. * Creates a webGL program
  34903. * @param pipelineContext defines the pipeline context to attach to
  34904. * @param vertexCode defines the vertex shader code to use
  34905. * @param fragmentCode defines the fragment shader code to use
  34906. * @param defines defines the string containing the defines to use to compile the shaders
  34907. * @param context defines the webGL context to use (if not set, the current one will be used)
  34908. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34909. * @returns the new webGL program
  34910. */
  34911. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34912. /**
  34913. * Creates a new pipeline context
  34914. * @returns the new pipeline
  34915. */
  34916. createPipelineContext(): IPipelineContext;
  34917. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34918. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34919. /** @hidden */
  34920. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34921. /** @hidden */
  34922. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34923. /** @hidden */
  34924. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34925. /**
  34926. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34927. * @param pipelineContext defines the pipeline context to use
  34928. * @param uniformsNames defines the list of uniform names
  34929. * @returns an array of webGL uniform locations
  34930. */
  34931. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34932. /**
  34933. * Gets the lsit of active attributes for a given webGL program
  34934. * @param pipelineContext defines the pipeline context to use
  34935. * @param attributesNames defines the list of attribute names to get
  34936. * @returns an array of indices indicating the offset of each attribute
  34937. */
  34938. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34939. /**
  34940. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34941. * @param effect defines the effect to activate
  34942. */
  34943. enableEffect(effect: Nullable<Effect>): void;
  34944. /**
  34945. * Set the value of an uniform to a number (int)
  34946. * @param uniform defines the webGL uniform location where to store the value
  34947. * @param value defines the int number to store
  34948. */
  34949. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34950. /**
  34951. * Set the value of an uniform to an array of int32
  34952. * @param uniform defines the webGL uniform location where to store the value
  34953. * @param array defines the array of int32 to store
  34954. */
  34955. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34956. /**
  34957. * Set the value of an uniform to an array of int32 (stored as vec2)
  34958. * @param uniform defines the webGL uniform location where to store the value
  34959. * @param array defines the array of int32 to store
  34960. */
  34961. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34962. /**
  34963. * Set the value of an uniform to an array of int32 (stored as vec3)
  34964. * @param uniform defines the webGL uniform location where to store the value
  34965. * @param array defines the array of int32 to store
  34966. */
  34967. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34968. /**
  34969. * Set the value of an uniform to an array of int32 (stored as vec4)
  34970. * @param uniform defines the webGL uniform location where to store the value
  34971. * @param array defines the array of int32 to store
  34972. */
  34973. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34974. /**
  34975. * Set the value of an uniform to an array of number
  34976. * @param uniform defines the webGL uniform location where to store the value
  34977. * @param array defines the array of number to store
  34978. */
  34979. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34980. /**
  34981. * Set the value of an uniform to an array of number (stored as vec2)
  34982. * @param uniform defines the webGL uniform location where to store the value
  34983. * @param array defines the array of number to store
  34984. */
  34985. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34986. /**
  34987. * Set the value of an uniform to an array of number (stored as vec3)
  34988. * @param uniform defines the webGL uniform location where to store the value
  34989. * @param array defines the array of number to store
  34990. */
  34991. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34992. /**
  34993. * Set the value of an uniform to an array of number (stored as vec4)
  34994. * @param uniform defines the webGL uniform location where to store the value
  34995. * @param array defines the array of number to store
  34996. */
  34997. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34998. /**
  34999. * Set the value of an uniform to an array of float32 (stored as matrices)
  35000. * @param uniform defines the webGL uniform location where to store the value
  35001. * @param matrices defines the array of float32 to store
  35002. */
  35003. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35004. /**
  35005. * Set the value of an uniform to a matrix (3x3)
  35006. * @param uniform defines the webGL uniform location where to store the value
  35007. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35008. */
  35009. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35010. /**
  35011. * Set the value of an uniform to a matrix (2x2)
  35012. * @param uniform defines the webGL uniform location where to store the value
  35013. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35014. */
  35015. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35016. /**
  35017. * Set the value of an uniform to a number (float)
  35018. * @param uniform defines the webGL uniform location where to store the value
  35019. * @param value defines the float number to store
  35020. */
  35021. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35022. /**
  35023. * Set the value of an uniform to a vec2
  35024. * @param uniform defines the webGL uniform location where to store the value
  35025. * @param x defines the 1st component of the value
  35026. * @param y defines the 2nd component of the value
  35027. */
  35028. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35029. /**
  35030. * Set the value of an uniform to a vec3
  35031. * @param uniform defines the webGL uniform location where to store the value
  35032. * @param x defines the 1st component of the value
  35033. * @param y defines the 2nd component of the value
  35034. * @param z defines the 3rd component of the value
  35035. */
  35036. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35037. /**
  35038. * Set the value of an uniform to a vec4
  35039. * @param uniform defines the webGL uniform location where to store the value
  35040. * @param x defines the 1st component of the value
  35041. * @param y defines the 2nd component of the value
  35042. * @param z defines the 3rd component of the value
  35043. * @param w defines the 4th component of the value
  35044. */
  35045. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35046. /**
  35047. * Apply all cached states (depth, culling, stencil and alpha)
  35048. */
  35049. applyStates(): void;
  35050. /**
  35051. * Enable or disable color writing
  35052. * @param enable defines the state to set
  35053. */
  35054. setColorWrite(enable: boolean): void;
  35055. /**
  35056. * Gets a boolean indicating if color writing is enabled
  35057. * @returns the current color writing state
  35058. */
  35059. getColorWrite(): boolean;
  35060. /**
  35061. * Gets the depth culling state manager
  35062. */
  35063. get depthCullingState(): DepthCullingState;
  35064. /**
  35065. * Gets the alpha state manager
  35066. */
  35067. get alphaState(): AlphaState;
  35068. /**
  35069. * Gets the stencil state manager
  35070. */
  35071. get stencilState(): StencilState;
  35072. /**
  35073. * Clears the list of texture accessible through engine.
  35074. * This can help preventing texture load conflict due to name collision.
  35075. */
  35076. clearInternalTexturesCache(): void;
  35077. /**
  35078. * Force the entire cache to be cleared
  35079. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35080. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35081. */
  35082. wipeCaches(bruteForce?: boolean): void;
  35083. /** @hidden */
  35084. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35085. min: number;
  35086. mag: number;
  35087. };
  35088. /** @hidden */
  35089. _createTexture(): WebGLTexture;
  35090. /**
  35091. * Usually called from Texture.ts.
  35092. * Passed information to create a WebGLTexture
  35093. * @param url defines a value which contains one of the following:
  35094. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35095. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35096. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35097. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35098. * @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)
  35099. * @param scene needed for loading to the correct scene
  35100. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35101. * @param onLoad optional callback to be called upon successful completion
  35102. * @param onError optional callback to be called upon failure
  35103. * @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
  35104. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35105. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35106. * @param forcedExtension defines the extension to use to pick the right loader
  35107. * @param mimeType defines an optional mime type
  35108. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35109. */
  35110. 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;
  35111. /**
  35112. * Loads an image as an HTMLImageElement.
  35113. * @param input url string, ArrayBuffer, or Blob to load
  35114. * @param onLoad callback called when the image successfully loads
  35115. * @param onError callback called when the image fails to load
  35116. * @param offlineProvider offline provider for caching
  35117. * @param mimeType optional mime type
  35118. * @returns the HTMLImageElement of the loaded image
  35119. * @hidden
  35120. */
  35121. 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>;
  35122. /**
  35123. * @hidden
  35124. */
  35125. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35126. private _unpackFlipYCached;
  35127. /**
  35128. * In case you are sharing the context with other applications, it might
  35129. * be interested to not cache the unpack flip y state to ensure a consistent
  35130. * value would be set.
  35131. */
  35132. enableUnpackFlipYCached: boolean;
  35133. /** @hidden */
  35134. _unpackFlipY(value: boolean): void;
  35135. /** @hidden */
  35136. _getUnpackAlignement(): number;
  35137. private _getTextureTarget;
  35138. /**
  35139. * Update the sampling mode of a given texture
  35140. * @param samplingMode defines the required sampling mode
  35141. * @param texture defines the texture to update
  35142. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35143. */
  35144. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35145. /**
  35146. * Update the sampling mode of a given texture
  35147. * @param texture defines the texture to update
  35148. * @param wrapU defines the texture wrap mode of the u coordinates
  35149. * @param wrapV defines the texture wrap mode of the v coordinates
  35150. * @param wrapR defines the texture wrap mode of the r coordinates
  35151. */
  35152. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35153. /** @hidden */
  35154. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35155. width: number;
  35156. height: number;
  35157. layers?: number;
  35158. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35159. /** @hidden */
  35160. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35161. /** @hidden */
  35162. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35163. /**
  35164. * Update a portion of an internal texture
  35165. * @param texture defines the texture to update
  35166. * @param imageData defines the data to store into the texture
  35167. * @param xOffset defines the x coordinates of the update rectangle
  35168. * @param yOffset defines the y coordinates of the update rectangle
  35169. * @param width defines the width of the update rectangle
  35170. * @param height defines the height of the update rectangle
  35171. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35172. * @param lod defines the lod level to update (0 by default)
  35173. */
  35174. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35175. /** @hidden */
  35176. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35177. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35178. private _prepareWebGLTexture;
  35179. /** @hidden */
  35180. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35181. private _getDepthStencilBuffer;
  35182. /** @hidden */
  35183. _releaseFramebufferObjects(texture: InternalTexture): void;
  35184. /** @hidden */
  35185. _releaseTexture(texture: InternalTexture): void;
  35186. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35187. protected _setProgram(program: WebGLProgram): void;
  35188. protected _boundUniforms: {
  35189. [key: number]: WebGLUniformLocation;
  35190. };
  35191. /**
  35192. * Binds an effect to the webGL context
  35193. * @param effect defines the effect to bind
  35194. */
  35195. bindSamplers(effect: Effect): void;
  35196. private _activateCurrentTexture;
  35197. /** @hidden */
  35198. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35199. /** @hidden */
  35200. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35201. /**
  35202. * Unbind all textures from the webGL context
  35203. */
  35204. unbindAllTextures(): void;
  35205. /**
  35206. * Sets a texture to the according uniform.
  35207. * @param channel The texture channel
  35208. * @param uniform The uniform to set
  35209. * @param texture The texture to apply
  35210. */
  35211. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35212. private _bindSamplerUniformToChannel;
  35213. private _getTextureWrapMode;
  35214. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35215. /**
  35216. * Sets an array of texture to the webGL context
  35217. * @param channel defines the channel where the texture array must be set
  35218. * @param uniform defines the associated uniform location
  35219. * @param textures defines the array of textures to bind
  35220. */
  35221. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35222. /** @hidden */
  35223. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35224. private _setTextureParameterFloat;
  35225. private _setTextureParameterInteger;
  35226. /**
  35227. * Unbind all vertex attributes from the webGL context
  35228. */
  35229. unbindAllAttributes(): void;
  35230. /**
  35231. * 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
  35232. */
  35233. releaseEffects(): void;
  35234. /**
  35235. * Dispose and release all associated resources
  35236. */
  35237. dispose(): void;
  35238. /**
  35239. * Attach a new callback raised when context lost event is fired
  35240. * @param callback defines the callback to call
  35241. */
  35242. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35243. /**
  35244. * Attach a new callback raised when context restored event is fired
  35245. * @param callback defines the callback to call
  35246. */
  35247. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35248. /**
  35249. * Get the current error code of the webGL context
  35250. * @returns the error code
  35251. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35252. */
  35253. getError(): number;
  35254. private _canRenderToFloatFramebuffer;
  35255. private _canRenderToHalfFloatFramebuffer;
  35256. private _canRenderToFramebuffer;
  35257. /** @hidden */
  35258. _getWebGLTextureType(type: number): number;
  35259. /** @hidden */
  35260. _getInternalFormat(format: number): number;
  35261. /** @hidden */
  35262. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35263. /** @hidden */
  35264. _getRGBAMultiSampleBufferFormat(type: number): number;
  35265. /** @hidden */
  35266. _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;
  35267. /**
  35268. * Loads a file from a url
  35269. * @param url url to load
  35270. * @param onSuccess callback called when the file successfully loads
  35271. * @param onProgress callback called while file is loading (if the server supports this mode)
  35272. * @param offlineProvider defines the offline provider for caching
  35273. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35274. * @param onError callback called when the file fails to load
  35275. * @returns a file request object
  35276. * @hidden
  35277. */
  35278. 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;
  35279. /**
  35280. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35281. * @param x defines the x coordinate of the rectangle where pixels must be read
  35282. * @param y defines the y coordinate of the rectangle where pixels must be read
  35283. * @param width defines the width of the rectangle where pixels must be read
  35284. * @param height defines the height of the rectangle where pixels must be read
  35285. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35286. * @returns a Uint8Array containing RGBA colors
  35287. */
  35288. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35289. private static _isSupported;
  35290. /**
  35291. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35292. * @returns true if the engine can be created
  35293. * @ignorenaming
  35294. */
  35295. static isSupported(): boolean;
  35296. /**
  35297. * Find the next highest power of two.
  35298. * @param x Number to start search from.
  35299. * @return Next highest power of two.
  35300. */
  35301. static CeilingPOT(x: number): number;
  35302. /**
  35303. * Find the next lowest power of two.
  35304. * @param x Number to start search from.
  35305. * @return Next lowest power of two.
  35306. */
  35307. static FloorPOT(x: number): number;
  35308. /**
  35309. * Find the nearest power of two.
  35310. * @param x Number to start search from.
  35311. * @return Next nearest power of two.
  35312. */
  35313. static NearestPOT(x: number): number;
  35314. /**
  35315. * Get the closest exponent of two
  35316. * @param value defines the value to approximate
  35317. * @param max defines the maximum value to return
  35318. * @param mode defines how to define the closest value
  35319. * @returns closest exponent of two of the given value
  35320. */
  35321. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35322. /**
  35323. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35324. * @param func - the function to be called
  35325. * @param requester - the object that will request the next frame. Falls back to window.
  35326. * @returns frame number
  35327. */
  35328. static QueueNewFrame(func: () => void, requester?: any): number;
  35329. /**
  35330. * Gets host document
  35331. * @returns the host document object
  35332. */
  35333. getHostDocument(): Nullable<Document>;
  35334. }
  35335. }
  35336. declare module BABYLON {
  35337. /**
  35338. * Class representing spherical harmonics coefficients to the 3rd degree
  35339. */
  35340. export class SphericalHarmonics {
  35341. /**
  35342. * Defines whether or not the harmonics have been prescaled for rendering.
  35343. */
  35344. preScaled: boolean;
  35345. /**
  35346. * The l0,0 coefficients of the spherical harmonics
  35347. */
  35348. l00: Vector3;
  35349. /**
  35350. * The l1,-1 coefficients of the spherical harmonics
  35351. */
  35352. l1_1: Vector3;
  35353. /**
  35354. * The l1,0 coefficients of the spherical harmonics
  35355. */
  35356. l10: Vector3;
  35357. /**
  35358. * The l1,1 coefficients of the spherical harmonics
  35359. */
  35360. l11: Vector3;
  35361. /**
  35362. * The l2,-2 coefficients of the spherical harmonics
  35363. */
  35364. l2_2: Vector3;
  35365. /**
  35366. * The l2,-1 coefficients of the spherical harmonics
  35367. */
  35368. l2_1: Vector3;
  35369. /**
  35370. * The l2,0 coefficients of the spherical harmonics
  35371. */
  35372. l20: Vector3;
  35373. /**
  35374. * The l2,1 coefficients of the spherical harmonics
  35375. */
  35376. l21: Vector3;
  35377. /**
  35378. * The l2,2 coefficients of the spherical harmonics
  35379. */
  35380. l22: Vector3;
  35381. /**
  35382. * Adds a light to the spherical harmonics
  35383. * @param direction the direction of the light
  35384. * @param color the color of the light
  35385. * @param deltaSolidAngle the delta solid angle of the light
  35386. */
  35387. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35388. /**
  35389. * Scales the spherical harmonics by the given amount
  35390. * @param scale the amount to scale
  35391. */
  35392. scaleInPlace(scale: number): void;
  35393. /**
  35394. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35395. *
  35396. * ```
  35397. * E_lm = A_l * L_lm
  35398. * ```
  35399. *
  35400. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35401. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35402. * the scaling factors are given in equation 9.
  35403. */
  35404. convertIncidentRadianceToIrradiance(): void;
  35405. /**
  35406. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35407. *
  35408. * ```
  35409. * L = (1/pi) * E * rho
  35410. * ```
  35411. *
  35412. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35413. */
  35414. convertIrradianceToLambertianRadiance(): void;
  35415. /**
  35416. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35417. * required operations at run time.
  35418. *
  35419. * This is simply done by scaling back the SH with Ylm constants parameter.
  35420. * The trigonometric part being applied by the shader at run time.
  35421. */
  35422. preScaleForRendering(): void;
  35423. /**
  35424. * Constructs a spherical harmonics from an array.
  35425. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35426. * @returns the spherical harmonics
  35427. */
  35428. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35429. /**
  35430. * Gets the spherical harmonics from polynomial
  35431. * @param polynomial the spherical polynomial
  35432. * @returns the spherical harmonics
  35433. */
  35434. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35435. }
  35436. /**
  35437. * Class representing spherical polynomial coefficients to the 3rd degree
  35438. */
  35439. export class SphericalPolynomial {
  35440. private _harmonics;
  35441. /**
  35442. * The spherical harmonics used to create the polynomials.
  35443. */
  35444. get preScaledHarmonics(): SphericalHarmonics;
  35445. /**
  35446. * The x coefficients of the spherical polynomial
  35447. */
  35448. x: Vector3;
  35449. /**
  35450. * The y coefficients of the spherical polynomial
  35451. */
  35452. y: Vector3;
  35453. /**
  35454. * The z coefficients of the spherical polynomial
  35455. */
  35456. z: Vector3;
  35457. /**
  35458. * The xx coefficients of the spherical polynomial
  35459. */
  35460. xx: Vector3;
  35461. /**
  35462. * The yy coefficients of the spherical polynomial
  35463. */
  35464. yy: Vector3;
  35465. /**
  35466. * The zz coefficients of the spherical polynomial
  35467. */
  35468. zz: Vector3;
  35469. /**
  35470. * The xy coefficients of the spherical polynomial
  35471. */
  35472. xy: Vector3;
  35473. /**
  35474. * The yz coefficients of the spherical polynomial
  35475. */
  35476. yz: Vector3;
  35477. /**
  35478. * The zx coefficients of the spherical polynomial
  35479. */
  35480. zx: Vector3;
  35481. /**
  35482. * Adds an ambient color to the spherical polynomial
  35483. * @param color the color to add
  35484. */
  35485. addAmbient(color: Color3): void;
  35486. /**
  35487. * Scales the spherical polynomial by the given amount
  35488. * @param scale the amount to scale
  35489. */
  35490. scaleInPlace(scale: number): void;
  35491. /**
  35492. * Gets the spherical polynomial from harmonics
  35493. * @param harmonics the spherical harmonics
  35494. * @returns the spherical polynomial
  35495. */
  35496. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35497. /**
  35498. * Constructs a spherical polynomial from an array.
  35499. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35500. * @returns the spherical polynomial
  35501. */
  35502. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35503. }
  35504. }
  35505. declare module BABYLON {
  35506. /**
  35507. * Defines the source of the internal texture
  35508. */
  35509. export enum InternalTextureSource {
  35510. /**
  35511. * The source of the texture data is unknown
  35512. */
  35513. Unknown = 0,
  35514. /**
  35515. * Texture data comes from an URL
  35516. */
  35517. Url = 1,
  35518. /**
  35519. * Texture data is only used for temporary storage
  35520. */
  35521. Temp = 2,
  35522. /**
  35523. * Texture data comes from raw data (ArrayBuffer)
  35524. */
  35525. Raw = 3,
  35526. /**
  35527. * Texture content is dynamic (video or dynamic texture)
  35528. */
  35529. Dynamic = 4,
  35530. /**
  35531. * Texture content is generated by rendering to it
  35532. */
  35533. RenderTarget = 5,
  35534. /**
  35535. * Texture content is part of a multi render target process
  35536. */
  35537. MultiRenderTarget = 6,
  35538. /**
  35539. * Texture data comes from a cube data file
  35540. */
  35541. Cube = 7,
  35542. /**
  35543. * Texture data comes from a raw cube data
  35544. */
  35545. CubeRaw = 8,
  35546. /**
  35547. * Texture data come from a prefiltered cube data file
  35548. */
  35549. CubePrefiltered = 9,
  35550. /**
  35551. * Texture content is raw 3D data
  35552. */
  35553. Raw3D = 10,
  35554. /**
  35555. * Texture content is raw 2D array data
  35556. */
  35557. Raw2DArray = 11,
  35558. /**
  35559. * Texture content is a depth texture
  35560. */
  35561. Depth = 12,
  35562. /**
  35563. * Texture data comes from a raw cube data encoded with RGBD
  35564. */
  35565. CubeRawRGBD = 13
  35566. }
  35567. /**
  35568. * Class used to store data associated with WebGL texture data for the engine
  35569. * This class should not be used directly
  35570. */
  35571. export class InternalTexture {
  35572. /** @hidden */
  35573. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35574. /**
  35575. * Defines if the texture is ready
  35576. */
  35577. isReady: boolean;
  35578. /**
  35579. * Defines if the texture is a cube texture
  35580. */
  35581. isCube: boolean;
  35582. /**
  35583. * Defines if the texture contains 3D data
  35584. */
  35585. is3D: boolean;
  35586. /**
  35587. * Defines if the texture contains 2D array data
  35588. */
  35589. is2DArray: boolean;
  35590. /**
  35591. * Defines if the texture contains multiview data
  35592. */
  35593. isMultiview: boolean;
  35594. /**
  35595. * Gets the URL used to load this texture
  35596. */
  35597. url: string;
  35598. /**
  35599. * Gets the sampling mode of the texture
  35600. */
  35601. samplingMode: number;
  35602. /**
  35603. * Gets a boolean indicating if the texture needs mipmaps generation
  35604. */
  35605. generateMipMaps: boolean;
  35606. /**
  35607. * Gets the number of samples used by the texture (WebGL2+ only)
  35608. */
  35609. samples: number;
  35610. /**
  35611. * Gets the type of the texture (int, float...)
  35612. */
  35613. type: number;
  35614. /**
  35615. * Gets the format of the texture (RGB, RGBA...)
  35616. */
  35617. format: number;
  35618. /**
  35619. * Observable called when the texture is loaded
  35620. */
  35621. onLoadedObservable: Observable<InternalTexture>;
  35622. /**
  35623. * Gets the width of the texture
  35624. */
  35625. width: number;
  35626. /**
  35627. * Gets the height of the texture
  35628. */
  35629. height: number;
  35630. /**
  35631. * Gets the depth of the texture
  35632. */
  35633. depth: number;
  35634. /**
  35635. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35636. */
  35637. baseWidth: number;
  35638. /**
  35639. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35640. */
  35641. baseHeight: number;
  35642. /**
  35643. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35644. */
  35645. baseDepth: number;
  35646. /**
  35647. * Gets a boolean indicating if the texture is inverted on Y axis
  35648. */
  35649. invertY: boolean;
  35650. /** @hidden */
  35651. _invertVScale: boolean;
  35652. /** @hidden */
  35653. _associatedChannel: number;
  35654. /** @hidden */
  35655. _source: InternalTextureSource;
  35656. /** @hidden */
  35657. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35658. /** @hidden */
  35659. _bufferView: Nullable<ArrayBufferView>;
  35660. /** @hidden */
  35661. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35662. /** @hidden */
  35663. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35664. /** @hidden */
  35665. _size: number;
  35666. /** @hidden */
  35667. _extension: string;
  35668. /** @hidden */
  35669. _files: Nullable<string[]>;
  35670. /** @hidden */
  35671. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35672. /** @hidden */
  35673. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35674. /** @hidden */
  35675. _framebuffer: Nullable<WebGLFramebuffer>;
  35676. /** @hidden */
  35677. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35678. /** @hidden */
  35679. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35680. /** @hidden */
  35681. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35682. /** @hidden */
  35683. _attachments: Nullable<number[]>;
  35684. /** @hidden */
  35685. _cachedCoordinatesMode: Nullable<number>;
  35686. /** @hidden */
  35687. _cachedWrapU: Nullable<number>;
  35688. /** @hidden */
  35689. _cachedWrapV: Nullable<number>;
  35690. /** @hidden */
  35691. _cachedWrapR: Nullable<number>;
  35692. /** @hidden */
  35693. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35694. /** @hidden */
  35695. _isDisabled: boolean;
  35696. /** @hidden */
  35697. _compression: Nullable<string>;
  35698. /** @hidden */
  35699. _generateStencilBuffer: boolean;
  35700. /** @hidden */
  35701. _generateDepthBuffer: boolean;
  35702. /** @hidden */
  35703. _comparisonFunction: number;
  35704. /** @hidden */
  35705. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35706. /** @hidden */
  35707. _lodGenerationScale: number;
  35708. /** @hidden */
  35709. _lodGenerationOffset: number;
  35710. /** @hidden */
  35711. _depthStencilTexture: Nullable<InternalTexture>;
  35712. /** @hidden */
  35713. _colorTextureArray: Nullable<WebGLTexture>;
  35714. /** @hidden */
  35715. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35716. /** @hidden */
  35717. _lodTextureHigh: Nullable<BaseTexture>;
  35718. /** @hidden */
  35719. _lodTextureMid: Nullable<BaseTexture>;
  35720. /** @hidden */
  35721. _lodTextureLow: Nullable<BaseTexture>;
  35722. /** @hidden */
  35723. _isRGBD: boolean;
  35724. /** @hidden */
  35725. _linearSpecularLOD: boolean;
  35726. /** @hidden */
  35727. _irradianceTexture: Nullable<BaseTexture>;
  35728. /** @hidden */
  35729. _webGLTexture: Nullable<WebGLTexture>;
  35730. /** @hidden */
  35731. _references: number;
  35732. private _engine;
  35733. /**
  35734. * Gets the Engine the texture belongs to.
  35735. * @returns The babylon engine
  35736. */
  35737. getEngine(): ThinEngine;
  35738. /**
  35739. * Gets the data source type of the texture
  35740. */
  35741. get source(): InternalTextureSource;
  35742. /**
  35743. * Creates a new InternalTexture
  35744. * @param engine defines the engine to use
  35745. * @param source defines the type of data that will be used
  35746. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35747. */
  35748. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35749. /**
  35750. * Increments the number of references (ie. the number of Texture that point to it)
  35751. */
  35752. incrementReferences(): void;
  35753. /**
  35754. * Change the size of the texture (not the size of the content)
  35755. * @param width defines the new width
  35756. * @param height defines the new height
  35757. * @param depth defines the new depth (1 by default)
  35758. */
  35759. updateSize(width: int, height: int, depth?: int): void;
  35760. /** @hidden */
  35761. _rebuild(): void;
  35762. /** @hidden */
  35763. _swapAndDie(target: InternalTexture): void;
  35764. /**
  35765. * Dispose the current allocated resources
  35766. */
  35767. dispose(): void;
  35768. }
  35769. }
  35770. declare module BABYLON {
  35771. /**
  35772. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35774. */
  35775. export class Analyser {
  35776. /**
  35777. * Gets or sets the smoothing
  35778. * @ignorenaming
  35779. */
  35780. SMOOTHING: number;
  35781. /**
  35782. * Gets or sets the FFT table size
  35783. * @ignorenaming
  35784. */
  35785. FFT_SIZE: number;
  35786. /**
  35787. * Gets or sets the bar graph amplitude
  35788. * @ignorenaming
  35789. */
  35790. BARGRAPHAMPLITUDE: number;
  35791. /**
  35792. * Gets or sets the position of the debug canvas
  35793. * @ignorenaming
  35794. */
  35795. DEBUGCANVASPOS: {
  35796. x: number;
  35797. y: number;
  35798. };
  35799. /**
  35800. * Gets or sets the debug canvas size
  35801. * @ignorenaming
  35802. */
  35803. DEBUGCANVASSIZE: {
  35804. width: number;
  35805. height: number;
  35806. };
  35807. private _byteFreqs;
  35808. private _byteTime;
  35809. private _floatFreqs;
  35810. private _webAudioAnalyser;
  35811. private _debugCanvas;
  35812. private _debugCanvasContext;
  35813. private _scene;
  35814. private _registerFunc;
  35815. private _audioEngine;
  35816. /**
  35817. * Creates a new analyser
  35818. * @param scene defines hosting scene
  35819. */
  35820. constructor(scene: Scene);
  35821. /**
  35822. * Get the number of data values you will have to play with for the visualization
  35823. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35824. * @returns a number
  35825. */
  35826. getFrequencyBinCount(): number;
  35827. /**
  35828. * Gets the current frequency data as a byte array
  35829. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35830. * @returns a Uint8Array
  35831. */
  35832. getByteFrequencyData(): Uint8Array;
  35833. /**
  35834. * Gets the current waveform as a byte array
  35835. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35836. * @returns a Uint8Array
  35837. */
  35838. getByteTimeDomainData(): Uint8Array;
  35839. /**
  35840. * Gets the current frequency data as a float array
  35841. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35842. * @returns a Float32Array
  35843. */
  35844. getFloatFrequencyData(): Float32Array;
  35845. /**
  35846. * Renders the debug canvas
  35847. */
  35848. drawDebugCanvas(): void;
  35849. /**
  35850. * Stops rendering the debug canvas and removes it
  35851. */
  35852. stopDebugCanvas(): void;
  35853. /**
  35854. * Connects two audio nodes
  35855. * @param inputAudioNode defines first node to connect
  35856. * @param outputAudioNode defines second node to connect
  35857. */
  35858. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35859. /**
  35860. * Releases all associated resources
  35861. */
  35862. dispose(): void;
  35863. }
  35864. }
  35865. declare module BABYLON {
  35866. /**
  35867. * This represents an audio engine and it is responsible
  35868. * to play, synchronize and analyse sounds throughout the application.
  35869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35870. */
  35871. export interface IAudioEngine extends IDisposable {
  35872. /**
  35873. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35874. */
  35875. readonly canUseWebAudio: boolean;
  35876. /**
  35877. * Gets the current AudioContext if available.
  35878. */
  35879. readonly audioContext: Nullable<AudioContext>;
  35880. /**
  35881. * The master gain node defines the global audio volume of your audio engine.
  35882. */
  35883. readonly masterGain: GainNode;
  35884. /**
  35885. * Gets whether or not mp3 are supported by your browser.
  35886. */
  35887. readonly isMP3supported: boolean;
  35888. /**
  35889. * Gets whether or not ogg are supported by your browser.
  35890. */
  35891. readonly isOGGsupported: boolean;
  35892. /**
  35893. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35894. * @ignoreNaming
  35895. */
  35896. WarnedWebAudioUnsupported: boolean;
  35897. /**
  35898. * Defines if the audio engine relies on a custom unlocked button.
  35899. * In this case, the embedded button will not be displayed.
  35900. */
  35901. useCustomUnlockedButton: boolean;
  35902. /**
  35903. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35904. */
  35905. readonly unlocked: boolean;
  35906. /**
  35907. * Event raised when audio has been unlocked on the browser.
  35908. */
  35909. onAudioUnlockedObservable: Observable<AudioEngine>;
  35910. /**
  35911. * Event raised when audio has been locked on the browser.
  35912. */
  35913. onAudioLockedObservable: Observable<AudioEngine>;
  35914. /**
  35915. * Flags the audio engine in Locked state.
  35916. * This happens due to new browser policies preventing audio to autoplay.
  35917. */
  35918. lock(): void;
  35919. /**
  35920. * Unlocks the audio engine once a user action has been done on the dom.
  35921. * This is helpful to resume play once browser policies have been satisfied.
  35922. */
  35923. unlock(): void;
  35924. /**
  35925. * Gets the global volume sets on the master gain.
  35926. * @returns the global volume if set or -1 otherwise
  35927. */
  35928. getGlobalVolume(): number;
  35929. /**
  35930. * Sets the global volume of your experience (sets on the master gain).
  35931. * @param newVolume Defines the new global volume of the application
  35932. */
  35933. setGlobalVolume(newVolume: number): void;
  35934. /**
  35935. * Connect the audio engine to an audio analyser allowing some amazing
  35936. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35938. * @param analyser The analyser to connect to the engine
  35939. */
  35940. connectToAnalyser(analyser: Analyser): void;
  35941. }
  35942. /**
  35943. * This represents the default audio engine used in babylon.
  35944. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35946. */
  35947. export class AudioEngine implements IAudioEngine {
  35948. private _audioContext;
  35949. private _audioContextInitialized;
  35950. private _muteButton;
  35951. private _hostElement;
  35952. /**
  35953. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35954. */
  35955. canUseWebAudio: boolean;
  35956. /**
  35957. * The master gain node defines the global audio volume of your audio engine.
  35958. */
  35959. masterGain: GainNode;
  35960. /**
  35961. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35962. * @ignoreNaming
  35963. */
  35964. WarnedWebAudioUnsupported: boolean;
  35965. /**
  35966. * Gets whether or not mp3 are supported by your browser.
  35967. */
  35968. isMP3supported: boolean;
  35969. /**
  35970. * Gets whether or not ogg are supported by your browser.
  35971. */
  35972. isOGGsupported: boolean;
  35973. /**
  35974. * Gets whether audio has been unlocked on the device.
  35975. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35976. * a user interaction has happened.
  35977. */
  35978. unlocked: boolean;
  35979. /**
  35980. * Defines if the audio engine relies on a custom unlocked button.
  35981. * In this case, the embedded button will not be displayed.
  35982. */
  35983. useCustomUnlockedButton: boolean;
  35984. /**
  35985. * Event raised when audio has been unlocked on the browser.
  35986. */
  35987. onAudioUnlockedObservable: Observable<AudioEngine>;
  35988. /**
  35989. * Event raised when audio has been locked on the browser.
  35990. */
  35991. onAudioLockedObservable: Observable<AudioEngine>;
  35992. /**
  35993. * Gets the current AudioContext if available.
  35994. */
  35995. get audioContext(): Nullable<AudioContext>;
  35996. private _connectedAnalyser;
  35997. /**
  35998. * Instantiates a new audio engine.
  35999. *
  36000. * There should be only one per page as some browsers restrict the number
  36001. * of audio contexts you can create.
  36002. * @param hostElement defines the host element where to display the mute icon if necessary
  36003. */
  36004. constructor(hostElement?: Nullable<HTMLElement>);
  36005. /**
  36006. * Flags the audio engine in Locked state.
  36007. * This happens due to new browser policies preventing audio to autoplay.
  36008. */
  36009. lock(): void;
  36010. /**
  36011. * Unlocks the audio engine once a user action has been done on the dom.
  36012. * This is helpful to resume play once browser policies have been satisfied.
  36013. */
  36014. unlock(): void;
  36015. private _resumeAudioContext;
  36016. private _initializeAudioContext;
  36017. private _tryToRun;
  36018. private _triggerRunningState;
  36019. private _triggerSuspendedState;
  36020. private _displayMuteButton;
  36021. private _moveButtonToTopLeft;
  36022. private _onResize;
  36023. private _hideMuteButton;
  36024. /**
  36025. * Destroy and release the resources associated with the audio ccontext.
  36026. */
  36027. dispose(): void;
  36028. /**
  36029. * Gets the global volume sets on the master gain.
  36030. * @returns the global volume if set or -1 otherwise
  36031. */
  36032. getGlobalVolume(): number;
  36033. /**
  36034. * Sets the global volume of your experience (sets on the master gain).
  36035. * @param newVolume Defines the new global volume of the application
  36036. */
  36037. setGlobalVolume(newVolume: number): void;
  36038. /**
  36039. * Connect the audio engine to an audio analyser allowing some amazing
  36040. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36042. * @param analyser The analyser to connect to the engine
  36043. */
  36044. connectToAnalyser(analyser: Analyser): void;
  36045. }
  36046. }
  36047. declare module BABYLON {
  36048. /**
  36049. * Interface used to present a loading screen while loading a scene
  36050. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36051. */
  36052. export interface ILoadingScreen {
  36053. /**
  36054. * Function called to display the loading screen
  36055. */
  36056. displayLoadingUI: () => void;
  36057. /**
  36058. * Function called to hide the loading screen
  36059. */
  36060. hideLoadingUI: () => void;
  36061. /**
  36062. * Gets or sets the color to use for the background
  36063. */
  36064. loadingUIBackgroundColor: string;
  36065. /**
  36066. * Gets or sets the text to display while loading
  36067. */
  36068. loadingUIText: string;
  36069. }
  36070. /**
  36071. * Class used for the default loading screen
  36072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36073. */
  36074. export class DefaultLoadingScreen implements ILoadingScreen {
  36075. private _renderingCanvas;
  36076. private _loadingText;
  36077. private _loadingDivBackgroundColor;
  36078. private _loadingDiv;
  36079. private _loadingTextDiv;
  36080. /** Gets or sets the logo url to use for the default loading screen */
  36081. static DefaultLogoUrl: string;
  36082. /** Gets or sets the spinner url to use for the default loading screen */
  36083. static DefaultSpinnerUrl: string;
  36084. /**
  36085. * Creates a new default loading screen
  36086. * @param _renderingCanvas defines the canvas used to render the scene
  36087. * @param _loadingText defines the default text to display
  36088. * @param _loadingDivBackgroundColor defines the default background color
  36089. */
  36090. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36091. /**
  36092. * Function called to display the loading screen
  36093. */
  36094. displayLoadingUI(): void;
  36095. /**
  36096. * Function called to hide the loading screen
  36097. */
  36098. hideLoadingUI(): void;
  36099. /**
  36100. * Gets or sets the text to display while loading
  36101. */
  36102. set loadingUIText(text: string);
  36103. get loadingUIText(): string;
  36104. /**
  36105. * Gets or sets the color to use for the background
  36106. */
  36107. get loadingUIBackgroundColor(): string;
  36108. set loadingUIBackgroundColor(color: string);
  36109. private _resizeLoadingUI;
  36110. }
  36111. }
  36112. declare module BABYLON {
  36113. /**
  36114. * Interface for any object that can request an animation frame
  36115. */
  36116. export interface ICustomAnimationFrameRequester {
  36117. /**
  36118. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36119. */
  36120. renderFunction?: Function;
  36121. /**
  36122. * Called to request the next frame to render to
  36123. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36124. */
  36125. requestAnimationFrame: Function;
  36126. /**
  36127. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36128. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36129. */
  36130. requestID?: number;
  36131. }
  36132. }
  36133. declare module BABYLON {
  36134. /**
  36135. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36136. */
  36137. export class PerformanceMonitor {
  36138. private _enabled;
  36139. private _rollingFrameTime;
  36140. private _lastFrameTimeMs;
  36141. /**
  36142. * constructor
  36143. * @param frameSampleSize The number of samples required to saturate the sliding window
  36144. */
  36145. constructor(frameSampleSize?: number);
  36146. /**
  36147. * Samples current frame
  36148. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36149. */
  36150. sampleFrame(timeMs?: number): void;
  36151. /**
  36152. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36153. */
  36154. get averageFrameTime(): number;
  36155. /**
  36156. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36157. */
  36158. get averageFrameTimeVariance(): number;
  36159. /**
  36160. * Returns the frame time of the most recent frame
  36161. */
  36162. get instantaneousFrameTime(): number;
  36163. /**
  36164. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36165. */
  36166. get averageFPS(): number;
  36167. /**
  36168. * Returns the average framerate in frames per second using the most recent frame time
  36169. */
  36170. get instantaneousFPS(): number;
  36171. /**
  36172. * Returns true if enough samples have been taken to completely fill the sliding window
  36173. */
  36174. get isSaturated(): boolean;
  36175. /**
  36176. * Enables contributions to the sliding window sample set
  36177. */
  36178. enable(): void;
  36179. /**
  36180. * Disables contributions to the sliding window sample set
  36181. * Samples will not be interpolated over the disabled period
  36182. */
  36183. disable(): void;
  36184. /**
  36185. * Returns true if sampling is enabled
  36186. */
  36187. get isEnabled(): boolean;
  36188. /**
  36189. * Resets performance monitor
  36190. */
  36191. reset(): void;
  36192. }
  36193. /**
  36194. * RollingAverage
  36195. *
  36196. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36197. */
  36198. export class RollingAverage {
  36199. /**
  36200. * Current average
  36201. */
  36202. average: number;
  36203. /**
  36204. * Current variance
  36205. */
  36206. variance: number;
  36207. protected _samples: Array<number>;
  36208. protected _sampleCount: number;
  36209. protected _pos: number;
  36210. protected _m2: number;
  36211. /**
  36212. * constructor
  36213. * @param length The number of samples required to saturate the sliding window
  36214. */
  36215. constructor(length: number);
  36216. /**
  36217. * Adds a sample to the sample set
  36218. * @param v The sample value
  36219. */
  36220. add(v: number): void;
  36221. /**
  36222. * Returns previously added values or null if outside of history or outside the sliding window domain
  36223. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36224. * @return Value previously recorded with add() or null if outside of range
  36225. */
  36226. history(i: number): number;
  36227. /**
  36228. * Returns true if enough samples have been taken to completely fill the sliding window
  36229. * @return true if sample-set saturated
  36230. */
  36231. isSaturated(): boolean;
  36232. /**
  36233. * Resets the rolling average (equivalent to 0 samples taken so far)
  36234. */
  36235. reset(): void;
  36236. /**
  36237. * Wraps a value around the sample range boundaries
  36238. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36239. * @return Wrapped position in sample range
  36240. */
  36241. protected _wrapPosition(i: number): number;
  36242. }
  36243. }
  36244. declare module BABYLON {
  36245. /**
  36246. * This class is used to track a performance counter which is number based.
  36247. * The user has access to many properties which give statistics of different nature.
  36248. *
  36249. * The implementer can track two kinds of Performance Counter: time and count.
  36250. * 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.
  36251. * 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.
  36252. */
  36253. export class PerfCounter {
  36254. /**
  36255. * Gets or sets a global boolean to turn on and off all the counters
  36256. */
  36257. static Enabled: boolean;
  36258. /**
  36259. * Returns the smallest value ever
  36260. */
  36261. get min(): number;
  36262. /**
  36263. * Returns the biggest value ever
  36264. */
  36265. get max(): number;
  36266. /**
  36267. * Returns the average value since the performance counter is running
  36268. */
  36269. get average(): number;
  36270. /**
  36271. * Returns the average value of the last second the counter was monitored
  36272. */
  36273. get lastSecAverage(): number;
  36274. /**
  36275. * Returns the current value
  36276. */
  36277. get current(): number;
  36278. /**
  36279. * Gets the accumulated total
  36280. */
  36281. get total(): number;
  36282. /**
  36283. * Gets the total value count
  36284. */
  36285. get count(): number;
  36286. /**
  36287. * Creates a new counter
  36288. */
  36289. constructor();
  36290. /**
  36291. * Call this method to start monitoring a new frame.
  36292. * 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.
  36293. */
  36294. fetchNewFrame(): void;
  36295. /**
  36296. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36297. * @param newCount the count value to add to the monitored count
  36298. * @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.
  36299. */
  36300. addCount(newCount: number, fetchResult: boolean): void;
  36301. /**
  36302. * Start monitoring this performance counter
  36303. */
  36304. beginMonitoring(): void;
  36305. /**
  36306. * Compute the time lapsed since the previous beginMonitoring() call.
  36307. * @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
  36308. */
  36309. endMonitoring(newFrame?: boolean): void;
  36310. private _fetchResult;
  36311. private _startMonitoringTime;
  36312. private _min;
  36313. private _max;
  36314. private _average;
  36315. private _current;
  36316. private _totalValueCount;
  36317. private _totalAccumulated;
  36318. private _lastSecAverage;
  36319. private _lastSecAccumulated;
  36320. private _lastSecTime;
  36321. private _lastSecValueCount;
  36322. }
  36323. }
  36324. declare module BABYLON {
  36325. interface ThinEngine {
  36326. /**
  36327. * Sets alpha constants used by some alpha blending modes
  36328. * @param r defines the red component
  36329. * @param g defines the green component
  36330. * @param b defines the blue component
  36331. * @param a defines the alpha component
  36332. */
  36333. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36334. /**
  36335. * Sets the current alpha mode
  36336. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36337. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36338. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36339. */
  36340. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36341. /**
  36342. * Gets the current alpha mode
  36343. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36344. * @returns the current alpha mode
  36345. */
  36346. getAlphaMode(): number;
  36347. /**
  36348. * Sets the current alpha equation
  36349. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36350. */
  36351. setAlphaEquation(equation: number): void;
  36352. /**
  36353. * Gets the current alpha equation.
  36354. * @returns the current alpha equation
  36355. */
  36356. getAlphaEquation(): number;
  36357. }
  36358. }
  36359. declare module BABYLON {
  36360. interface ThinEngine {
  36361. /** @hidden */
  36362. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36363. }
  36364. }
  36365. declare module BABYLON {
  36366. /**
  36367. * Defines the interface used by display changed events
  36368. */
  36369. export interface IDisplayChangedEventArgs {
  36370. /** Gets the vrDisplay object (if any) */
  36371. vrDisplay: Nullable<any>;
  36372. /** Gets a boolean indicating if webVR is supported */
  36373. vrSupported: boolean;
  36374. }
  36375. /**
  36376. * Defines the interface used by objects containing a viewport (like a camera)
  36377. */
  36378. interface IViewportOwnerLike {
  36379. /**
  36380. * Gets or sets the viewport
  36381. */
  36382. viewport: IViewportLike;
  36383. }
  36384. /**
  36385. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36386. */
  36387. export class Engine extends ThinEngine {
  36388. /** Defines that alpha blending is disabled */
  36389. static readonly ALPHA_DISABLE: number;
  36390. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36391. static readonly ALPHA_ADD: number;
  36392. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36393. static readonly ALPHA_COMBINE: number;
  36394. /** Defines that alpha blending to DEST - SRC * DEST */
  36395. static readonly ALPHA_SUBTRACT: number;
  36396. /** Defines that alpha blending to SRC * DEST */
  36397. static readonly ALPHA_MULTIPLY: number;
  36398. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36399. static readonly ALPHA_MAXIMIZED: number;
  36400. /** Defines that alpha blending to SRC + DEST */
  36401. static readonly ALPHA_ONEONE: number;
  36402. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36403. static readonly ALPHA_PREMULTIPLIED: number;
  36404. /**
  36405. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36406. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36407. */
  36408. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36409. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36410. static readonly ALPHA_INTERPOLATE: number;
  36411. /**
  36412. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36413. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36414. */
  36415. static readonly ALPHA_SCREENMODE: number;
  36416. /** Defines that the ressource is not delayed*/
  36417. static readonly DELAYLOADSTATE_NONE: number;
  36418. /** Defines that the ressource was successfully delay loaded */
  36419. static readonly DELAYLOADSTATE_LOADED: number;
  36420. /** Defines that the ressource is currently delay loading */
  36421. static readonly DELAYLOADSTATE_LOADING: number;
  36422. /** Defines that the ressource is delayed and has not started loading */
  36423. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36425. static readonly NEVER: number;
  36426. /** 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 */
  36427. static readonly ALWAYS: number;
  36428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36429. static readonly LESS: number;
  36430. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36431. static readonly EQUAL: number;
  36432. /** 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 */
  36433. static readonly LEQUAL: number;
  36434. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36435. static readonly GREATER: number;
  36436. /** 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 */
  36437. static readonly GEQUAL: number;
  36438. /** 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 */
  36439. static readonly NOTEQUAL: number;
  36440. /** Passed to stencilOperation to specify that stencil value must be kept */
  36441. static readonly KEEP: number;
  36442. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36443. static readonly REPLACE: number;
  36444. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36445. static readonly INCR: number;
  36446. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36447. static readonly DECR: number;
  36448. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36449. static readonly INVERT: number;
  36450. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36451. static readonly INCR_WRAP: number;
  36452. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36453. static readonly DECR_WRAP: number;
  36454. /** Texture is not repeating outside of 0..1 UVs */
  36455. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36456. /** Texture is repeating outside of 0..1 UVs */
  36457. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36458. /** Texture is repeating and mirrored */
  36459. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36460. /** ALPHA */
  36461. static readonly TEXTUREFORMAT_ALPHA: number;
  36462. /** LUMINANCE */
  36463. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36464. /** LUMINANCE_ALPHA */
  36465. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36466. /** RGB */
  36467. static readonly TEXTUREFORMAT_RGB: number;
  36468. /** RGBA */
  36469. static readonly TEXTUREFORMAT_RGBA: number;
  36470. /** RED */
  36471. static readonly TEXTUREFORMAT_RED: number;
  36472. /** RED (2nd reference) */
  36473. static readonly TEXTUREFORMAT_R: number;
  36474. /** RG */
  36475. static readonly TEXTUREFORMAT_RG: number;
  36476. /** RED_INTEGER */
  36477. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36478. /** RED_INTEGER (2nd reference) */
  36479. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36480. /** RG_INTEGER */
  36481. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36482. /** RGB_INTEGER */
  36483. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36484. /** RGBA_INTEGER */
  36485. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36486. /** UNSIGNED_BYTE */
  36487. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36488. /** UNSIGNED_BYTE (2nd reference) */
  36489. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36490. /** FLOAT */
  36491. static readonly TEXTURETYPE_FLOAT: number;
  36492. /** HALF_FLOAT */
  36493. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36494. /** BYTE */
  36495. static readonly TEXTURETYPE_BYTE: number;
  36496. /** SHORT */
  36497. static readonly TEXTURETYPE_SHORT: number;
  36498. /** UNSIGNED_SHORT */
  36499. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36500. /** INT */
  36501. static readonly TEXTURETYPE_INT: number;
  36502. /** UNSIGNED_INT */
  36503. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36504. /** UNSIGNED_SHORT_4_4_4_4 */
  36505. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36506. /** UNSIGNED_SHORT_5_5_5_1 */
  36507. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36508. /** UNSIGNED_SHORT_5_6_5 */
  36509. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36510. /** UNSIGNED_INT_2_10_10_10_REV */
  36511. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36512. /** UNSIGNED_INT_24_8 */
  36513. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36514. /** UNSIGNED_INT_10F_11F_11F_REV */
  36515. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36516. /** UNSIGNED_INT_5_9_9_9_REV */
  36517. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36518. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36519. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36520. /** nearest is mag = nearest and min = nearest and mip = linear */
  36521. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36523. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36524. /** Trilinear is mag = linear and min = linear and mip = linear */
  36525. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36526. /** nearest is mag = nearest and min = nearest and mip = linear */
  36527. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36528. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36529. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36530. /** Trilinear is mag = linear and min = linear and mip = linear */
  36531. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36532. /** mag = nearest and min = nearest and mip = nearest */
  36533. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36534. /** mag = nearest and min = linear and mip = nearest */
  36535. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36536. /** mag = nearest and min = linear and mip = linear */
  36537. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36538. /** mag = nearest and min = linear and mip = none */
  36539. static readonly TEXTURE_NEAREST_LINEAR: number;
  36540. /** mag = nearest and min = nearest and mip = none */
  36541. static readonly TEXTURE_NEAREST_NEAREST: number;
  36542. /** mag = linear and min = nearest and mip = nearest */
  36543. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36544. /** mag = linear and min = nearest and mip = linear */
  36545. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36546. /** mag = linear and min = linear and mip = none */
  36547. static readonly TEXTURE_LINEAR_LINEAR: number;
  36548. /** mag = linear and min = nearest and mip = none */
  36549. static readonly TEXTURE_LINEAR_NEAREST: number;
  36550. /** Explicit coordinates mode */
  36551. static readonly TEXTURE_EXPLICIT_MODE: number;
  36552. /** Spherical coordinates mode */
  36553. static readonly TEXTURE_SPHERICAL_MODE: number;
  36554. /** Planar coordinates mode */
  36555. static readonly TEXTURE_PLANAR_MODE: number;
  36556. /** Cubic coordinates mode */
  36557. static readonly TEXTURE_CUBIC_MODE: number;
  36558. /** Projection coordinates mode */
  36559. static readonly TEXTURE_PROJECTION_MODE: number;
  36560. /** Skybox coordinates mode */
  36561. static readonly TEXTURE_SKYBOX_MODE: number;
  36562. /** Inverse Cubic coordinates mode */
  36563. static readonly TEXTURE_INVCUBIC_MODE: number;
  36564. /** Equirectangular coordinates mode */
  36565. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36566. /** Equirectangular Fixed coordinates mode */
  36567. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36568. /** Equirectangular Fixed Mirrored coordinates mode */
  36569. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36570. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36571. static readonly SCALEMODE_FLOOR: number;
  36572. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36573. static readonly SCALEMODE_NEAREST: number;
  36574. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36575. static readonly SCALEMODE_CEILING: number;
  36576. /**
  36577. * Returns the current npm package of the sdk
  36578. */
  36579. static get NpmPackage(): string;
  36580. /**
  36581. * Returns the current version of the framework
  36582. */
  36583. static get Version(): string;
  36584. /** Gets the list of created engines */
  36585. static get Instances(): Engine[];
  36586. /**
  36587. * Gets the latest created engine
  36588. */
  36589. static get LastCreatedEngine(): Nullable<Engine>;
  36590. /**
  36591. * Gets the latest created scene
  36592. */
  36593. static get LastCreatedScene(): Nullable<Scene>;
  36594. /**
  36595. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36596. * @param flag defines which part of the materials must be marked as dirty
  36597. * @param predicate defines a predicate used to filter which materials should be affected
  36598. */
  36599. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36600. /**
  36601. * Method called to create the default loading screen.
  36602. * This can be overriden in your own app.
  36603. * @param canvas The rendering canvas element
  36604. * @returns The loading screen
  36605. */
  36606. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36607. /**
  36608. * Method called to create the default rescale post process on each engine.
  36609. */
  36610. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36611. /**
  36612. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36613. **/
  36614. enableOfflineSupport: boolean;
  36615. /**
  36616. * 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)
  36617. **/
  36618. disableManifestCheck: boolean;
  36619. /**
  36620. * Gets the list of created scenes
  36621. */
  36622. scenes: Scene[];
  36623. /**
  36624. * Event raised when a new scene is created
  36625. */
  36626. onNewSceneAddedObservable: Observable<Scene>;
  36627. /**
  36628. * Gets the list of created postprocesses
  36629. */
  36630. postProcesses: PostProcess[];
  36631. /**
  36632. * Gets a boolean indicating if the pointer is currently locked
  36633. */
  36634. isPointerLock: boolean;
  36635. /**
  36636. * Observable event triggered each time the rendering canvas is resized
  36637. */
  36638. onResizeObservable: Observable<Engine>;
  36639. /**
  36640. * Observable event triggered each time the canvas loses focus
  36641. */
  36642. onCanvasBlurObservable: Observable<Engine>;
  36643. /**
  36644. * Observable event triggered each time the canvas gains focus
  36645. */
  36646. onCanvasFocusObservable: Observable<Engine>;
  36647. /**
  36648. * Observable event triggered each time the canvas receives pointerout event
  36649. */
  36650. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36651. /**
  36652. * Observable raised when the engine begins a new frame
  36653. */
  36654. onBeginFrameObservable: Observable<Engine>;
  36655. /**
  36656. * If set, will be used to request the next animation frame for the render loop
  36657. */
  36658. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36659. /**
  36660. * Observable raised when the engine ends the current frame
  36661. */
  36662. onEndFrameObservable: Observable<Engine>;
  36663. /**
  36664. * Observable raised when the engine is about to compile a shader
  36665. */
  36666. onBeforeShaderCompilationObservable: Observable<Engine>;
  36667. /**
  36668. * Observable raised when the engine has jsut compiled a shader
  36669. */
  36670. onAfterShaderCompilationObservable: Observable<Engine>;
  36671. /**
  36672. * Gets the audio engine
  36673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36674. * @ignorenaming
  36675. */
  36676. static audioEngine: IAudioEngine;
  36677. /**
  36678. * Default AudioEngine factory responsible of creating the Audio Engine.
  36679. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36680. */
  36681. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36682. /**
  36683. * Default offline support factory responsible of creating a tool used to store data locally.
  36684. * By default, this will create a Database object if the workload has been embedded.
  36685. */
  36686. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36687. private _loadingScreen;
  36688. private _pointerLockRequested;
  36689. private _rescalePostProcess;
  36690. private _deterministicLockstep;
  36691. private _lockstepMaxSteps;
  36692. private _timeStep;
  36693. protected get _supportsHardwareTextureRescaling(): boolean;
  36694. private _fps;
  36695. private _deltaTime;
  36696. /** @hidden */
  36697. _drawCalls: PerfCounter;
  36698. /** 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 */
  36699. canvasTabIndex: number;
  36700. /**
  36701. * Turn this value on if you want to pause FPS computation when in background
  36702. */
  36703. disablePerformanceMonitorInBackground: boolean;
  36704. private _performanceMonitor;
  36705. /**
  36706. * Gets the performance monitor attached to this engine
  36707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36708. */
  36709. get performanceMonitor(): PerformanceMonitor;
  36710. private _onFocus;
  36711. private _onBlur;
  36712. private _onCanvasPointerOut;
  36713. private _onCanvasBlur;
  36714. private _onCanvasFocus;
  36715. private _onFullscreenChange;
  36716. private _onPointerLockChange;
  36717. /**
  36718. * Gets the HTML element used to attach event listeners
  36719. * @returns a HTML element
  36720. */
  36721. getInputElement(): Nullable<HTMLElement>;
  36722. /**
  36723. * Creates a new engine
  36724. * @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
  36725. * @param antialias defines enable antialiasing (default: false)
  36726. * @param options defines further options to be sent to the getContext() function
  36727. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36728. */
  36729. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36730. /**
  36731. * Gets current aspect ratio
  36732. * @param viewportOwner defines the camera to use to get the aspect ratio
  36733. * @param useScreen defines if screen size must be used (or the current render target if any)
  36734. * @returns a number defining the aspect ratio
  36735. */
  36736. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36737. /**
  36738. * Gets current screen aspect ratio
  36739. * @returns a number defining the aspect ratio
  36740. */
  36741. getScreenAspectRatio(): number;
  36742. /**
  36743. * Gets the client rect of the HTML canvas attached with the current webGL context
  36744. * @returns a client rectanglee
  36745. */
  36746. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36747. /**
  36748. * Gets the client rect of the HTML element used for events
  36749. * @returns a client rectanglee
  36750. */
  36751. getInputElementClientRect(): Nullable<ClientRect>;
  36752. /**
  36753. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36754. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36755. * @returns true if engine is in deterministic lock step mode
  36756. */
  36757. isDeterministicLockStep(): boolean;
  36758. /**
  36759. * Gets the max steps when engine is running in deterministic lock step
  36760. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36761. * @returns the max steps
  36762. */
  36763. getLockstepMaxSteps(): number;
  36764. /**
  36765. * Returns the time in ms between steps when using deterministic lock step.
  36766. * @returns time step in (ms)
  36767. */
  36768. getTimeStep(): number;
  36769. /**
  36770. * Force the mipmap generation for the given render target texture
  36771. * @param texture defines the render target texture to use
  36772. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36773. */
  36774. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36775. /** States */
  36776. /**
  36777. * Set various states to the webGL context
  36778. * @param culling defines backface culling state
  36779. * @param zOffset defines the value to apply to zOffset (0 by default)
  36780. * @param force defines if states must be applied even if cache is up to date
  36781. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36782. */
  36783. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36784. /**
  36785. * Set the z offset to apply to current rendering
  36786. * @param value defines the offset to apply
  36787. */
  36788. setZOffset(value: number): void;
  36789. /**
  36790. * Gets the current value of the zOffset
  36791. * @returns the current zOffset state
  36792. */
  36793. getZOffset(): number;
  36794. /**
  36795. * Enable or disable depth buffering
  36796. * @param enable defines the state to set
  36797. */
  36798. setDepthBuffer(enable: boolean): void;
  36799. /**
  36800. * Gets a boolean indicating if depth writing is enabled
  36801. * @returns the current depth writing state
  36802. */
  36803. getDepthWrite(): boolean;
  36804. /**
  36805. * Enable or disable depth writing
  36806. * @param enable defines the state to set
  36807. */
  36808. setDepthWrite(enable: boolean): void;
  36809. /**
  36810. * Gets a boolean indicating if stencil buffer is enabled
  36811. * @returns the current stencil buffer state
  36812. */
  36813. getStencilBuffer(): boolean;
  36814. /**
  36815. * Enable or disable the stencil buffer
  36816. * @param enable defines if the stencil buffer must be enabled or disabled
  36817. */
  36818. setStencilBuffer(enable: boolean): void;
  36819. /**
  36820. * Gets the current stencil mask
  36821. * @returns a number defining the new stencil mask to use
  36822. */
  36823. getStencilMask(): number;
  36824. /**
  36825. * Sets the current stencil mask
  36826. * @param mask defines the new stencil mask to use
  36827. */
  36828. setStencilMask(mask: number): void;
  36829. /**
  36830. * Gets the current stencil function
  36831. * @returns a number defining the stencil function to use
  36832. */
  36833. getStencilFunction(): number;
  36834. /**
  36835. * Gets the current stencil reference value
  36836. * @returns a number defining the stencil reference value to use
  36837. */
  36838. getStencilFunctionReference(): number;
  36839. /**
  36840. * Gets the current stencil mask
  36841. * @returns a number defining the stencil mask to use
  36842. */
  36843. getStencilFunctionMask(): number;
  36844. /**
  36845. * Sets the current stencil function
  36846. * @param stencilFunc defines the new stencil function to use
  36847. */
  36848. setStencilFunction(stencilFunc: number): void;
  36849. /**
  36850. * Sets the current stencil reference
  36851. * @param reference defines the new stencil reference to use
  36852. */
  36853. setStencilFunctionReference(reference: number): void;
  36854. /**
  36855. * Sets the current stencil mask
  36856. * @param mask defines the new stencil mask to use
  36857. */
  36858. setStencilFunctionMask(mask: number): void;
  36859. /**
  36860. * Gets the current stencil operation when stencil fails
  36861. * @returns a number defining stencil operation to use when stencil fails
  36862. */
  36863. getStencilOperationFail(): number;
  36864. /**
  36865. * Gets the current stencil operation when depth fails
  36866. * @returns a number defining stencil operation to use when depth fails
  36867. */
  36868. getStencilOperationDepthFail(): number;
  36869. /**
  36870. * Gets the current stencil operation when stencil passes
  36871. * @returns a number defining stencil operation to use when stencil passes
  36872. */
  36873. getStencilOperationPass(): number;
  36874. /**
  36875. * Sets the stencil operation to use when stencil fails
  36876. * @param operation defines the stencil operation to use when stencil fails
  36877. */
  36878. setStencilOperationFail(operation: number): void;
  36879. /**
  36880. * Sets the stencil operation to use when depth fails
  36881. * @param operation defines the stencil operation to use when depth fails
  36882. */
  36883. setStencilOperationDepthFail(operation: number): void;
  36884. /**
  36885. * Sets the stencil operation to use when stencil passes
  36886. * @param operation defines the stencil operation to use when stencil passes
  36887. */
  36888. setStencilOperationPass(operation: number): void;
  36889. /**
  36890. * Sets a boolean indicating if the dithering state is enabled or disabled
  36891. * @param value defines the dithering state
  36892. */
  36893. setDitheringState(value: boolean): void;
  36894. /**
  36895. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36896. * @param value defines the rasterizer state
  36897. */
  36898. setRasterizerState(value: boolean): void;
  36899. /**
  36900. * Gets the current depth function
  36901. * @returns a number defining the depth function
  36902. */
  36903. getDepthFunction(): Nullable<number>;
  36904. /**
  36905. * Sets the current depth function
  36906. * @param depthFunc defines the function to use
  36907. */
  36908. setDepthFunction(depthFunc: number): void;
  36909. /**
  36910. * Sets the current depth function to GREATER
  36911. */
  36912. setDepthFunctionToGreater(): void;
  36913. /**
  36914. * Sets the current depth function to GEQUAL
  36915. */
  36916. setDepthFunctionToGreaterOrEqual(): void;
  36917. /**
  36918. * Sets the current depth function to LESS
  36919. */
  36920. setDepthFunctionToLess(): void;
  36921. /**
  36922. * Sets the current depth function to LEQUAL
  36923. */
  36924. setDepthFunctionToLessOrEqual(): void;
  36925. private _cachedStencilBuffer;
  36926. private _cachedStencilFunction;
  36927. private _cachedStencilMask;
  36928. private _cachedStencilOperationPass;
  36929. private _cachedStencilOperationFail;
  36930. private _cachedStencilOperationDepthFail;
  36931. private _cachedStencilReference;
  36932. /**
  36933. * Caches the the state of the stencil buffer
  36934. */
  36935. cacheStencilState(): void;
  36936. /**
  36937. * Restores the state of the stencil buffer
  36938. */
  36939. restoreStencilState(): void;
  36940. /**
  36941. * Directly set the WebGL Viewport
  36942. * @param x defines the x coordinate of the viewport (in screen space)
  36943. * @param y defines the y coordinate of the viewport (in screen space)
  36944. * @param width defines the width of the viewport (in screen space)
  36945. * @param height defines the height of the viewport (in screen space)
  36946. * @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
  36947. */
  36948. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36949. /**
  36950. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36951. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36952. * @param y defines the y-coordinate of the corner of the clear rectangle
  36953. * @param width defines the width of the clear rectangle
  36954. * @param height defines the height of the clear rectangle
  36955. * @param clearColor defines the clear color
  36956. */
  36957. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36958. /**
  36959. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36960. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36961. * @param y defines the y-coordinate of the corner of the clear rectangle
  36962. * @param width defines the width of the clear rectangle
  36963. * @param height defines the height of the clear rectangle
  36964. */
  36965. enableScissor(x: number, y: number, width: number, height: number): void;
  36966. /**
  36967. * Disable previously set scissor test rectangle
  36968. */
  36969. disableScissor(): void;
  36970. protected _reportDrawCall(): void;
  36971. /**
  36972. * Initializes a webVR display and starts listening to display change events
  36973. * The onVRDisplayChangedObservable will be notified upon these changes
  36974. * @returns The onVRDisplayChangedObservable
  36975. */
  36976. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36977. /** @hidden */
  36978. _prepareVRComponent(): void;
  36979. /** @hidden */
  36980. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36981. /** @hidden */
  36982. _submitVRFrame(): void;
  36983. /**
  36984. * Call this function to leave webVR mode
  36985. * Will do nothing if webVR is not supported or if there is no webVR device
  36986. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36987. */
  36988. disableVR(): void;
  36989. /**
  36990. * Gets a boolean indicating that the system is in VR mode and is presenting
  36991. * @returns true if VR mode is engaged
  36992. */
  36993. isVRPresenting(): boolean;
  36994. /** @hidden */
  36995. _requestVRFrame(): void;
  36996. /** @hidden */
  36997. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36998. /**
  36999. * Gets the source code of the vertex shader associated with a specific webGL program
  37000. * @param program defines the program to use
  37001. * @returns a string containing the source code of the vertex shader associated with the program
  37002. */
  37003. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37004. /**
  37005. * Gets the source code of the fragment shader associated with a specific webGL program
  37006. * @param program defines the program to use
  37007. * @returns a string containing the source code of the fragment shader associated with the program
  37008. */
  37009. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37010. /**
  37011. * Sets a depth stencil texture from a render target to the according uniform.
  37012. * @param channel The texture channel
  37013. * @param uniform The uniform to set
  37014. * @param texture The render target texture containing the depth stencil texture to apply
  37015. */
  37016. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37017. /**
  37018. * Sets a texture to the webGL context from a postprocess
  37019. * @param channel defines the channel to use
  37020. * @param postProcess defines the source postprocess
  37021. */
  37022. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37023. /**
  37024. * Binds the output of the passed in post process to the texture channel specified
  37025. * @param channel The channel the texture should be bound to
  37026. * @param postProcess The post process which's output should be bound
  37027. */
  37028. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37029. protected _rebuildBuffers(): void;
  37030. /** @hidden */
  37031. _renderFrame(): void;
  37032. _renderLoop(): void;
  37033. /** @hidden */
  37034. _renderViews(): boolean;
  37035. /**
  37036. * Toggle full screen mode
  37037. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37038. */
  37039. switchFullscreen(requestPointerLock: boolean): void;
  37040. /**
  37041. * Enters full screen mode
  37042. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37043. */
  37044. enterFullscreen(requestPointerLock: boolean): void;
  37045. /**
  37046. * Exits full screen mode
  37047. */
  37048. exitFullscreen(): void;
  37049. /**
  37050. * Enters Pointerlock mode
  37051. */
  37052. enterPointerlock(): void;
  37053. /**
  37054. * Exits Pointerlock mode
  37055. */
  37056. exitPointerlock(): void;
  37057. /**
  37058. * Begin a new frame
  37059. */
  37060. beginFrame(): void;
  37061. /**
  37062. * Enf the current frame
  37063. */
  37064. endFrame(): void;
  37065. resize(): void;
  37066. /**
  37067. * Force a specific size of the canvas
  37068. * @param width defines the new canvas' width
  37069. * @param height defines the new canvas' height
  37070. */
  37071. setSize(width: number, height: number): void;
  37072. /**
  37073. * Updates a dynamic vertex buffer.
  37074. * @param vertexBuffer the vertex buffer to update
  37075. * @param data the data used to update the vertex buffer
  37076. * @param byteOffset the byte offset of the data
  37077. * @param byteLength the byte length of the data
  37078. */
  37079. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37080. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37081. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37082. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37083. _releaseTexture(texture: InternalTexture): void;
  37084. /**
  37085. * @hidden
  37086. * Rescales a texture
  37087. * @param source input texutre
  37088. * @param destination destination texture
  37089. * @param scene scene to use to render the resize
  37090. * @param internalFormat format to use when resizing
  37091. * @param onComplete callback to be called when resize has completed
  37092. */
  37093. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37094. /**
  37095. * Gets the current framerate
  37096. * @returns a number representing the framerate
  37097. */
  37098. getFps(): number;
  37099. /**
  37100. * Gets the time spent between current and previous frame
  37101. * @returns a number representing the delta time in ms
  37102. */
  37103. getDeltaTime(): number;
  37104. private _measureFps;
  37105. /** @hidden */
  37106. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37107. /**
  37108. * Update a dynamic index buffer
  37109. * @param indexBuffer defines the target index buffer
  37110. * @param indices defines the data to update
  37111. * @param offset defines the offset in the target index buffer where update should start
  37112. */
  37113. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37114. /**
  37115. * Updates the sample count of a render target texture
  37116. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37117. * @param texture defines the texture to update
  37118. * @param samples defines the sample count to set
  37119. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37120. */
  37121. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37122. /**
  37123. * Updates a depth texture Comparison Mode and Function.
  37124. * If the comparison Function is equal to 0, the mode will be set to none.
  37125. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37126. * @param texture The texture to set the comparison function for
  37127. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37128. */
  37129. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37130. /**
  37131. * Creates a webGL buffer to use with instanciation
  37132. * @param capacity defines the size of the buffer
  37133. * @returns the webGL buffer
  37134. */
  37135. createInstancesBuffer(capacity: number): DataBuffer;
  37136. /**
  37137. * Delete a webGL buffer used with instanciation
  37138. * @param buffer defines the webGL buffer to delete
  37139. */
  37140. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37141. private _clientWaitAsync;
  37142. /** @hidden */
  37143. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37144. dispose(): void;
  37145. private _disableTouchAction;
  37146. /**
  37147. * Display the loading screen
  37148. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37149. */
  37150. displayLoadingUI(): void;
  37151. /**
  37152. * Hide the loading screen
  37153. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37154. */
  37155. hideLoadingUI(): void;
  37156. /**
  37157. * Gets the current loading screen object
  37158. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37159. */
  37160. get loadingScreen(): ILoadingScreen;
  37161. /**
  37162. * Sets the current loading screen object
  37163. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37164. */
  37165. set loadingScreen(loadingScreen: ILoadingScreen);
  37166. /**
  37167. * Sets the current loading screen text
  37168. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37169. */
  37170. set loadingUIText(text: string);
  37171. /**
  37172. * Sets the current loading screen background color
  37173. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37174. */
  37175. set loadingUIBackgroundColor(color: string);
  37176. /** Pointerlock and fullscreen */
  37177. /**
  37178. * Ask the browser to promote the current element to pointerlock mode
  37179. * @param element defines the DOM element to promote
  37180. */
  37181. static _RequestPointerlock(element: HTMLElement): void;
  37182. /**
  37183. * Asks the browser to exit pointerlock mode
  37184. */
  37185. static _ExitPointerlock(): void;
  37186. /**
  37187. * Ask the browser to promote the current element to fullscreen rendering mode
  37188. * @param element defines the DOM element to promote
  37189. */
  37190. static _RequestFullscreen(element: HTMLElement): void;
  37191. /**
  37192. * Asks the browser to exit fullscreen mode
  37193. */
  37194. static _ExitFullscreen(): void;
  37195. }
  37196. }
  37197. declare module BABYLON {
  37198. /**
  37199. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37200. * during the life time of the application.
  37201. */
  37202. export class EngineStore {
  37203. /** Gets the list of created engines */
  37204. static Instances: Engine[];
  37205. /** @hidden */
  37206. static _LastCreatedScene: Nullable<Scene>;
  37207. /**
  37208. * Gets the latest created engine
  37209. */
  37210. static get LastCreatedEngine(): Nullable<Engine>;
  37211. /**
  37212. * Gets the latest created scene
  37213. */
  37214. static get LastCreatedScene(): Nullable<Scene>;
  37215. /**
  37216. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37217. * @ignorenaming
  37218. */
  37219. static UseFallbackTexture: boolean;
  37220. /**
  37221. * Texture content used if a texture cannot loaded
  37222. * @ignorenaming
  37223. */
  37224. static FallbackTexture: string;
  37225. }
  37226. }
  37227. declare module BABYLON {
  37228. /**
  37229. * Helper class that provides a small promise polyfill
  37230. */
  37231. export class PromisePolyfill {
  37232. /**
  37233. * Static function used to check if the polyfill is required
  37234. * If this is the case then the function will inject the polyfill to window.Promise
  37235. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37236. */
  37237. static Apply(force?: boolean): void;
  37238. }
  37239. }
  37240. declare module BABYLON {
  37241. /**
  37242. * Interface for screenshot methods with describe argument called `size` as object with options
  37243. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37244. */
  37245. export interface IScreenshotSize {
  37246. /**
  37247. * number in pixels for canvas height
  37248. */
  37249. height?: number;
  37250. /**
  37251. * multiplier allowing render at a higher or lower resolution
  37252. * If value is defined then height and width will be ignored and taken from camera
  37253. */
  37254. precision?: number;
  37255. /**
  37256. * number in pixels for canvas width
  37257. */
  37258. width?: number;
  37259. }
  37260. }
  37261. declare module BABYLON {
  37262. interface IColor4Like {
  37263. r: float;
  37264. g: float;
  37265. b: float;
  37266. a: float;
  37267. }
  37268. /**
  37269. * Class containing a set of static utilities functions
  37270. */
  37271. export class Tools {
  37272. /**
  37273. * Gets or sets the base URL to use to load assets
  37274. */
  37275. static get BaseUrl(): string;
  37276. static set BaseUrl(value: string);
  37277. /**
  37278. * Enable/Disable Custom HTTP Request Headers globally.
  37279. * default = false
  37280. * @see CustomRequestHeaders
  37281. */
  37282. static UseCustomRequestHeaders: boolean;
  37283. /**
  37284. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37285. * i.e. when loading files, where the server/service expects an Authorization header
  37286. */
  37287. static CustomRequestHeaders: {
  37288. [key: string]: string;
  37289. };
  37290. /**
  37291. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37292. */
  37293. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37294. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37295. /**
  37296. * Default behaviour for cors in the application.
  37297. * It can be a string if the expected behavior is identical in the entire app.
  37298. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37299. */
  37300. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37301. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37302. /**
  37303. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37304. * @ignorenaming
  37305. */
  37306. static get UseFallbackTexture(): boolean;
  37307. static set UseFallbackTexture(value: boolean);
  37308. /**
  37309. * Use this object to register external classes like custom textures or material
  37310. * to allow the laoders to instantiate them
  37311. */
  37312. static get RegisteredExternalClasses(): {
  37313. [key: string]: Object;
  37314. };
  37315. static set RegisteredExternalClasses(classes: {
  37316. [key: string]: Object;
  37317. });
  37318. /**
  37319. * Texture content used if a texture cannot loaded
  37320. * @ignorenaming
  37321. */
  37322. static get fallbackTexture(): string;
  37323. static set fallbackTexture(value: string);
  37324. /**
  37325. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37326. * @param u defines the coordinate on X axis
  37327. * @param v defines the coordinate on Y axis
  37328. * @param width defines the width of the source data
  37329. * @param height defines the height of the source data
  37330. * @param pixels defines the source byte array
  37331. * @param color defines the output color
  37332. */
  37333. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37334. /**
  37335. * Interpolates between a and b via alpha
  37336. * @param a The lower value (returned when alpha = 0)
  37337. * @param b The upper value (returned when alpha = 1)
  37338. * @param alpha The interpolation-factor
  37339. * @return The mixed value
  37340. */
  37341. static Mix(a: number, b: number, alpha: number): number;
  37342. /**
  37343. * Tries to instantiate a new object from a given class name
  37344. * @param className defines the class name to instantiate
  37345. * @returns the new object or null if the system was not able to do the instantiation
  37346. */
  37347. static Instantiate(className: string): any;
  37348. /**
  37349. * Provides a slice function that will work even on IE
  37350. * @param data defines the array to slice
  37351. * @param start defines the start of the data (optional)
  37352. * @param end defines the end of the data (optional)
  37353. * @returns the new sliced array
  37354. */
  37355. static Slice<T>(data: T, start?: number, end?: number): T;
  37356. /**
  37357. * Polyfill for setImmediate
  37358. * @param action defines the action to execute after the current execution block
  37359. */
  37360. static SetImmediate(action: () => void): void;
  37361. /**
  37362. * Function indicating if a number is an exponent of 2
  37363. * @param value defines the value to test
  37364. * @returns true if the value is an exponent of 2
  37365. */
  37366. static IsExponentOfTwo(value: number): boolean;
  37367. private static _tmpFloatArray;
  37368. /**
  37369. * Returns the nearest 32-bit single precision float representation of a Number
  37370. * @param value A Number. If the parameter is of a different type, it will get converted
  37371. * to a number or to NaN if it cannot be converted
  37372. * @returns number
  37373. */
  37374. static FloatRound(value: number): number;
  37375. /**
  37376. * Extracts the filename from a path
  37377. * @param path defines the path to use
  37378. * @returns the filename
  37379. */
  37380. static GetFilename(path: string): string;
  37381. /**
  37382. * Extracts the "folder" part of a path (everything before the filename).
  37383. * @param uri The URI to extract the info from
  37384. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37385. * @returns The "folder" part of the path
  37386. */
  37387. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37388. /**
  37389. * Extracts text content from a DOM element hierarchy
  37390. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37391. */
  37392. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37393. /**
  37394. * Convert an angle in radians to degrees
  37395. * @param angle defines the angle to convert
  37396. * @returns the angle in degrees
  37397. */
  37398. static ToDegrees(angle: number): number;
  37399. /**
  37400. * Convert an angle in degrees to radians
  37401. * @param angle defines the angle to convert
  37402. * @returns the angle in radians
  37403. */
  37404. static ToRadians(angle: number): number;
  37405. /**
  37406. * Returns an array if obj is not an array
  37407. * @param obj defines the object to evaluate as an array
  37408. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37409. * @returns either obj directly if obj is an array or a new array containing obj
  37410. */
  37411. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37412. /**
  37413. * Gets the pointer prefix to use
  37414. * @param engine defines the engine we are finding the prefix for
  37415. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37416. */
  37417. static GetPointerPrefix(engine: Engine): string;
  37418. /**
  37419. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37420. * @param url define the url we are trying
  37421. * @param element define the dom element where to configure the cors policy
  37422. */
  37423. static SetCorsBehavior(url: string | string[], element: {
  37424. crossOrigin: string | null;
  37425. }): void;
  37426. /**
  37427. * Removes unwanted characters from an url
  37428. * @param url defines the url to clean
  37429. * @returns the cleaned url
  37430. */
  37431. static CleanUrl(url: string): string;
  37432. /**
  37433. * Gets or sets a function used to pre-process url before using them to load assets
  37434. */
  37435. static get PreprocessUrl(): (url: string) => string;
  37436. static set PreprocessUrl(processor: (url: string) => string);
  37437. /**
  37438. * Loads an image as an HTMLImageElement.
  37439. * @param input url string, ArrayBuffer, or Blob to load
  37440. * @param onLoad callback called when the image successfully loads
  37441. * @param onError callback called when the image fails to load
  37442. * @param offlineProvider offline provider for caching
  37443. * @param mimeType optional mime type
  37444. * @returns the HTMLImageElement of the loaded image
  37445. */
  37446. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37447. /**
  37448. * Loads a file from a url
  37449. * @param url url string, ArrayBuffer, or Blob to load
  37450. * @param onSuccess callback called when the file successfully loads
  37451. * @param onProgress callback called while file is loading (if the server supports this mode)
  37452. * @param offlineProvider defines the offline provider for caching
  37453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37454. * @param onError callback called when the file fails to load
  37455. * @returns a file request object
  37456. */
  37457. 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;
  37458. /**
  37459. * Loads a file from a url
  37460. * @param url the file url to load
  37461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37462. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37463. */
  37464. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37465. /**
  37466. * Load a script (identified by an url). When the url returns, the
  37467. * content of this file is added into a new script element, attached to the DOM (body element)
  37468. * @param scriptUrl defines the url of the script to laod
  37469. * @param onSuccess defines the callback called when the script is loaded
  37470. * @param onError defines the callback to call if an error occurs
  37471. * @param scriptId defines the id of the script element
  37472. */
  37473. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37474. /**
  37475. * Load an asynchronous script (identified by an url). When the url returns, the
  37476. * content of this file is added into a new script element, attached to the DOM (body element)
  37477. * @param scriptUrl defines the url of the script to laod
  37478. * @param scriptId defines the id of the script element
  37479. * @returns a promise request object
  37480. */
  37481. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37482. /**
  37483. * Loads a file from a blob
  37484. * @param fileToLoad defines the blob to use
  37485. * @param callback defines the callback to call when data is loaded
  37486. * @param progressCallback defines the callback to call during loading process
  37487. * @returns a file request object
  37488. */
  37489. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37490. /**
  37491. * Reads a file from a File object
  37492. * @param file defines the file to load
  37493. * @param onSuccess defines the callback to call when data is loaded
  37494. * @param onProgress defines the callback to call during loading process
  37495. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37496. * @param onError defines the callback to call when an error occurs
  37497. * @returns a file request object
  37498. */
  37499. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37500. /**
  37501. * Creates a data url from a given string content
  37502. * @param content defines the content to convert
  37503. * @returns the new data url link
  37504. */
  37505. static FileAsURL(content: string): string;
  37506. /**
  37507. * Format the given number to a specific decimal format
  37508. * @param value defines the number to format
  37509. * @param decimals defines the number of decimals to use
  37510. * @returns the formatted string
  37511. */
  37512. static Format(value: number, decimals?: number): string;
  37513. /**
  37514. * Tries to copy an object by duplicating every property
  37515. * @param source defines the source object
  37516. * @param destination defines the target object
  37517. * @param doNotCopyList defines a list of properties to avoid
  37518. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37519. */
  37520. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37521. /**
  37522. * Gets a boolean indicating if the given object has no own property
  37523. * @param obj defines the object to test
  37524. * @returns true if object has no own property
  37525. */
  37526. static IsEmpty(obj: any): boolean;
  37527. /**
  37528. * Function used to register events at window level
  37529. * @param windowElement defines the Window object to use
  37530. * @param events defines the events to register
  37531. */
  37532. static RegisterTopRootEvents(windowElement: Window, events: {
  37533. name: string;
  37534. handler: Nullable<(e: FocusEvent) => any>;
  37535. }[]): void;
  37536. /**
  37537. * Function used to unregister events from window level
  37538. * @param windowElement defines the Window object to use
  37539. * @param events defines the events to unregister
  37540. */
  37541. static UnregisterTopRootEvents(windowElement: Window, events: {
  37542. name: string;
  37543. handler: Nullable<(e: FocusEvent) => any>;
  37544. }[]): void;
  37545. /**
  37546. * @ignore
  37547. */
  37548. static _ScreenshotCanvas: HTMLCanvasElement;
  37549. /**
  37550. * Dumps the current bound framebuffer
  37551. * @param width defines the rendering width
  37552. * @param height defines the rendering height
  37553. * @param engine defines the hosting engine
  37554. * @param successCallback defines the callback triggered once the data are available
  37555. * @param mimeType defines the mime type of the result
  37556. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37557. */
  37558. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37559. /**
  37560. * Converts the canvas data to blob.
  37561. * This acts as a polyfill for browsers not supporting the to blob function.
  37562. * @param canvas Defines the canvas to extract the data from
  37563. * @param successCallback Defines the callback triggered once the data are available
  37564. * @param mimeType Defines the mime type of the result
  37565. */
  37566. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37567. /**
  37568. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37569. * @param successCallback defines the callback triggered once the data are available
  37570. * @param mimeType defines the mime type of the result
  37571. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37572. */
  37573. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37574. /**
  37575. * Downloads a blob in the browser
  37576. * @param blob defines the blob to download
  37577. * @param fileName defines the name of the downloaded file
  37578. */
  37579. static Download(blob: Blob, fileName: string): void;
  37580. /**
  37581. * Captures a screenshot of the current rendering
  37582. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37583. * @param engine defines the rendering engine
  37584. * @param camera defines the source camera
  37585. * @param size This parameter can be set to a single number or to an object with the
  37586. * following (optional) properties: precision, width, height. If a single number is passed,
  37587. * it will be used for both width and height. If an object is passed, the screenshot size
  37588. * will be derived from the parameters. The precision property is a multiplier allowing
  37589. * rendering at a higher or lower resolution
  37590. * @param successCallback defines the callback receives a single parameter which contains the
  37591. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37592. * src parameter of an <img> to display it
  37593. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37594. * Check your browser for supported MIME types
  37595. */
  37596. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37597. /**
  37598. * Captures a screenshot of the current rendering
  37599. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37600. * @param engine defines the rendering engine
  37601. * @param camera defines the source camera
  37602. * @param size This parameter can be set to a single number or to an object with the
  37603. * following (optional) properties: precision, width, height. If a single number is passed,
  37604. * it will be used for both width and height. If an object is passed, the screenshot size
  37605. * will be derived from the parameters. The precision property is a multiplier allowing
  37606. * rendering at a higher or lower resolution
  37607. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37608. * Check your browser for supported MIME types
  37609. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37610. * to the src parameter of an <img> to display it
  37611. */
  37612. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37613. /**
  37614. * Generates an image screenshot from the specified camera.
  37615. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37616. * @param engine The engine to use for rendering
  37617. * @param camera The camera to use for rendering
  37618. * @param size This parameter can be set to a single number or to an object with the
  37619. * following (optional) properties: precision, width, height. If a single number is passed,
  37620. * it will be used for both width and height. If an object is passed, the screenshot size
  37621. * will be derived from the parameters. The precision property is a multiplier allowing
  37622. * rendering at a higher or lower resolution
  37623. * @param successCallback The callback receives a single parameter which contains the
  37624. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37625. * src parameter of an <img> to display it
  37626. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37627. * Check your browser for supported MIME types
  37628. * @param samples Texture samples (default: 1)
  37629. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37630. * @param fileName A name for for the downloaded file.
  37631. */
  37632. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37633. /**
  37634. * Generates an image screenshot from the specified camera.
  37635. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37636. * @param engine The engine to use for rendering
  37637. * @param camera The camera to use for rendering
  37638. * @param size This parameter can be set to a single number or to an object with the
  37639. * following (optional) properties: precision, width, height. If a single number is passed,
  37640. * it will be used for both width and height. If an object is passed, the screenshot size
  37641. * will be derived from the parameters. The precision property is a multiplier allowing
  37642. * rendering at a higher or lower resolution
  37643. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37644. * Check your browser for supported MIME types
  37645. * @param samples Texture samples (default: 1)
  37646. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37647. * @param fileName A name for for the downloaded file.
  37648. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37649. * to the src parameter of an <img> to display it
  37650. */
  37651. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37652. /**
  37653. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37654. * Be aware Math.random() could cause collisions, but:
  37655. * "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"
  37656. * @returns a pseudo random id
  37657. */
  37658. static RandomId(): string;
  37659. /**
  37660. * Test if the given uri is a base64 string
  37661. * @param uri The uri to test
  37662. * @return True if the uri is a base64 string or false otherwise
  37663. */
  37664. static IsBase64(uri: string): boolean;
  37665. /**
  37666. * Decode the given base64 uri.
  37667. * @param uri The uri to decode
  37668. * @return The decoded base64 data.
  37669. */
  37670. static DecodeBase64(uri: string): ArrayBuffer;
  37671. /**
  37672. * Gets the absolute url.
  37673. * @param url the input url
  37674. * @return the absolute url
  37675. */
  37676. static GetAbsoluteUrl(url: string): string;
  37677. /**
  37678. * No log
  37679. */
  37680. static readonly NoneLogLevel: number;
  37681. /**
  37682. * Only message logs
  37683. */
  37684. static readonly MessageLogLevel: number;
  37685. /**
  37686. * Only warning logs
  37687. */
  37688. static readonly WarningLogLevel: number;
  37689. /**
  37690. * Only error logs
  37691. */
  37692. static readonly ErrorLogLevel: number;
  37693. /**
  37694. * All logs
  37695. */
  37696. static readonly AllLogLevel: number;
  37697. /**
  37698. * Gets a value indicating the number of loading errors
  37699. * @ignorenaming
  37700. */
  37701. static get errorsCount(): number;
  37702. /**
  37703. * Callback called when a new log is added
  37704. */
  37705. static OnNewCacheEntry: (entry: string) => void;
  37706. /**
  37707. * Log a message to the console
  37708. * @param message defines the message to log
  37709. */
  37710. static Log(message: string): void;
  37711. /**
  37712. * Write a warning message to the console
  37713. * @param message defines the message to log
  37714. */
  37715. static Warn(message: string): void;
  37716. /**
  37717. * Write an error message to the console
  37718. * @param message defines the message to log
  37719. */
  37720. static Error(message: string): void;
  37721. /**
  37722. * Gets current log cache (list of logs)
  37723. */
  37724. static get LogCache(): string;
  37725. /**
  37726. * Clears the log cache
  37727. */
  37728. static ClearLogCache(): void;
  37729. /**
  37730. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37731. */
  37732. static set LogLevels(level: number);
  37733. /**
  37734. * Checks if the window object exists
  37735. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37736. */
  37737. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37738. /**
  37739. * No performance log
  37740. */
  37741. static readonly PerformanceNoneLogLevel: number;
  37742. /**
  37743. * Use user marks to log performance
  37744. */
  37745. static readonly PerformanceUserMarkLogLevel: number;
  37746. /**
  37747. * Log performance to the console
  37748. */
  37749. static readonly PerformanceConsoleLogLevel: number;
  37750. private static _performance;
  37751. /**
  37752. * Sets the current performance log level
  37753. */
  37754. static set PerformanceLogLevel(level: number);
  37755. private static _StartPerformanceCounterDisabled;
  37756. private static _EndPerformanceCounterDisabled;
  37757. private static _StartUserMark;
  37758. private static _EndUserMark;
  37759. private static _StartPerformanceConsole;
  37760. private static _EndPerformanceConsole;
  37761. /**
  37762. * Starts a performance counter
  37763. */
  37764. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37765. /**
  37766. * Ends a specific performance coutner
  37767. */
  37768. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37769. /**
  37770. * Gets either window.performance.now() if supported or Date.now() else
  37771. */
  37772. static get Now(): number;
  37773. /**
  37774. * This method will return the name of the class used to create the instance of the given object.
  37775. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37776. * @param object the object to get the class name from
  37777. * @param isType defines if the object is actually a type
  37778. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37779. */
  37780. static GetClassName(object: any, isType?: boolean): string;
  37781. /**
  37782. * Gets the first element of an array satisfying a given predicate
  37783. * @param array defines the array to browse
  37784. * @param predicate defines the predicate to use
  37785. * @returns null if not found or the element
  37786. */
  37787. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37788. /**
  37789. * This method will return the name of the full name of the class, including its owning module (if any).
  37790. * 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).
  37791. * @param object the object to get the class name from
  37792. * @param isType defines if the object is actually a type
  37793. * @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.
  37794. * @ignorenaming
  37795. */
  37796. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37797. /**
  37798. * Returns a promise that resolves after the given amount of time.
  37799. * @param delay Number of milliseconds to delay
  37800. * @returns Promise that resolves after the given amount of time
  37801. */
  37802. static DelayAsync(delay: number): Promise<void>;
  37803. /**
  37804. * Utility function to detect if the current user agent is Safari
  37805. * @returns whether or not the current user agent is safari
  37806. */
  37807. static IsSafari(): boolean;
  37808. }
  37809. /**
  37810. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37811. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37812. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37813. * @param name The name of the class, case should be preserved
  37814. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37815. */
  37816. export function className(name: string, module?: string): (target: Object) => void;
  37817. /**
  37818. * An implementation of a loop for asynchronous functions.
  37819. */
  37820. export class AsyncLoop {
  37821. /**
  37822. * Defines the number of iterations for the loop
  37823. */
  37824. iterations: number;
  37825. /**
  37826. * Defines the current index of the loop.
  37827. */
  37828. index: number;
  37829. private _done;
  37830. private _fn;
  37831. private _successCallback;
  37832. /**
  37833. * Constructor.
  37834. * @param iterations the number of iterations.
  37835. * @param func the function to run each iteration
  37836. * @param successCallback the callback that will be called upon succesful execution
  37837. * @param offset starting offset.
  37838. */
  37839. constructor(
  37840. /**
  37841. * Defines the number of iterations for the loop
  37842. */
  37843. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37844. /**
  37845. * Execute the next iteration. Must be called after the last iteration was finished.
  37846. */
  37847. executeNext(): void;
  37848. /**
  37849. * Break the loop and run the success callback.
  37850. */
  37851. breakLoop(): void;
  37852. /**
  37853. * Create and run an async loop.
  37854. * @param iterations the number of iterations.
  37855. * @param fn the function to run each iteration
  37856. * @param successCallback the callback that will be called upon succesful execution
  37857. * @param offset starting offset.
  37858. * @returns the created async loop object
  37859. */
  37860. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37861. /**
  37862. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37863. * @param iterations total number of iterations
  37864. * @param syncedIterations number of synchronous iterations in each async iteration.
  37865. * @param fn the function to call each iteration.
  37866. * @param callback a success call back that will be called when iterating stops.
  37867. * @param breakFunction a break condition (optional)
  37868. * @param timeout timeout settings for the setTimeout function. default - 0.
  37869. * @returns the created async loop object
  37870. */
  37871. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37872. }
  37873. }
  37874. declare module BABYLON {
  37875. /**
  37876. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37877. * The underlying implementation relies on an associative array to ensure the best performances.
  37878. * The value can be anything including 'null' but except 'undefined'
  37879. */
  37880. export class StringDictionary<T> {
  37881. /**
  37882. * This will clear this dictionary and copy the content from the 'source' one.
  37883. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37884. * @param source the dictionary to take the content from and copy to this dictionary
  37885. */
  37886. copyFrom(source: StringDictionary<T>): void;
  37887. /**
  37888. * Get a value based from its key
  37889. * @param key the given key to get the matching value from
  37890. * @return the value if found, otherwise undefined is returned
  37891. */
  37892. get(key: string): T | undefined;
  37893. /**
  37894. * Get a value from its key or add it if it doesn't exist.
  37895. * This method will ensure you that a given key/data will be present in the dictionary.
  37896. * @param key the given key to get the matching value from
  37897. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37898. * The factory will only be invoked if there's no data for the given key.
  37899. * @return the value corresponding to the key.
  37900. */
  37901. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37902. /**
  37903. * Get a value from its key if present in the dictionary otherwise add it
  37904. * @param key the key to get the value from
  37905. * @param val if there's no such key/value pair in the dictionary add it with this value
  37906. * @return the value corresponding to the key
  37907. */
  37908. getOrAdd(key: string, val: T): T;
  37909. /**
  37910. * Check if there's a given key in the dictionary
  37911. * @param key the key to check for
  37912. * @return true if the key is present, false otherwise
  37913. */
  37914. contains(key: string): boolean;
  37915. /**
  37916. * Add a new key and its corresponding value
  37917. * @param key the key to add
  37918. * @param value the value corresponding to the key
  37919. * @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
  37920. */
  37921. add(key: string, value: T): boolean;
  37922. /**
  37923. * Update a specific value associated to a key
  37924. * @param key defines the key to use
  37925. * @param value defines the value to store
  37926. * @returns true if the value was updated (or false if the key was not found)
  37927. */
  37928. set(key: string, value: T): boolean;
  37929. /**
  37930. * Get the element of the given key and remove it from the dictionary
  37931. * @param key defines the key to search
  37932. * @returns the value associated with the key or null if not found
  37933. */
  37934. getAndRemove(key: string): Nullable<T>;
  37935. /**
  37936. * Remove a key/value from the dictionary.
  37937. * @param key the key to remove
  37938. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37939. */
  37940. remove(key: string): boolean;
  37941. /**
  37942. * Clear the whole content of the dictionary
  37943. */
  37944. clear(): void;
  37945. /**
  37946. * Gets the current count
  37947. */
  37948. get count(): number;
  37949. /**
  37950. * Execute a callback on each key/val of the dictionary.
  37951. * Note that you can remove any element in this dictionary in the callback implementation
  37952. * @param callback the callback to execute on a given key/value pair
  37953. */
  37954. forEach(callback: (key: string, val: T) => void): void;
  37955. /**
  37956. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37957. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37958. * Note that you can remove any element in this dictionary in the callback implementation
  37959. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37960. * @returns the first item
  37961. */
  37962. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37963. private _count;
  37964. private _data;
  37965. }
  37966. }
  37967. declare module BABYLON {
  37968. /** @hidden */
  37969. export interface ICollisionCoordinator {
  37970. createCollider(): Collider;
  37971. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37972. init(scene: Scene): void;
  37973. }
  37974. /** @hidden */
  37975. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37976. private _scene;
  37977. private _scaledPosition;
  37978. private _scaledVelocity;
  37979. private _finalPosition;
  37980. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37981. createCollider(): Collider;
  37982. init(scene: Scene): void;
  37983. private _collideWithWorld;
  37984. }
  37985. }
  37986. declare module BABYLON {
  37987. /**
  37988. * Class used to manage all inputs for the scene.
  37989. */
  37990. export class InputManager {
  37991. /** The distance in pixel that you have to move to prevent some events */
  37992. static DragMovementThreshold: number;
  37993. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37994. static LongPressDelay: number;
  37995. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37996. static DoubleClickDelay: number;
  37997. /** If you need to check double click without raising a single click at first click, enable this flag */
  37998. static ExclusiveDoubleClickMode: boolean;
  37999. private _wheelEventName;
  38000. private _onPointerMove;
  38001. private _onPointerDown;
  38002. private _onPointerUp;
  38003. private _initClickEvent;
  38004. private _initActionManager;
  38005. private _delayedSimpleClick;
  38006. private _delayedSimpleClickTimeout;
  38007. private _previousDelayedSimpleClickTimeout;
  38008. private _meshPickProceed;
  38009. private _previousButtonPressed;
  38010. private _currentPickResult;
  38011. private _previousPickResult;
  38012. private _totalPointersPressed;
  38013. private _doubleClickOccured;
  38014. private _pointerOverMesh;
  38015. private _pickedDownMesh;
  38016. private _pickedUpMesh;
  38017. private _pointerX;
  38018. private _pointerY;
  38019. private _unTranslatedPointerX;
  38020. private _unTranslatedPointerY;
  38021. private _startingPointerPosition;
  38022. private _previousStartingPointerPosition;
  38023. private _startingPointerTime;
  38024. private _previousStartingPointerTime;
  38025. private _pointerCaptures;
  38026. private _onKeyDown;
  38027. private _onKeyUp;
  38028. private _onCanvasFocusObserver;
  38029. private _onCanvasBlurObserver;
  38030. private _scene;
  38031. /**
  38032. * Creates a new InputManager
  38033. * @param scene defines the hosting scene
  38034. */
  38035. constructor(scene: Scene);
  38036. /**
  38037. * Gets the mesh that is currently under the pointer
  38038. */
  38039. get meshUnderPointer(): Nullable<AbstractMesh>;
  38040. /**
  38041. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38042. */
  38043. get unTranslatedPointer(): Vector2;
  38044. /**
  38045. * Gets or sets the current on-screen X position of the pointer
  38046. */
  38047. get pointerX(): number;
  38048. set pointerX(value: number);
  38049. /**
  38050. * Gets or sets the current on-screen Y position of the pointer
  38051. */
  38052. get pointerY(): number;
  38053. set pointerY(value: number);
  38054. private _updatePointerPosition;
  38055. private _processPointerMove;
  38056. private _setRayOnPointerInfo;
  38057. private _checkPrePointerObservable;
  38058. /**
  38059. * Use this method to simulate a pointer move on a mesh
  38060. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38061. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38062. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38063. */
  38064. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38065. /**
  38066. * Use this method to simulate a pointer down on a mesh
  38067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38070. */
  38071. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38072. private _processPointerDown;
  38073. /** @hidden */
  38074. _isPointerSwiping(): boolean;
  38075. /**
  38076. * Use this method to simulate a pointer up on a mesh
  38077. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38078. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38079. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38080. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38081. */
  38082. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38083. private _processPointerUp;
  38084. /**
  38085. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38086. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38087. * @returns true if the pointer was captured
  38088. */
  38089. isPointerCaptured(pointerId?: number): boolean;
  38090. /**
  38091. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38092. * @param attachUp defines if you want to attach events to pointerup
  38093. * @param attachDown defines if you want to attach events to pointerdown
  38094. * @param attachMove defines if you want to attach events to pointermove
  38095. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38096. */
  38097. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38098. /**
  38099. * Detaches all event handlers
  38100. */
  38101. detachControl(): void;
  38102. /**
  38103. * Force the value of meshUnderPointer
  38104. * @param mesh defines the mesh to use
  38105. */
  38106. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38107. /**
  38108. * Gets the mesh under the pointer
  38109. * @returns a Mesh or null if no mesh is under the pointer
  38110. */
  38111. getPointerOverMesh(): Nullable<AbstractMesh>;
  38112. }
  38113. }
  38114. declare module BABYLON {
  38115. /**
  38116. * This class defines the direct association between an animation and a target
  38117. */
  38118. export class TargetedAnimation {
  38119. /**
  38120. * Animation to perform
  38121. */
  38122. animation: Animation;
  38123. /**
  38124. * Target to animate
  38125. */
  38126. target: any;
  38127. /**
  38128. * Returns the string "TargetedAnimation"
  38129. * @returns "TargetedAnimation"
  38130. */
  38131. getClassName(): string;
  38132. /**
  38133. * Serialize the object
  38134. * @returns the JSON object representing the current entity
  38135. */
  38136. serialize(): any;
  38137. }
  38138. /**
  38139. * Use this class to create coordinated animations on multiple targets
  38140. */
  38141. export class AnimationGroup implements IDisposable {
  38142. /** The name of the animation group */
  38143. name: string;
  38144. private _scene;
  38145. private _targetedAnimations;
  38146. private _animatables;
  38147. private _from;
  38148. private _to;
  38149. private _isStarted;
  38150. private _isPaused;
  38151. private _speedRatio;
  38152. private _loopAnimation;
  38153. private _isAdditive;
  38154. /**
  38155. * Gets or sets the unique id of the node
  38156. */
  38157. uniqueId: number;
  38158. /**
  38159. * This observable will notify when one animation have ended
  38160. */
  38161. onAnimationEndObservable: Observable<TargetedAnimation>;
  38162. /**
  38163. * Observer raised when one animation loops
  38164. */
  38165. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38166. /**
  38167. * Observer raised when all animations have looped
  38168. */
  38169. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38170. /**
  38171. * This observable will notify when all animations have ended.
  38172. */
  38173. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38174. /**
  38175. * This observable will notify when all animations have paused.
  38176. */
  38177. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38178. /**
  38179. * This observable will notify when all animations are playing.
  38180. */
  38181. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38182. /**
  38183. * Gets the first frame
  38184. */
  38185. get from(): number;
  38186. /**
  38187. * Gets the last frame
  38188. */
  38189. get to(): number;
  38190. /**
  38191. * Define if the animations are started
  38192. */
  38193. get isStarted(): boolean;
  38194. /**
  38195. * Gets a value indicating that the current group is playing
  38196. */
  38197. get isPlaying(): boolean;
  38198. /**
  38199. * Gets or sets the speed ratio to use for all animations
  38200. */
  38201. get speedRatio(): number;
  38202. /**
  38203. * Gets or sets the speed ratio to use for all animations
  38204. */
  38205. set speedRatio(value: number);
  38206. /**
  38207. * Gets or sets if all animations should loop or not
  38208. */
  38209. get loopAnimation(): boolean;
  38210. set loopAnimation(value: boolean);
  38211. /**
  38212. * Gets or sets if all animations should be evaluated additively
  38213. */
  38214. get isAdditive(): boolean;
  38215. set isAdditive(value: boolean);
  38216. /**
  38217. * Gets the targeted animations for this animation group
  38218. */
  38219. get targetedAnimations(): Array<TargetedAnimation>;
  38220. /**
  38221. * returning the list of animatables controlled by this animation group.
  38222. */
  38223. get animatables(): Array<Animatable>;
  38224. /**
  38225. * Gets the list of target animations
  38226. */
  38227. get children(): TargetedAnimation[];
  38228. /**
  38229. * Instantiates a new Animation Group.
  38230. * This helps managing several animations at once.
  38231. * @see http://doc.babylonjs.com/how_to/group
  38232. * @param name Defines the name of the group
  38233. * @param scene Defines the scene the group belongs to
  38234. */
  38235. constructor(
  38236. /** The name of the animation group */
  38237. name: string, scene?: Nullable<Scene>);
  38238. /**
  38239. * Add an animation (with its target) in the group
  38240. * @param animation defines the animation we want to add
  38241. * @param target defines the target of the animation
  38242. * @returns the TargetedAnimation object
  38243. */
  38244. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38245. /**
  38246. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38247. * It can add constant keys at begin or end
  38248. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38249. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38250. * @returns the animation group
  38251. */
  38252. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38253. private _animationLoopCount;
  38254. private _animationLoopFlags;
  38255. private _processLoop;
  38256. /**
  38257. * Start all animations on given targets
  38258. * @param loop defines if animations must loop
  38259. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38260. * @param from defines the from key (optional)
  38261. * @param to defines the to key (optional)
  38262. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38263. * @returns the current animation group
  38264. */
  38265. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38266. /**
  38267. * Pause all animations
  38268. * @returns the animation group
  38269. */
  38270. pause(): AnimationGroup;
  38271. /**
  38272. * Play all animations to initial state
  38273. * This function will start() the animations if they were not started or will restart() them if they were paused
  38274. * @param loop defines if animations must loop
  38275. * @returns the animation group
  38276. */
  38277. play(loop?: boolean): AnimationGroup;
  38278. /**
  38279. * Reset all animations to initial state
  38280. * @returns the animation group
  38281. */
  38282. reset(): AnimationGroup;
  38283. /**
  38284. * Restart animations from key 0
  38285. * @returns the animation group
  38286. */
  38287. restart(): AnimationGroup;
  38288. /**
  38289. * Stop all animations
  38290. * @returns the animation group
  38291. */
  38292. stop(): AnimationGroup;
  38293. /**
  38294. * Set animation weight for all animatables
  38295. * @param weight defines the weight to use
  38296. * @return the animationGroup
  38297. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38298. */
  38299. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38300. /**
  38301. * Synchronize and normalize all animatables with a source animatable
  38302. * @param root defines the root animatable to synchronize with
  38303. * @return the animationGroup
  38304. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38305. */
  38306. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38307. /**
  38308. * Goes to a specific frame in this animation group
  38309. * @param frame the frame number to go to
  38310. * @return the animationGroup
  38311. */
  38312. goToFrame(frame: number): AnimationGroup;
  38313. /**
  38314. * Dispose all associated resources
  38315. */
  38316. dispose(): void;
  38317. private _checkAnimationGroupEnded;
  38318. /**
  38319. * Clone the current animation group and returns a copy
  38320. * @param newName defines the name of the new group
  38321. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38322. * @returns the new aniamtion group
  38323. */
  38324. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38325. /**
  38326. * Serializes the animationGroup to an object
  38327. * @returns Serialized object
  38328. */
  38329. serialize(): any;
  38330. /**
  38331. * Returns a new AnimationGroup object parsed from the source provided.
  38332. * @param parsedAnimationGroup defines the source
  38333. * @param scene defines the scene that will receive the animationGroup
  38334. * @returns a new AnimationGroup
  38335. */
  38336. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38337. /**
  38338. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38339. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38340. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38341. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38342. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38343. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38344. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38345. */
  38346. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38347. /**
  38348. * Returns the string "AnimationGroup"
  38349. * @returns "AnimationGroup"
  38350. */
  38351. getClassName(): string;
  38352. /**
  38353. * Creates a detailled string about the object
  38354. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38355. * @returns a string representing the object
  38356. */
  38357. toString(fullDetails?: boolean): string;
  38358. }
  38359. }
  38360. declare module BABYLON {
  38361. /**
  38362. * Define an interface for all classes that will hold resources
  38363. */
  38364. export interface IDisposable {
  38365. /**
  38366. * Releases all held resources
  38367. */
  38368. dispose(): void;
  38369. }
  38370. /** Interface defining initialization parameters for Scene class */
  38371. export interface SceneOptions {
  38372. /**
  38373. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38374. * It will improve performance when the number of geometries becomes important.
  38375. */
  38376. useGeometryUniqueIdsMap?: boolean;
  38377. /**
  38378. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38379. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38380. */
  38381. useMaterialMeshMap?: boolean;
  38382. /**
  38383. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38384. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38385. */
  38386. useClonedMeshMap?: boolean;
  38387. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38388. virtual?: boolean;
  38389. }
  38390. /**
  38391. * Represents a scene to be rendered by the engine.
  38392. * @see http://doc.babylonjs.com/features/scene
  38393. */
  38394. export class Scene extends AbstractScene implements IAnimatable {
  38395. /** The fog is deactivated */
  38396. static readonly FOGMODE_NONE: number;
  38397. /** The fog density is following an exponential function */
  38398. static readonly FOGMODE_EXP: number;
  38399. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38400. static readonly FOGMODE_EXP2: number;
  38401. /** The fog density is following a linear function. */
  38402. static readonly FOGMODE_LINEAR: number;
  38403. /**
  38404. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38405. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38406. */
  38407. static MinDeltaTime: number;
  38408. /**
  38409. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38410. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38411. */
  38412. static MaxDeltaTime: number;
  38413. /**
  38414. * Factory used to create the default material.
  38415. * @param name The name of the material to create
  38416. * @param scene The scene to create the material for
  38417. * @returns The default material
  38418. */
  38419. static DefaultMaterialFactory(scene: Scene): Material;
  38420. /**
  38421. * Factory used to create the a collision coordinator.
  38422. * @returns The collision coordinator
  38423. */
  38424. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38425. /** @hidden */
  38426. _inputManager: InputManager;
  38427. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38428. cameraToUseForPointers: Nullable<Camera>;
  38429. /** @hidden */
  38430. readonly _isScene: boolean;
  38431. /** @hidden */
  38432. _blockEntityCollection: boolean;
  38433. /**
  38434. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38435. */
  38436. autoClear: boolean;
  38437. /**
  38438. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38439. */
  38440. autoClearDepthAndStencil: boolean;
  38441. /**
  38442. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38443. */
  38444. clearColor: Color4;
  38445. /**
  38446. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38447. */
  38448. ambientColor: Color3;
  38449. /**
  38450. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38451. * It should only be one of the following (if not the default embedded one):
  38452. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38453. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38454. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38455. * The material properties need to be setup according to the type of texture in use.
  38456. */
  38457. environmentBRDFTexture: BaseTexture;
  38458. /** @hidden */
  38459. protected _environmentTexture: Nullable<BaseTexture>;
  38460. /**
  38461. * Texture used in all pbr material as the reflection texture.
  38462. * As in the majority of the scene they are the same (exception for multi room and so on),
  38463. * this is easier to reference from here than from all the materials.
  38464. */
  38465. get environmentTexture(): Nullable<BaseTexture>;
  38466. /**
  38467. * Texture used in all pbr material as the reflection texture.
  38468. * As in the majority of the scene they are the same (exception for multi room and so on),
  38469. * this is easier to set here than in all the materials.
  38470. */
  38471. set environmentTexture(value: Nullable<BaseTexture>);
  38472. /** @hidden */
  38473. protected _environmentIntensity: number;
  38474. /**
  38475. * Intensity of the environment in all pbr material.
  38476. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38477. * As in the majority of the scene they are the same (exception for multi room and so on),
  38478. * this is easier to reference from here than from all the materials.
  38479. */
  38480. get environmentIntensity(): number;
  38481. /**
  38482. * Intensity of the environment in all pbr material.
  38483. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38484. * As in the majority of the scene they are the same (exception for multi room and so on),
  38485. * this is easier to set here than in all the materials.
  38486. */
  38487. set environmentIntensity(value: number);
  38488. /** @hidden */
  38489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38490. /**
  38491. * Default image processing configuration used either in the rendering
  38492. * Forward main pass or through the imageProcessingPostProcess if present.
  38493. * As in the majority of the scene they are the same (exception for multi camera),
  38494. * this is easier to reference from here than from all the materials and post process.
  38495. *
  38496. * No setter as we it is a shared configuration, you can set the values instead.
  38497. */
  38498. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38499. private _forceWireframe;
  38500. /**
  38501. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38502. */
  38503. set forceWireframe(value: boolean);
  38504. get forceWireframe(): boolean;
  38505. private _skipFrustumClipping;
  38506. /**
  38507. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38508. */
  38509. set skipFrustumClipping(value: boolean);
  38510. get skipFrustumClipping(): boolean;
  38511. private _forcePointsCloud;
  38512. /**
  38513. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38514. */
  38515. set forcePointsCloud(value: boolean);
  38516. get forcePointsCloud(): boolean;
  38517. /**
  38518. * Gets or sets the active clipplane 1
  38519. */
  38520. clipPlane: Nullable<Plane>;
  38521. /**
  38522. * Gets or sets the active clipplane 2
  38523. */
  38524. clipPlane2: Nullable<Plane>;
  38525. /**
  38526. * Gets or sets the active clipplane 3
  38527. */
  38528. clipPlane3: Nullable<Plane>;
  38529. /**
  38530. * Gets or sets the active clipplane 4
  38531. */
  38532. clipPlane4: Nullable<Plane>;
  38533. /**
  38534. * Gets or sets the active clipplane 5
  38535. */
  38536. clipPlane5: Nullable<Plane>;
  38537. /**
  38538. * Gets or sets the active clipplane 6
  38539. */
  38540. clipPlane6: Nullable<Plane>;
  38541. /**
  38542. * Gets or sets a boolean indicating if animations are enabled
  38543. */
  38544. animationsEnabled: boolean;
  38545. private _animationPropertiesOverride;
  38546. /**
  38547. * Gets or sets the animation properties override
  38548. */
  38549. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38550. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38551. /**
  38552. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38553. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38554. */
  38555. useConstantAnimationDeltaTime: boolean;
  38556. /**
  38557. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38558. * Please note that it requires to run a ray cast through the scene on every frame
  38559. */
  38560. constantlyUpdateMeshUnderPointer: boolean;
  38561. /**
  38562. * Defines the HTML cursor to use when hovering over interactive elements
  38563. */
  38564. hoverCursor: string;
  38565. /**
  38566. * Defines the HTML default cursor to use (empty by default)
  38567. */
  38568. defaultCursor: string;
  38569. /**
  38570. * Defines whether cursors are handled by the scene.
  38571. */
  38572. doNotHandleCursors: boolean;
  38573. /**
  38574. * This is used to call preventDefault() on pointer down
  38575. * in order to block unwanted artifacts like system double clicks
  38576. */
  38577. preventDefaultOnPointerDown: boolean;
  38578. /**
  38579. * This is used to call preventDefault() on pointer up
  38580. * in order to block unwanted artifacts like system double clicks
  38581. */
  38582. preventDefaultOnPointerUp: boolean;
  38583. /**
  38584. * Gets or sets user defined metadata
  38585. */
  38586. metadata: any;
  38587. /**
  38588. * For internal use only. Please do not use.
  38589. */
  38590. reservedDataStore: any;
  38591. /**
  38592. * Gets the name of the plugin used to load this scene (null by default)
  38593. */
  38594. loadingPluginName: string;
  38595. /**
  38596. * Use this array to add regular expressions used to disable offline support for specific urls
  38597. */
  38598. disableOfflineSupportExceptionRules: RegExp[];
  38599. /**
  38600. * An event triggered when the scene is disposed.
  38601. */
  38602. onDisposeObservable: Observable<Scene>;
  38603. private _onDisposeObserver;
  38604. /** Sets a function to be executed when this scene is disposed. */
  38605. set onDispose(callback: () => void);
  38606. /**
  38607. * An event triggered before rendering the scene (right after animations and physics)
  38608. */
  38609. onBeforeRenderObservable: Observable<Scene>;
  38610. private _onBeforeRenderObserver;
  38611. /** Sets a function to be executed before rendering this scene */
  38612. set beforeRender(callback: Nullable<() => void>);
  38613. /**
  38614. * An event triggered after rendering the scene
  38615. */
  38616. onAfterRenderObservable: Observable<Scene>;
  38617. /**
  38618. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38619. */
  38620. onAfterRenderCameraObservable: Observable<Camera>;
  38621. private _onAfterRenderObserver;
  38622. /** Sets a function to be executed after rendering this scene */
  38623. set afterRender(callback: Nullable<() => void>);
  38624. /**
  38625. * An event triggered before animating the scene
  38626. */
  38627. onBeforeAnimationsObservable: Observable<Scene>;
  38628. /**
  38629. * An event triggered after animations processing
  38630. */
  38631. onAfterAnimationsObservable: Observable<Scene>;
  38632. /**
  38633. * An event triggered before draw calls are ready to be sent
  38634. */
  38635. onBeforeDrawPhaseObservable: Observable<Scene>;
  38636. /**
  38637. * An event triggered after draw calls have been sent
  38638. */
  38639. onAfterDrawPhaseObservable: Observable<Scene>;
  38640. /**
  38641. * An event triggered when the scene is ready
  38642. */
  38643. onReadyObservable: Observable<Scene>;
  38644. /**
  38645. * An event triggered before rendering a camera
  38646. */
  38647. onBeforeCameraRenderObservable: Observable<Camera>;
  38648. private _onBeforeCameraRenderObserver;
  38649. /** Sets a function to be executed before rendering a camera*/
  38650. set beforeCameraRender(callback: () => void);
  38651. /**
  38652. * An event triggered after rendering a camera
  38653. */
  38654. onAfterCameraRenderObservable: Observable<Camera>;
  38655. private _onAfterCameraRenderObserver;
  38656. /** Sets a function to be executed after rendering a camera*/
  38657. set afterCameraRender(callback: () => void);
  38658. /**
  38659. * An event triggered when active meshes evaluation is about to start
  38660. */
  38661. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38662. /**
  38663. * An event triggered when active meshes evaluation is done
  38664. */
  38665. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38666. /**
  38667. * An event triggered when particles rendering is about to start
  38668. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38669. */
  38670. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38671. /**
  38672. * An event triggered when particles rendering is done
  38673. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38674. */
  38675. onAfterParticlesRenderingObservable: Observable<Scene>;
  38676. /**
  38677. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38678. */
  38679. onDataLoadedObservable: Observable<Scene>;
  38680. /**
  38681. * An event triggered when a camera is created
  38682. */
  38683. onNewCameraAddedObservable: Observable<Camera>;
  38684. /**
  38685. * An event triggered when a camera is removed
  38686. */
  38687. onCameraRemovedObservable: Observable<Camera>;
  38688. /**
  38689. * An event triggered when a light is created
  38690. */
  38691. onNewLightAddedObservable: Observable<Light>;
  38692. /**
  38693. * An event triggered when a light is removed
  38694. */
  38695. onLightRemovedObservable: Observable<Light>;
  38696. /**
  38697. * An event triggered when a geometry is created
  38698. */
  38699. onNewGeometryAddedObservable: Observable<Geometry>;
  38700. /**
  38701. * An event triggered when a geometry is removed
  38702. */
  38703. onGeometryRemovedObservable: Observable<Geometry>;
  38704. /**
  38705. * An event triggered when a transform node is created
  38706. */
  38707. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38708. /**
  38709. * An event triggered when a transform node is removed
  38710. */
  38711. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38712. /**
  38713. * An event triggered when a mesh is created
  38714. */
  38715. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38716. /**
  38717. * An event triggered when a mesh is removed
  38718. */
  38719. onMeshRemovedObservable: Observable<AbstractMesh>;
  38720. /**
  38721. * An event triggered when a skeleton is created
  38722. */
  38723. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38724. /**
  38725. * An event triggered when a skeleton is removed
  38726. */
  38727. onSkeletonRemovedObservable: Observable<Skeleton>;
  38728. /**
  38729. * An event triggered when a material is created
  38730. */
  38731. onNewMaterialAddedObservable: Observable<Material>;
  38732. /**
  38733. * An event triggered when a material is removed
  38734. */
  38735. onMaterialRemovedObservable: Observable<Material>;
  38736. /**
  38737. * An event triggered when a texture is created
  38738. */
  38739. onNewTextureAddedObservable: Observable<BaseTexture>;
  38740. /**
  38741. * An event triggered when a texture is removed
  38742. */
  38743. onTextureRemovedObservable: Observable<BaseTexture>;
  38744. /**
  38745. * An event triggered when render targets are about to be rendered
  38746. * Can happen multiple times per frame.
  38747. */
  38748. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38749. /**
  38750. * An event triggered when render targets were rendered.
  38751. * Can happen multiple times per frame.
  38752. */
  38753. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38754. /**
  38755. * An event triggered before calculating deterministic simulation step
  38756. */
  38757. onBeforeStepObservable: Observable<Scene>;
  38758. /**
  38759. * An event triggered after calculating deterministic simulation step
  38760. */
  38761. onAfterStepObservable: Observable<Scene>;
  38762. /**
  38763. * An event triggered when the activeCamera property is updated
  38764. */
  38765. onActiveCameraChanged: Observable<Scene>;
  38766. /**
  38767. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38768. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38769. * 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)
  38770. */
  38771. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38772. /**
  38773. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38774. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38775. * 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)
  38776. */
  38777. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38778. /**
  38779. * This Observable will when a mesh has been imported into the scene.
  38780. */
  38781. onMeshImportedObservable: Observable<AbstractMesh>;
  38782. /**
  38783. * This Observable will when an animation file has been imported into the scene.
  38784. */
  38785. onAnimationFileImportedObservable: Observable<Scene>;
  38786. /**
  38787. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38788. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38789. */
  38790. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38791. /** @hidden */
  38792. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38793. /**
  38794. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38795. */
  38796. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38797. /**
  38798. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38799. */
  38800. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38801. /**
  38802. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38803. */
  38804. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38805. /** Callback called when a pointer move is detected */
  38806. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38807. /** Callback called when a pointer down is detected */
  38808. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38809. /** Callback called when a pointer up is detected */
  38810. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38811. /** Callback called when a pointer pick is detected */
  38812. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38813. /**
  38814. * 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).
  38815. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38816. */
  38817. onPrePointerObservable: Observable<PointerInfoPre>;
  38818. /**
  38819. * Observable event triggered each time an input event is received from the rendering canvas
  38820. */
  38821. onPointerObservable: Observable<PointerInfo>;
  38822. /**
  38823. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38824. */
  38825. get unTranslatedPointer(): Vector2;
  38826. /**
  38827. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38828. */
  38829. static get DragMovementThreshold(): number;
  38830. static set DragMovementThreshold(value: number);
  38831. /**
  38832. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38833. */
  38834. static get LongPressDelay(): number;
  38835. static set LongPressDelay(value: number);
  38836. /**
  38837. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38838. */
  38839. static get DoubleClickDelay(): number;
  38840. static set DoubleClickDelay(value: number);
  38841. /** If you need to check double click without raising a single click at first click, enable this flag */
  38842. static get ExclusiveDoubleClickMode(): boolean;
  38843. static set ExclusiveDoubleClickMode(value: boolean);
  38844. /** @hidden */
  38845. _mirroredCameraPosition: Nullable<Vector3>;
  38846. /**
  38847. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38848. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38849. */
  38850. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38851. /**
  38852. * Observable event triggered each time an keyboard event is received from the hosting window
  38853. */
  38854. onKeyboardObservable: Observable<KeyboardInfo>;
  38855. private _useRightHandedSystem;
  38856. /**
  38857. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38858. */
  38859. set useRightHandedSystem(value: boolean);
  38860. get useRightHandedSystem(): boolean;
  38861. private _timeAccumulator;
  38862. private _currentStepId;
  38863. private _currentInternalStep;
  38864. /**
  38865. * Sets the step Id used by deterministic lock step
  38866. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38867. * @param newStepId defines the step Id
  38868. */
  38869. setStepId(newStepId: number): void;
  38870. /**
  38871. * Gets the step Id used by deterministic lock step
  38872. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38873. * @returns the step Id
  38874. */
  38875. getStepId(): number;
  38876. /**
  38877. * Gets the internal step used by deterministic lock step
  38878. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38879. * @returns the internal step
  38880. */
  38881. getInternalStep(): number;
  38882. private _fogEnabled;
  38883. /**
  38884. * Gets or sets a boolean indicating if fog is enabled on this scene
  38885. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38886. * (Default is true)
  38887. */
  38888. set fogEnabled(value: boolean);
  38889. get fogEnabled(): boolean;
  38890. private _fogMode;
  38891. /**
  38892. * Gets or sets the fog mode to use
  38893. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38894. * | mode | value |
  38895. * | --- | --- |
  38896. * | FOGMODE_NONE | 0 |
  38897. * | FOGMODE_EXP | 1 |
  38898. * | FOGMODE_EXP2 | 2 |
  38899. * | FOGMODE_LINEAR | 3 |
  38900. */
  38901. set fogMode(value: number);
  38902. get fogMode(): number;
  38903. /**
  38904. * Gets or sets the fog color to use
  38905. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38906. * (Default is Color3(0.2, 0.2, 0.3))
  38907. */
  38908. fogColor: Color3;
  38909. /**
  38910. * Gets or sets the fog density to use
  38911. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38912. * (Default is 0.1)
  38913. */
  38914. fogDensity: number;
  38915. /**
  38916. * Gets or sets the fog start distance to use
  38917. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38918. * (Default is 0)
  38919. */
  38920. fogStart: number;
  38921. /**
  38922. * Gets or sets the fog end distance to use
  38923. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38924. * (Default is 1000)
  38925. */
  38926. fogEnd: number;
  38927. private _shadowsEnabled;
  38928. /**
  38929. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38930. */
  38931. set shadowsEnabled(value: boolean);
  38932. get shadowsEnabled(): boolean;
  38933. private _lightsEnabled;
  38934. /**
  38935. * Gets or sets a boolean indicating if lights are enabled on this scene
  38936. */
  38937. set lightsEnabled(value: boolean);
  38938. get lightsEnabled(): boolean;
  38939. /** All of the active cameras added to this scene. */
  38940. activeCameras: Camera[];
  38941. /** @hidden */
  38942. _activeCamera: Nullable<Camera>;
  38943. /** Gets or sets the current active camera */
  38944. get activeCamera(): Nullable<Camera>;
  38945. set activeCamera(value: Nullable<Camera>);
  38946. private _defaultMaterial;
  38947. /** The default material used on meshes when no material is affected */
  38948. get defaultMaterial(): Material;
  38949. /** The default material used on meshes when no material is affected */
  38950. set defaultMaterial(value: Material);
  38951. private _texturesEnabled;
  38952. /**
  38953. * Gets or sets a boolean indicating if textures are enabled on this scene
  38954. */
  38955. set texturesEnabled(value: boolean);
  38956. get texturesEnabled(): boolean;
  38957. /**
  38958. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38959. */
  38960. physicsEnabled: boolean;
  38961. /**
  38962. * Gets or sets a boolean indicating if particles are enabled on this scene
  38963. */
  38964. particlesEnabled: boolean;
  38965. /**
  38966. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38967. */
  38968. spritesEnabled: boolean;
  38969. private _skeletonsEnabled;
  38970. /**
  38971. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38972. */
  38973. set skeletonsEnabled(value: boolean);
  38974. get skeletonsEnabled(): boolean;
  38975. /**
  38976. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38977. */
  38978. lensFlaresEnabled: boolean;
  38979. /**
  38980. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38981. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38982. */
  38983. collisionsEnabled: boolean;
  38984. private _collisionCoordinator;
  38985. /** @hidden */
  38986. get collisionCoordinator(): ICollisionCoordinator;
  38987. /**
  38988. * Defines the gravity applied to this scene (used only for collisions)
  38989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38990. */
  38991. gravity: Vector3;
  38992. /**
  38993. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38994. */
  38995. postProcessesEnabled: boolean;
  38996. /**
  38997. * The list of postprocesses added to the scene
  38998. */
  38999. postProcesses: PostProcess[];
  39000. /**
  39001. * Gets the current postprocess manager
  39002. */
  39003. postProcessManager: PostProcessManager;
  39004. /**
  39005. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39006. */
  39007. renderTargetsEnabled: boolean;
  39008. /**
  39009. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39010. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39011. */
  39012. dumpNextRenderTargets: boolean;
  39013. /**
  39014. * The list of user defined render targets added to the scene
  39015. */
  39016. customRenderTargets: RenderTargetTexture[];
  39017. /**
  39018. * Defines if texture loading must be delayed
  39019. * If true, textures will only be loaded when they need to be rendered
  39020. */
  39021. useDelayedTextureLoading: boolean;
  39022. /**
  39023. * Gets the list of meshes imported to the scene through SceneLoader
  39024. */
  39025. importedMeshesFiles: String[];
  39026. /**
  39027. * Gets or sets a boolean indicating if probes are enabled on this scene
  39028. */
  39029. probesEnabled: boolean;
  39030. /**
  39031. * Gets or sets the current offline provider to use to store scene data
  39032. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39033. */
  39034. offlineProvider: IOfflineProvider;
  39035. /**
  39036. * Gets or sets the action manager associated with the scene
  39037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39038. */
  39039. actionManager: AbstractActionManager;
  39040. private _meshesForIntersections;
  39041. /**
  39042. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39043. */
  39044. proceduralTexturesEnabled: boolean;
  39045. private _engine;
  39046. private _totalVertices;
  39047. /** @hidden */
  39048. _activeIndices: PerfCounter;
  39049. /** @hidden */
  39050. _activeParticles: PerfCounter;
  39051. /** @hidden */
  39052. _activeBones: PerfCounter;
  39053. private _animationRatio;
  39054. /** @hidden */
  39055. _animationTimeLast: number;
  39056. /** @hidden */
  39057. _animationTime: number;
  39058. /**
  39059. * Gets or sets a general scale for animation speed
  39060. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39061. */
  39062. animationTimeScale: number;
  39063. /** @hidden */
  39064. _cachedMaterial: Nullable<Material>;
  39065. /** @hidden */
  39066. _cachedEffect: Nullable<Effect>;
  39067. /** @hidden */
  39068. _cachedVisibility: Nullable<number>;
  39069. private _renderId;
  39070. private _frameId;
  39071. private _executeWhenReadyTimeoutId;
  39072. private _intermediateRendering;
  39073. private _viewUpdateFlag;
  39074. private _projectionUpdateFlag;
  39075. /** @hidden */
  39076. _toBeDisposed: Nullable<IDisposable>[];
  39077. private _activeRequests;
  39078. /** @hidden */
  39079. _pendingData: any[];
  39080. private _isDisposed;
  39081. /**
  39082. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39083. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39084. */
  39085. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39086. private _activeMeshes;
  39087. private _processedMaterials;
  39088. private _renderTargets;
  39089. /** @hidden */
  39090. _activeParticleSystems: SmartArray<IParticleSystem>;
  39091. private _activeSkeletons;
  39092. private _softwareSkinnedMeshes;
  39093. private _renderingManager;
  39094. /** @hidden */
  39095. _activeAnimatables: Animatable[];
  39096. private _transformMatrix;
  39097. private _sceneUbo;
  39098. /** @hidden */
  39099. _viewMatrix: Matrix;
  39100. private _projectionMatrix;
  39101. /** @hidden */
  39102. _forcedViewPosition: Nullable<Vector3>;
  39103. /** @hidden */
  39104. _frustumPlanes: Plane[];
  39105. /**
  39106. * Gets the list of frustum planes (built from the active camera)
  39107. */
  39108. get frustumPlanes(): Plane[];
  39109. /**
  39110. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39111. * This is useful if there are more lights that the maximum simulteanous authorized
  39112. */
  39113. requireLightSorting: boolean;
  39114. /** @hidden */
  39115. readonly useMaterialMeshMap: boolean;
  39116. /** @hidden */
  39117. readonly useClonedMeshMap: boolean;
  39118. private _externalData;
  39119. private _uid;
  39120. /**
  39121. * @hidden
  39122. * Backing store of defined scene components.
  39123. */
  39124. _components: ISceneComponent[];
  39125. /**
  39126. * @hidden
  39127. * Backing store of defined scene components.
  39128. */
  39129. _serializableComponents: ISceneSerializableComponent[];
  39130. /**
  39131. * List of components to register on the next registration step.
  39132. */
  39133. private _transientComponents;
  39134. /**
  39135. * Registers the transient components if needed.
  39136. */
  39137. private _registerTransientComponents;
  39138. /**
  39139. * @hidden
  39140. * Add a component to the scene.
  39141. * Note that the ccomponent could be registered on th next frame if this is called after
  39142. * the register component stage.
  39143. * @param component Defines the component to add to the scene
  39144. */
  39145. _addComponent(component: ISceneComponent): void;
  39146. /**
  39147. * @hidden
  39148. * Gets a component from the scene.
  39149. * @param name defines the name of the component to retrieve
  39150. * @returns the component or null if not present
  39151. */
  39152. _getComponent(name: string): Nullable<ISceneComponent>;
  39153. /**
  39154. * @hidden
  39155. * Defines the actions happening before camera updates.
  39156. */
  39157. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39158. /**
  39159. * @hidden
  39160. * Defines the actions happening before clear the canvas.
  39161. */
  39162. _beforeClearStage: Stage<SimpleStageAction>;
  39163. /**
  39164. * @hidden
  39165. * Defines the actions when collecting render targets for the frame.
  39166. */
  39167. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39168. /**
  39169. * @hidden
  39170. * Defines the actions happening for one camera in the frame.
  39171. */
  39172. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39173. /**
  39174. * @hidden
  39175. * Defines the actions happening during the per mesh ready checks.
  39176. */
  39177. _isReadyForMeshStage: Stage<MeshStageAction>;
  39178. /**
  39179. * @hidden
  39180. * Defines the actions happening before evaluate active mesh checks.
  39181. */
  39182. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39183. /**
  39184. * @hidden
  39185. * Defines the actions happening during the evaluate sub mesh checks.
  39186. */
  39187. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39188. /**
  39189. * @hidden
  39190. * Defines the actions happening during the active mesh stage.
  39191. */
  39192. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39193. /**
  39194. * @hidden
  39195. * Defines the actions happening during the per camera render target step.
  39196. */
  39197. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39198. /**
  39199. * @hidden
  39200. * Defines the actions happening just before the active camera is drawing.
  39201. */
  39202. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39203. /**
  39204. * @hidden
  39205. * Defines the actions happening just before a render target is drawing.
  39206. */
  39207. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39208. /**
  39209. * @hidden
  39210. * Defines the actions happening just before a rendering group is drawing.
  39211. */
  39212. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39213. /**
  39214. * @hidden
  39215. * Defines the actions happening just before a mesh is drawing.
  39216. */
  39217. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39218. /**
  39219. * @hidden
  39220. * Defines the actions happening just after a mesh has been drawn.
  39221. */
  39222. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39223. /**
  39224. * @hidden
  39225. * Defines the actions happening just after a rendering group has been drawn.
  39226. */
  39227. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39228. /**
  39229. * @hidden
  39230. * Defines the actions happening just after the active camera has been drawn.
  39231. */
  39232. _afterCameraDrawStage: Stage<CameraStageAction>;
  39233. /**
  39234. * @hidden
  39235. * Defines the actions happening just after a render target has been drawn.
  39236. */
  39237. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39238. /**
  39239. * @hidden
  39240. * Defines the actions happening just after rendering all cameras and computing intersections.
  39241. */
  39242. _afterRenderStage: Stage<SimpleStageAction>;
  39243. /**
  39244. * @hidden
  39245. * Defines the actions happening when a pointer move event happens.
  39246. */
  39247. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39248. /**
  39249. * @hidden
  39250. * Defines the actions happening when a pointer down event happens.
  39251. */
  39252. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39253. /**
  39254. * @hidden
  39255. * Defines the actions happening when a pointer up event happens.
  39256. */
  39257. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39258. /**
  39259. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39260. */
  39261. private geometriesByUniqueId;
  39262. /**
  39263. * Creates a new Scene
  39264. * @param engine defines the engine to use to render this scene
  39265. * @param options defines the scene options
  39266. */
  39267. constructor(engine: Engine, options?: SceneOptions);
  39268. /**
  39269. * Gets a string idenfifying the name of the class
  39270. * @returns "Scene" string
  39271. */
  39272. getClassName(): string;
  39273. private _defaultMeshCandidates;
  39274. /**
  39275. * @hidden
  39276. */
  39277. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39278. private _defaultSubMeshCandidates;
  39279. /**
  39280. * @hidden
  39281. */
  39282. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39283. /**
  39284. * Sets the default candidate providers for the scene.
  39285. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39286. * and getCollidingSubMeshCandidates to their default function
  39287. */
  39288. setDefaultCandidateProviders(): void;
  39289. /**
  39290. * Gets the mesh that is currently under the pointer
  39291. */
  39292. get meshUnderPointer(): Nullable<AbstractMesh>;
  39293. /**
  39294. * Gets or sets the current on-screen X position of the pointer
  39295. */
  39296. get pointerX(): number;
  39297. set pointerX(value: number);
  39298. /**
  39299. * Gets or sets the current on-screen Y position of the pointer
  39300. */
  39301. get pointerY(): number;
  39302. set pointerY(value: number);
  39303. /**
  39304. * Gets the cached material (ie. the latest rendered one)
  39305. * @returns the cached material
  39306. */
  39307. getCachedMaterial(): Nullable<Material>;
  39308. /**
  39309. * Gets the cached effect (ie. the latest rendered one)
  39310. * @returns the cached effect
  39311. */
  39312. getCachedEffect(): Nullable<Effect>;
  39313. /**
  39314. * Gets the cached visibility state (ie. the latest rendered one)
  39315. * @returns the cached visibility state
  39316. */
  39317. getCachedVisibility(): Nullable<number>;
  39318. /**
  39319. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39320. * @param material defines the current material
  39321. * @param effect defines the current effect
  39322. * @param visibility defines the current visibility state
  39323. * @returns true if one parameter is not cached
  39324. */
  39325. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39326. /**
  39327. * Gets the engine associated with the scene
  39328. * @returns an Engine
  39329. */
  39330. getEngine(): Engine;
  39331. /**
  39332. * Gets the total number of vertices rendered per frame
  39333. * @returns the total number of vertices rendered per frame
  39334. */
  39335. getTotalVertices(): number;
  39336. /**
  39337. * Gets the performance counter for total vertices
  39338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39339. */
  39340. get totalVerticesPerfCounter(): PerfCounter;
  39341. /**
  39342. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39343. * @returns the total number of active indices rendered per frame
  39344. */
  39345. getActiveIndices(): number;
  39346. /**
  39347. * Gets the performance counter for active indices
  39348. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39349. */
  39350. get totalActiveIndicesPerfCounter(): PerfCounter;
  39351. /**
  39352. * Gets the total number of active particles rendered per frame
  39353. * @returns the total number of active particles rendered per frame
  39354. */
  39355. getActiveParticles(): number;
  39356. /**
  39357. * Gets the performance counter for active particles
  39358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39359. */
  39360. get activeParticlesPerfCounter(): PerfCounter;
  39361. /**
  39362. * Gets the total number of active bones rendered per frame
  39363. * @returns the total number of active bones rendered per frame
  39364. */
  39365. getActiveBones(): number;
  39366. /**
  39367. * Gets the performance counter for active bones
  39368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39369. */
  39370. get activeBonesPerfCounter(): PerfCounter;
  39371. /**
  39372. * Gets the array of active meshes
  39373. * @returns an array of AbstractMesh
  39374. */
  39375. getActiveMeshes(): SmartArray<AbstractMesh>;
  39376. /**
  39377. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39378. * @returns a number
  39379. */
  39380. getAnimationRatio(): number;
  39381. /**
  39382. * Gets an unique Id for the current render phase
  39383. * @returns a number
  39384. */
  39385. getRenderId(): number;
  39386. /**
  39387. * Gets an unique Id for the current frame
  39388. * @returns a number
  39389. */
  39390. getFrameId(): number;
  39391. /** Call this function if you want to manually increment the render Id*/
  39392. incrementRenderId(): void;
  39393. private _createUbo;
  39394. /**
  39395. * Use this method to simulate a pointer move on a mesh
  39396. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39397. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39398. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39399. * @returns the current scene
  39400. */
  39401. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39402. /**
  39403. * Use this method to simulate a pointer down on a mesh
  39404. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39405. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39406. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39407. * @returns the current scene
  39408. */
  39409. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39410. /**
  39411. * Use this method to simulate a pointer up on a mesh
  39412. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39413. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39414. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39415. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39416. * @returns the current scene
  39417. */
  39418. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39419. /**
  39420. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39421. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39422. * @returns true if the pointer was captured
  39423. */
  39424. isPointerCaptured(pointerId?: number): boolean;
  39425. /**
  39426. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39427. * @param attachUp defines if you want to attach events to pointerup
  39428. * @param attachDown defines if you want to attach events to pointerdown
  39429. * @param attachMove defines if you want to attach events to pointermove
  39430. */
  39431. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39432. /** Detaches all event handlers*/
  39433. detachControl(): void;
  39434. /**
  39435. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39436. * Delay loaded resources are not taking in account
  39437. * @return true if all required resources are ready
  39438. */
  39439. isReady(): boolean;
  39440. /** Resets all cached information relative to material (including effect and visibility) */
  39441. resetCachedMaterial(): void;
  39442. /**
  39443. * Registers a function to be called before every frame render
  39444. * @param func defines the function to register
  39445. */
  39446. registerBeforeRender(func: () => void): void;
  39447. /**
  39448. * Unregisters a function called before every frame render
  39449. * @param func defines the function to unregister
  39450. */
  39451. unregisterBeforeRender(func: () => void): void;
  39452. /**
  39453. * Registers a function to be called after every frame render
  39454. * @param func defines the function to register
  39455. */
  39456. registerAfterRender(func: () => void): void;
  39457. /**
  39458. * Unregisters a function called after every frame render
  39459. * @param func defines the function to unregister
  39460. */
  39461. unregisterAfterRender(func: () => void): void;
  39462. private _executeOnceBeforeRender;
  39463. /**
  39464. * The provided function will run before render once and will be disposed afterwards.
  39465. * A timeout delay can be provided so that the function will be executed in N ms.
  39466. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39467. * @param func The function to be executed.
  39468. * @param timeout optional delay in ms
  39469. */
  39470. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39471. /** @hidden */
  39472. _addPendingData(data: any): void;
  39473. /** @hidden */
  39474. _removePendingData(data: any): void;
  39475. /**
  39476. * Returns the number of items waiting to be loaded
  39477. * @returns the number of items waiting to be loaded
  39478. */
  39479. getWaitingItemsCount(): number;
  39480. /**
  39481. * Returns a boolean indicating if the scene is still loading data
  39482. */
  39483. get isLoading(): boolean;
  39484. /**
  39485. * Registers a function to be executed when the scene is ready
  39486. * @param {Function} func - the function to be executed
  39487. */
  39488. executeWhenReady(func: () => void): void;
  39489. /**
  39490. * Returns a promise that resolves when the scene is ready
  39491. * @returns A promise that resolves when the scene is ready
  39492. */
  39493. whenReadyAsync(): Promise<void>;
  39494. /** @hidden */
  39495. _checkIsReady(): void;
  39496. /**
  39497. * Gets all animatable attached to the scene
  39498. */
  39499. get animatables(): Animatable[];
  39500. /**
  39501. * Resets the last animation time frame.
  39502. * Useful to override when animations start running when loading a scene for the first time.
  39503. */
  39504. resetLastAnimationTimeFrame(): void;
  39505. /**
  39506. * Gets the current view matrix
  39507. * @returns a Matrix
  39508. */
  39509. getViewMatrix(): Matrix;
  39510. /**
  39511. * Gets the current projection matrix
  39512. * @returns a Matrix
  39513. */
  39514. getProjectionMatrix(): Matrix;
  39515. /**
  39516. * Gets the current transform matrix
  39517. * @returns a Matrix made of View * Projection
  39518. */
  39519. getTransformMatrix(): Matrix;
  39520. /**
  39521. * Sets the current transform matrix
  39522. * @param viewL defines the View matrix to use
  39523. * @param projectionL defines the Projection matrix to use
  39524. * @param viewR defines the right View matrix to use (if provided)
  39525. * @param projectionR defines the right Projection matrix to use (if provided)
  39526. */
  39527. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39528. /**
  39529. * Gets the uniform buffer used to store scene data
  39530. * @returns a UniformBuffer
  39531. */
  39532. getSceneUniformBuffer(): UniformBuffer;
  39533. /**
  39534. * Gets an unique (relatively to the current scene) Id
  39535. * @returns an unique number for the scene
  39536. */
  39537. getUniqueId(): number;
  39538. /**
  39539. * Add a mesh to the list of scene's meshes
  39540. * @param newMesh defines the mesh to add
  39541. * @param recursive if all child meshes should also be added to the scene
  39542. */
  39543. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39544. /**
  39545. * Remove a mesh for the list of scene's meshes
  39546. * @param toRemove defines the mesh to remove
  39547. * @param recursive if all child meshes should also be removed from the scene
  39548. * @returns the index where the mesh was in the mesh list
  39549. */
  39550. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39551. /**
  39552. * Add a transform node to the list of scene's transform nodes
  39553. * @param newTransformNode defines the transform node to add
  39554. */
  39555. addTransformNode(newTransformNode: TransformNode): void;
  39556. /**
  39557. * Remove a transform node for the list of scene's transform nodes
  39558. * @param toRemove defines the transform node to remove
  39559. * @returns the index where the transform node was in the transform node list
  39560. */
  39561. removeTransformNode(toRemove: TransformNode): number;
  39562. /**
  39563. * Remove a skeleton for the list of scene's skeletons
  39564. * @param toRemove defines the skeleton to remove
  39565. * @returns the index where the skeleton was in the skeleton list
  39566. */
  39567. removeSkeleton(toRemove: Skeleton): number;
  39568. /**
  39569. * Remove a morph target for the list of scene's morph targets
  39570. * @param toRemove defines the morph target to remove
  39571. * @returns the index where the morph target was in the morph target list
  39572. */
  39573. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39574. /**
  39575. * Remove a light for the list of scene's lights
  39576. * @param toRemove defines the light to remove
  39577. * @returns the index where the light was in the light list
  39578. */
  39579. removeLight(toRemove: Light): number;
  39580. /**
  39581. * Remove a camera for the list of scene's cameras
  39582. * @param toRemove defines the camera to remove
  39583. * @returns the index where the camera was in the camera list
  39584. */
  39585. removeCamera(toRemove: Camera): number;
  39586. /**
  39587. * Remove a particle system for the list of scene's particle systems
  39588. * @param toRemove defines the particle system to remove
  39589. * @returns the index where the particle system was in the particle system list
  39590. */
  39591. removeParticleSystem(toRemove: IParticleSystem): number;
  39592. /**
  39593. * Remove a animation for the list of scene's animations
  39594. * @param toRemove defines the animation to remove
  39595. * @returns the index where the animation was in the animation list
  39596. */
  39597. removeAnimation(toRemove: Animation): number;
  39598. /**
  39599. * Will stop the animation of the given target
  39600. * @param target - the target
  39601. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39602. * @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)
  39603. */
  39604. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39605. /**
  39606. * Removes the given animation group from this scene.
  39607. * @param toRemove The animation group to remove
  39608. * @returns The index of the removed animation group
  39609. */
  39610. removeAnimationGroup(toRemove: AnimationGroup): number;
  39611. /**
  39612. * Removes the given multi-material from this scene.
  39613. * @param toRemove The multi-material to remove
  39614. * @returns The index of the removed multi-material
  39615. */
  39616. removeMultiMaterial(toRemove: MultiMaterial): number;
  39617. /**
  39618. * Removes the given material from this scene.
  39619. * @param toRemove The material to remove
  39620. * @returns The index of the removed material
  39621. */
  39622. removeMaterial(toRemove: Material): number;
  39623. /**
  39624. * Removes the given action manager from this scene.
  39625. * @param toRemove The action manager to remove
  39626. * @returns The index of the removed action manager
  39627. */
  39628. removeActionManager(toRemove: AbstractActionManager): number;
  39629. /**
  39630. * Removes the given texture from this scene.
  39631. * @param toRemove The texture to remove
  39632. * @returns The index of the removed texture
  39633. */
  39634. removeTexture(toRemove: BaseTexture): number;
  39635. /**
  39636. * Adds the given light to this scene
  39637. * @param newLight The light to add
  39638. */
  39639. addLight(newLight: Light): void;
  39640. /**
  39641. * Sorts the list list based on light priorities
  39642. */
  39643. sortLightsByPriority(): void;
  39644. /**
  39645. * Adds the given camera to this scene
  39646. * @param newCamera The camera to add
  39647. */
  39648. addCamera(newCamera: Camera): void;
  39649. /**
  39650. * Adds the given skeleton to this scene
  39651. * @param newSkeleton The skeleton to add
  39652. */
  39653. addSkeleton(newSkeleton: Skeleton): void;
  39654. /**
  39655. * Adds the given particle system to this scene
  39656. * @param newParticleSystem The particle system to add
  39657. */
  39658. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39659. /**
  39660. * Adds the given animation to this scene
  39661. * @param newAnimation The animation to add
  39662. */
  39663. addAnimation(newAnimation: Animation): void;
  39664. /**
  39665. * Adds the given animation group to this scene.
  39666. * @param newAnimationGroup The animation group to add
  39667. */
  39668. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39669. /**
  39670. * Adds the given multi-material to this scene
  39671. * @param newMultiMaterial The multi-material to add
  39672. */
  39673. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39674. /**
  39675. * Adds the given material to this scene
  39676. * @param newMaterial The material to add
  39677. */
  39678. addMaterial(newMaterial: Material): void;
  39679. /**
  39680. * Adds the given morph target to this scene
  39681. * @param newMorphTargetManager The morph target to add
  39682. */
  39683. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39684. /**
  39685. * Adds the given geometry to this scene
  39686. * @param newGeometry The geometry to add
  39687. */
  39688. addGeometry(newGeometry: Geometry): void;
  39689. /**
  39690. * Adds the given action manager to this scene
  39691. * @param newActionManager The action manager to add
  39692. */
  39693. addActionManager(newActionManager: AbstractActionManager): void;
  39694. /**
  39695. * Adds the given texture to this scene.
  39696. * @param newTexture The texture to add
  39697. */
  39698. addTexture(newTexture: BaseTexture): void;
  39699. /**
  39700. * Switch active camera
  39701. * @param newCamera defines the new active camera
  39702. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39703. */
  39704. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39705. /**
  39706. * sets the active camera of the scene using its ID
  39707. * @param id defines the camera's ID
  39708. * @return the new active camera or null if none found.
  39709. */
  39710. setActiveCameraByID(id: string): Nullable<Camera>;
  39711. /**
  39712. * sets the active camera of the scene using its name
  39713. * @param name defines the camera's name
  39714. * @returns the new active camera or null if none found.
  39715. */
  39716. setActiveCameraByName(name: string): Nullable<Camera>;
  39717. /**
  39718. * get an animation group using its name
  39719. * @param name defines the material's name
  39720. * @return the animation group or null if none found.
  39721. */
  39722. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39723. /**
  39724. * Get a material using its unique id
  39725. * @param uniqueId defines the material's unique id
  39726. * @return the material or null if none found.
  39727. */
  39728. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39729. /**
  39730. * get a material using its id
  39731. * @param id defines the material's ID
  39732. * @return the material or null if none found.
  39733. */
  39734. getMaterialByID(id: string): Nullable<Material>;
  39735. /**
  39736. * Gets a the last added material using a given id
  39737. * @param id defines the material's ID
  39738. * @return the last material with the given id or null if none found.
  39739. */
  39740. getLastMaterialByID(id: string): Nullable<Material>;
  39741. /**
  39742. * Gets a material using its name
  39743. * @param name defines the material's name
  39744. * @return the material or null if none found.
  39745. */
  39746. getMaterialByName(name: string): Nullable<Material>;
  39747. /**
  39748. * Get a texture using its unique id
  39749. * @param uniqueId defines the texture's unique id
  39750. * @return the texture or null if none found.
  39751. */
  39752. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39753. /**
  39754. * Gets a camera using its id
  39755. * @param id defines the id to look for
  39756. * @returns the camera or null if not found
  39757. */
  39758. getCameraByID(id: string): Nullable<Camera>;
  39759. /**
  39760. * Gets a camera using its unique id
  39761. * @param uniqueId defines the unique id to look for
  39762. * @returns the camera or null if not found
  39763. */
  39764. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39765. /**
  39766. * Gets a camera using its name
  39767. * @param name defines the camera's name
  39768. * @return the camera or null if none found.
  39769. */
  39770. getCameraByName(name: string): Nullable<Camera>;
  39771. /**
  39772. * Gets a bone using its id
  39773. * @param id defines the bone's id
  39774. * @return the bone or null if not found
  39775. */
  39776. getBoneByID(id: string): Nullable<Bone>;
  39777. /**
  39778. * Gets a bone using its id
  39779. * @param name defines the bone's name
  39780. * @return the bone or null if not found
  39781. */
  39782. getBoneByName(name: string): Nullable<Bone>;
  39783. /**
  39784. * Gets a light node using its name
  39785. * @param name defines the the light's name
  39786. * @return the light or null if none found.
  39787. */
  39788. getLightByName(name: string): Nullable<Light>;
  39789. /**
  39790. * Gets a light node using its id
  39791. * @param id defines the light's id
  39792. * @return the light or null if none found.
  39793. */
  39794. getLightByID(id: string): Nullable<Light>;
  39795. /**
  39796. * Gets a light node using its scene-generated unique ID
  39797. * @param uniqueId defines the light's unique id
  39798. * @return the light or null if none found.
  39799. */
  39800. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39801. /**
  39802. * Gets a particle system by id
  39803. * @param id defines the particle system id
  39804. * @return the corresponding system or null if none found
  39805. */
  39806. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39807. /**
  39808. * Gets a geometry using its ID
  39809. * @param id defines the geometry's id
  39810. * @return the geometry or null if none found.
  39811. */
  39812. getGeometryByID(id: string): Nullable<Geometry>;
  39813. private _getGeometryByUniqueID;
  39814. /**
  39815. * Add a new geometry to this scene
  39816. * @param geometry defines the geometry to be added to the scene.
  39817. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39818. * @return a boolean defining if the geometry was added or not
  39819. */
  39820. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39821. /**
  39822. * Removes an existing geometry
  39823. * @param geometry defines the geometry to be removed from the scene
  39824. * @return a boolean defining if the geometry was removed or not
  39825. */
  39826. removeGeometry(geometry: Geometry): boolean;
  39827. /**
  39828. * Gets the list of geometries attached to the scene
  39829. * @returns an array of Geometry
  39830. */
  39831. getGeometries(): Geometry[];
  39832. /**
  39833. * Gets the first added mesh found of a given ID
  39834. * @param id defines the id to search for
  39835. * @return the mesh found or null if not found at all
  39836. */
  39837. getMeshByID(id: string): Nullable<AbstractMesh>;
  39838. /**
  39839. * Gets a list of meshes using their id
  39840. * @param id defines the id to search for
  39841. * @returns a list of meshes
  39842. */
  39843. getMeshesByID(id: string): Array<AbstractMesh>;
  39844. /**
  39845. * Gets the first added transform node found of a given ID
  39846. * @param id defines the id to search for
  39847. * @return the found transform node or null if not found at all.
  39848. */
  39849. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39850. /**
  39851. * Gets a transform node with its auto-generated unique id
  39852. * @param uniqueId efines the unique id to search for
  39853. * @return the found transform node or null if not found at all.
  39854. */
  39855. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39856. /**
  39857. * Gets a list of transform nodes using their id
  39858. * @param id defines the id to search for
  39859. * @returns a list of transform nodes
  39860. */
  39861. getTransformNodesByID(id: string): Array<TransformNode>;
  39862. /**
  39863. * Gets a mesh with its auto-generated unique id
  39864. * @param uniqueId defines the unique id to search for
  39865. * @return the found mesh or null if not found at all.
  39866. */
  39867. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39868. /**
  39869. * Gets a the last added mesh using a given id
  39870. * @param id defines the id to search for
  39871. * @return the found mesh or null if not found at all.
  39872. */
  39873. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39874. /**
  39875. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39876. * @param id defines the id to search for
  39877. * @return the found node or null if not found at all
  39878. */
  39879. getLastEntryByID(id: string): Nullable<Node>;
  39880. /**
  39881. * Gets a node (Mesh, Camera, Light) using a given id
  39882. * @param id defines the id to search for
  39883. * @return the found node or null if not found at all
  39884. */
  39885. getNodeByID(id: string): Nullable<Node>;
  39886. /**
  39887. * Gets a node (Mesh, Camera, Light) using a given name
  39888. * @param name defines the name to search for
  39889. * @return the found node or null if not found at all.
  39890. */
  39891. getNodeByName(name: string): Nullable<Node>;
  39892. /**
  39893. * Gets a mesh using a given name
  39894. * @param name defines the name to search for
  39895. * @return the found mesh or null if not found at all.
  39896. */
  39897. getMeshByName(name: string): Nullable<AbstractMesh>;
  39898. /**
  39899. * Gets a transform node using a given name
  39900. * @param name defines the name to search for
  39901. * @return the found transform node or null if not found at all.
  39902. */
  39903. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39904. /**
  39905. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39906. * @param id defines the id to search for
  39907. * @return the found skeleton or null if not found at all.
  39908. */
  39909. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39910. /**
  39911. * Gets a skeleton using a given auto generated unique id
  39912. * @param uniqueId defines the unique id to search for
  39913. * @return the found skeleton or null if not found at all.
  39914. */
  39915. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39916. /**
  39917. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39918. * @param id defines the id to search for
  39919. * @return the found skeleton or null if not found at all.
  39920. */
  39921. getSkeletonById(id: string): Nullable<Skeleton>;
  39922. /**
  39923. * Gets a skeleton using a given name
  39924. * @param name defines the name to search for
  39925. * @return the found skeleton or null if not found at all.
  39926. */
  39927. getSkeletonByName(name: string): Nullable<Skeleton>;
  39928. /**
  39929. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39930. * @param id defines the id to search for
  39931. * @return the found morph target manager or null if not found at all.
  39932. */
  39933. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39934. /**
  39935. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39936. * @param id defines the id to search for
  39937. * @return the found morph target or null if not found at all.
  39938. */
  39939. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39940. /**
  39941. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39942. * @param name defines the name to search for
  39943. * @return the found morph target or null if not found at all.
  39944. */
  39945. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39946. /**
  39947. * Gets a boolean indicating if the given mesh is active
  39948. * @param mesh defines the mesh to look for
  39949. * @returns true if the mesh is in the active list
  39950. */
  39951. isActiveMesh(mesh: AbstractMesh): boolean;
  39952. /**
  39953. * Return a unique id as a string which can serve as an identifier for the scene
  39954. */
  39955. get uid(): string;
  39956. /**
  39957. * Add an externaly attached data from its key.
  39958. * This method call will fail and return false, if such key already exists.
  39959. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39960. * @param key the unique key that identifies the data
  39961. * @param data the data object to associate to the key for this Engine instance
  39962. * @return true if no such key were already present and the data was added successfully, false otherwise
  39963. */
  39964. addExternalData<T>(key: string, data: T): boolean;
  39965. /**
  39966. * Get an externaly attached data from its key
  39967. * @param key the unique key that identifies the data
  39968. * @return the associated data, if present (can be null), or undefined if not present
  39969. */
  39970. getExternalData<T>(key: string): Nullable<T>;
  39971. /**
  39972. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39973. * @param key the unique key that identifies the data
  39974. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39975. * @return the associated data, can be null if the factory returned null.
  39976. */
  39977. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39978. /**
  39979. * Remove an externaly attached data from the Engine instance
  39980. * @param key the unique key that identifies the data
  39981. * @return true if the data was successfully removed, false if it doesn't exist
  39982. */
  39983. removeExternalData(key: string): boolean;
  39984. private _evaluateSubMesh;
  39985. /**
  39986. * Clear the processed materials smart array preventing retention point in material dispose.
  39987. */
  39988. freeProcessedMaterials(): void;
  39989. private _preventFreeActiveMeshesAndRenderingGroups;
  39990. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39991. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39992. * when disposing several meshes in a row or a hierarchy of meshes.
  39993. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39994. */
  39995. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39996. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39997. /**
  39998. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39999. */
  40000. freeActiveMeshes(): void;
  40001. /**
  40002. * Clear the info related to rendering groups preventing retention points during dispose.
  40003. */
  40004. freeRenderingGroups(): void;
  40005. /** @hidden */
  40006. _isInIntermediateRendering(): boolean;
  40007. /**
  40008. * Lambda returning the list of potentially active meshes.
  40009. */
  40010. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40011. /**
  40012. * Lambda returning the list of potentially active sub meshes.
  40013. */
  40014. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40015. /**
  40016. * Lambda returning the list of potentially intersecting sub meshes.
  40017. */
  40018. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40019. /**
  40020. * Lambda returning the list of potentially colliding sub meshes.
  40021. */
  40022. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40023. private _activeMeshesFrozen;
  40024. private _skipEvaluateActiveMeshesCompletely;
  40025. /**
  40026. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40027. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40028. * @returns the current scene
  40029. */
  40030. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40031. /**
  40032. * Use this function to restart evaluating active meshes on every frame
  40033. * @returns the current scene
  40034. */
  40035. unfreezeActiveMeshes(): Scene;
  40036. private _evaluateActiveMeshes;
  40037. private _activeMesh;
  40038. /**
  40039. * Update the transform matrix to update from the current active camera
  40040. * @param force defines a boolean used to force the update even if cache is up to date
  40041. */
  40042. updateTransformMatrix(force?: boolean): void;
  40043. private _bindFrameBuffer;
  40044. /** @hidden */
  40045. _allowPostProcessClearColor: boolean;
  40046. /** @hidden */
  40047. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40048. private _processSubCameras;
  40049. private _checkIntersections;
  40050. /** @hidden */
  40051. _advancePhysicsEngineStep(step: number): void;
  40052. /**
  40053. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40054. */
  40055. getDeterministicFrameTime: () => number;
  40056. /** @hidden */
  40057. _animate(): void;
  40058. /** Execute all animations (for a frame) */
  40059. animate(): void;
  40060. /**
  40061. * Render the scene
  40062. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40063. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40064. */
  40065. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40066. /**
  40067. * Freeze all materials
  40068. * A frozen material will not be updatable but should be faster to render
  40069. */
  40070. freezeMaterials(): void;
  40071. /**
  40072. * Unfreeze all materials
  40073. * A frozen material will not be updatable but should be faster to render
  40074. */
  40075. unfreezeMaterials(): void;
  40076. /**
  40077. * Releases all held ressources
  40078. */
  40079. dispose(): void;
  40080. /**
  40081. * Gets if the scene is already disposed
  40082. */
  40083. get isDisposed(): boolean;
  40084. /**
  40085. * Call this function to reduce memory footprint of the scene.
  40086. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40087. */
  40088. clearCachedVertexData(): void;
  40089. /**
  40090. * This function will remove the local cached buffer data from texture.
  40091. * It will save memory but will prevent the texture from being rebuilt
  40092. */
  40093. cleanCachedTextureBuffer(): void;
  40094. /**
  40095. * Get the world extend vectors with an optional filter
  40096. *
  40097. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40098. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40099. */
  40100. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40101. min: Vector3;
  40102. max: Vector3;
  40103. };
  40104. /**
  40105. * Creates a ray that can be used to pick in the scene
  40106. * @param x defines the x coordinate of the origin (on-screen)
  40107. * @param y defines the y coordinate of the origin (on-screen)
  40108. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40109. * @param camera defines the camera to use for the picking
  40110. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40111. * @returns a Ray
  40112. */
  40113. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40114. /**
  40115. * Creates a ray that can be used to pick in the scene
  40116. * @param x defines the x coordinate of the origin (on-screen)
  40117. * @param y defines the y coordinate of the origin (on-screen)
  40118. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40119. * @param result defines the ray where to store the picking ray
  40120. * @param camera defines the camera to use for the picking
  40121. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40122. * @returns the current scene
  40123. */
  40124. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40125. /**
  40126. * Creates a ray that can be used to pick in the scene
  40127. * @param x defines the x coordinate of the origin (on-screen)
  40128. * @param y defines the y coordinate of the origin (on-screen)
  40129. * @param camera defines the camera to use for the picking
  40130. * @returns a Ray
  40131. */
  40132. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40133. /**
  40134. * Creates a ray that can be used to pick in the scene
  40135. * @param x defines the x coordinate of the origin (on-screen)
  40136. * @param y defines the y coordinate of the origin (on-screen)
  40137. * @param result defines the ray where to store the picking ray
  40138. * @param camera defines the camera to use for the picking
  40139. * @returns the current scene
  40140. */
  40141. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40142. /** Launch a ray to try to pick a mesh in the scene
  40143. * @param x position on screen
  40144. * @param y position on screen
  40145. * @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
  40146. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40147. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40148. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40149. * @returns a PickingInfo
  40150. */
  40151. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40152. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40153. * @param x position on screen
  40154. * @param y position on screen
  40155. * @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
  40156. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40157. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40158. * @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)
  40159. */
  40160. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40161. /** Use the given ray to pick a mesh in the scene
  40162. * @param ray The ray to use to pick meshes
  40163. * @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
  40164. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40165. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40166. * @returns a PickingInfo
  40167. */
  40168. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40169. /**
  40170. * Launch a ray to try to pick a mesh in the scene
  40171. * @param x X position on screen
  40172. * @param y Y position on screen
  40173. * @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
  40174. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40175. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40176. * @returns an array of PickingInfo
  40177. */
  40178. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40179. /**
  40180. * Launch a ray to try to pick a mesh in the scene
  40181. * @param ray Ray to use
  40182. * @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
  40183. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40184. * @returns an array of PickingInfo
  40185. */
  40186. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40187. /**
  40188. * Force the value of meshUnderPointer
  40189. * @param mesh defines the mesh to use
  40190. */
  40191. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40192. /**
  40193. * Gets the mesh under the pointer
  40194. * @returns a Mesh or null if no mesh is under the pointer
  40195. */
  40196. getPointerOverMesh(): Nullable<AbstractMesh>;
  40197. /** @hidden */
  40198. _rebuildGeometries(): void;
  40199. /** @hidden */
  40200. _rebuildTextures(): void;
  40201. private _getByTags;
  40202. /**
  40203. * Get a list of meshes by tags
  40204. * @param tagsQuery defines the tags query to use
  40205. * @param forEach defines a predicate used to filter results
  40206. * @returns an array of Mesh
  40207. */
  40208. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40209. /**
  40210. * Get a list of cameras by tags
  40211. * @param tagsQuery defines the tags query to use
  40212. * @param forEach defines a predicate used to filter results
  40213. * @returns an array of Camera
  40214. */
  40215. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40216. /**
  40217. * Get a list of lights by tags
  40218. * @param tagsQuery defines the tags query to use
  40219. * @param forEach defines a predicate used to filter results
  40220. * @returns an array of Light
  40221. */
  40222. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40223. /**
  40224. * Get a list of materials by tags
  40225. * @param tagsQuery defines the tags query to use
  40226. * @param forEach defines a predicate used to filter results
  40227. * @returns an array of Material
  40228. */
  40229. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40230. /**
  40231. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40232. * This allowed control for front to back rendering or reversly depending of the special needs.
  40233. *
  40234. * @param renderingGroupId The rendering group id corresponding to its index
  40235. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40236. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40237. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40238. */
  40239. 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;
  40240. /**
  40241. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40242. *
  40243. * @param renderingGroupId The rendering group id corresponding to its index
  40244. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40245. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40246. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40247. */
  40248. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40249. /**
  40250. * Gets the current auto clear configuration for one rendering group of the rendering
  40251. * manager.
  40252. * @param index the rendering group index to get the information for
  40253. * @returns The auto clear setup for the requested rendering group
  40254. */
  40255. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40256. private _blockMaterialDirtyMechanism;
  40257. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40258. get blockMaterialDirtyMechanism(): boolean;
  40259. set blockMaterialDirtyMechanism(value: boolean);
  40260. /**
  40261. * Will flag all materials as dirty to trigger new shader compilation
  40262. * @param flag defines the flag used to specify which material part must be marked as dirty
  40263. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40264. */
  40265. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40266. /** @hidden */
  40267. _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;
  40268. /** @hidden */
  40269. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40270. /** @hidden */
  40271. _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;
  40272. /** @hidden */
  40273. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40274. /** @hidden */
  40275. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40276. /** @hidden */
  40277. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40278. }
  40279. }
  40280. declare module BABYLON {
  40281. /**
  40282. * Set of assets to keep when moving a scene into an asset container.
  40283. */
  40284. export class KeepAssets extends AbstractScene {
  40285. }
  40286. /**
  40287. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40288. */
  40289. export class InstantiatedEntries {
  40290. /**
  40291. * List of new root nodes (eg. nodes with no parent)
  40292. */
  40293. rootNodes: TransformNode[];
  40294. /**
  40295. * List of new skeletons
  40296. */
  40297. skeletons: Skeleton[];
  40298. /**
  40299. * List of new animation groups
  40300. */
  40301. animationGroups: AnimationGroup[];
  40302. }
  40303. /**
  40304. * Container with a set of assets that can be added or removed from a scene.
  40305. */
  40306. export class AssetContainer extends AbstractScene {
  40307. private _wasAddedToScene;
  40308. /**
  40309. * The scene the AssetContainer belongs to.
  40310. */
  40311. scene: Scene;
  40312. /**
  40313. * Instantiates an AssetContainer.
  40314. * @param scene The scene the AssetContainer belongs to.
  40315. */
  40316. constructor(scene: Scene);
  40317. /**
  40318. * Instantiate or clone all meshes and add the new ones to the scene.
  40319. * Skeletons and animation groups will all be cloned
  40320. * @param nameFunction defines an optional function used to get new names for clones
  40321. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40322. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40323. */
  40324. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40325. /**
  40326. * Adds all the assets from the container to the scene.
  40327. */
  40328. addAllToScene(): void;
  40329. /**
  40330. * Removes all the assets in the container from the scene
  40331. */
  40332. removeAllFromScene(): void;
  40333. /**
  40334. * Disposes all the assets in the container
  40335. */
  40336. dispose(): void;
  40337. private _moveAssets;
  40338. /**
  40339. * Removes all the assets contained in the scene and adds them to the container.
  40340. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40341. */
  40342. moveAllFromScene(keepAssets?: KeepAssets): void;
  40343. /**
  40344. * 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.
  40345. * @returns the root mesh
  40346. */
  40347. createRootMesh(): Mesh;
  40348. /**
  40349. * Merge animations (direct and animation groups) from this asset container into a scene
  40350. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40351. * @param animatables set of animatables to retarget to a node from the scene
  40352. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40353. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40354. */
  40355. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40356. }
  40357. }
  40358. declare module BABYLON {
  40359. /**
  40360. * Defines how the parser contract is defined.
  40361. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40362. */
  40363. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40364. /**
  40365. * Defines how the individual parser contract is defined.
  40366. * These parser can parse an individual asset
  40367. */
  40368. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40369. /**
  40370. * Base class of the scene acting as a container for the different elements composing a scene.
  40371. * This class is dynamically extended by the different components of the scene increasing
  40372. * flexibility and reducing coupling
  40373. */
  40374. export abstract class AbstractScene {
  40375. /**
  40376. * Stores the list of available parsers in the application.
  40377. */
  40378. private static _BabylonFileParsers;
  40379. /**
  40380. * Stores the list of available individual parsers in the application.
  40381. */
  40382. private static _IndividualBabylonFileParsers;
  40383. /**
  40384. * Adds a parser in the list of available ones
  40385. * @param name Defines the name of the parser
  40386. * @param parser Defines the parser to add
  40387. */
  40388. static AddParser(name: string, parser: BabylonFileParser): void;
  40389. /**
  40390. * Gets a general parser from the list of avaialble ones
  40391. * @param name Defines the name of the parser
  40392. * @returns the requested parser or null
  40393. */
  40394. static GetParser(name: string): Nullable<BabylonFileParser>;
  40395. /**
  40396. * Adds n individual parser in the list of available ones
  40397. * @param name Defines the name of the parser
  40398. * @param parser Defines the parser to add
  40399. */
  40400. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40401. /**
  40402. * Gets an individual parser from the list of avaialble ones
  40403. * @param name Defines the name of the parser
  40404. * @returns the requested parser or null
  40405. */
  40406. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40407. /**
  40408. * Parser json data and populate both a scene and its associated container object
  40409. * @param jsonData Defines the data to parse
  40410. * @param scene Defines the scene to parse the data for
  40411. * @param container Defines the container attached to the parsing sequence
  40412. * @param rootUrl Defines the root url of the data
  40413. */
  40414. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40415. /**
  40416. * Gets the list of root nodes (ie. nodes with no parent)
  40417. */
  40418. rootNodes: Node[];
  40419. /** All of the cameras added to this scene
  40420. * @see http://doc.babylonjs.com/babylon101/cameras
  40421. */
  40422. cameras: Camera[];
  40423. /**
  40424. * All of the lights added to this scene
  40425. * @see http://doc.babylonjs.com/babylon101/lights
  40426. */
  40427. lights: Light[];
  40428. /**
  40429. * All of the (abstract) meshes added to this scene
  40430. */
  40431. meshes: AbstractMesh[];
  40432. /**
  40433. * The list of skeletons added to the scene
  40434. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40435. */
  40436. skeletons: Skeleton[];
  40437. /**
  40438. * All of the particle systems added to this scene
  40439. * @see http://doc.babylonjs.com/babylon101/particles
  40440. */
  40441. particleSystems: IParticleSystem[];
  40442. /**
  40443. * Gets a list of Animations associated with the scene
  40444. */
  40445. animations: Animation[];
  40446. /**
  40447. * All of the animation groups added to this scene
  40448. * @see http://doc.babylonjs.com/how_to/group
  40449. */
  40450. animationGroups: AnimationGroup[];
  40451. /**
  40452. * All of the multi-materials added to this scene
  40453. * @see http://doc.babylonjs.com/how_to/multi_materials
  40454. */
  40455. multiMaterials: MultiMaterial[];
  40456. /**
  40457. * All of the materials added to this scene
  40458. * In the context of a Scene, it is not supposed to be modified manually.
  40459. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40460. * Note also that the order of the Material within the array is not significant and might change.
  40461. * @see http://doc.babylonjs.com/babylon101/materials
  40462. */
  40463. materials: Material[];
  40464. /**
  40465. * The list of morph target managers added to the scene
  40466. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40467. */
  40468. morphTargetManagers: MorphTargetManager[];
  40469. /**
  40470. * The list of geometries used in the scene.
  40471. */
  40472. geometries: Geometry[];
  40473. /**
  40474. * All of the tranform nodes added to this scene
  40475. * In the context of a Scene, it is not supposed to be modified manually.
  40476. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40477. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40478. * @see http://doc.babylonjs.com/how_to/transformnode
  40479. */
  40480. transformNodes: TransformNode[];
  40481. /**
  40482. * ActionManagers available on the scene.
  40483. */
  40484. actionManagers: AbstractActionManager[];
  40485. /**
  40486. * Textures to keep.
  40487. */
  40488. textures: BaseTexture[];
  40489. /**
  40490. * Environment texture for the scene
  40491. */
  40492. environmentTexture: Nullable<BaseTexture>;
  40493. /**
  40494. * @returns all meshes, lights, cameras, transformNodes and bones
  40495. */
  40496. getNodes(): Array<Node>;
  40497. }
  40498. }
  40499. declare module BABYLON {
  40500. /**
  40501. * Interface used to define options for Sound class
  40502. */
  40503. export interface ISoundOptions {
  40504. /**
  40505. * Does the sound autoplay once loaded.
  40506. */
  40507. autoplay?: boolean;
  40508. /**
  40509. * Does the sound loop after it finishes playing once.
  40510. */
  40511. loop?: boolean;
  40512. /**
  40513. * Sound's volume
  40514. */
  40515. volume?: number;
  40516. /**
  40517. * Is it a spatial sound?
  40518. */
  40519. spatialSound?: boolean;
  40520. /**
  40521. * Maximum distance to hear that sound
  40522. */
  40523. maxDistance?: number;
  40524. /**
  40525. * Uses user defined attenuation function
  40526. */
  40527. useCustomAttenuation?: boolean;
  40528. /**
  40529. * Define the roll off factor of spatial sounds.
  40530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40531. */
  40532. rolloffFactor?: number;
  40533. /**
  40534. * Define the reference distance the sound should be heard perfectly.
  40535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40536. */
  40537. refDistance?: number;
  40538. /**
  40539. * Define the distance attenuation model the sound will follow.
  40540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40541. */
  40542. distanceModel?: string;
  40543. /**
  40544. * Defines the playback speed (1 by default)
  40545. */
  40546. playbackRate?: number;
  40547. /**
  40548. * Defines if the sound is from a streaming source
  40549. */
  40550. streaming?: boolean;
  40551. /**
  40552. * Defines an optional length (in seconds) inside the sound file
  40553. */
  40554. length?: number;
  40555. /**
  40556. * Defines an optional offset (in seconds) inside the sound file
  40557. */
  40558. offset?: number;
  40559. /**
  40560. * If true, URLs will not be required to state the audio file codec to use.
  40561. */
  40562. skipCodecCheck?: boolean;
  40563. }
  40564. /**
  40565. * Defines a sound that can be played in the application.
  40566. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40568. */
  40569. export class Sound {
  40570. /**
  40571. * The name of the sound in the scene.
  40572. */
  40573. name: string;
  40574. /**
  40575. * Does the sound autoplay once loaded.
  40576. */
  40577. autoplay: boolean;
  40578. /**
  40579. * Does the sound loop after it finishes playing once.
  40580. */
  40581. loop: boolean;
  40582. /**
  40583. * Does the sound use a custom attenuation curve to simulate the falloff
  40584. * happening when the source gets further away from the camera.
  40585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40586. */
  40587. useCustomAttenuation: boolean;
  40588. /**
  40589. * The sound track id this sound belongs to.
  40590. */
  40591. soundTrackId: number;
  40592. /**
  40593. * Is this sound currently played.
  40594. */
  40595. isPlaying: boolean;
  40596. /**
  40597. * Is this sound currently paused.
  40598. */
  40599. isPaused: boolean;
  40600. /**
  40601. * Does this sound enables spatial sound.
  40602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40603. */
  40604. spatialSound: boolean;
  40605. /**
  40606. * Define the reference distance the sound should be heard perfectly.
  40607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40608. */
  40609. refDistance: number;
  40610. /**
  40611. * Define the roll off factor of spatial sounds.
  40612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40613. */
  40614. rolloffFactor: number;
  40615. /**
  40616. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40618. */
  40619. maxDistance: number;
  40620. /**
  40621. * Define the distance attenuation model the sound will follow.
  40622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40623. */
  40624. distanceModel: string;
  40625. /**
  40626. * @hidden
  40627. * Back Compat
  40628. **/
  40629. onended: () => any;
  40630. /**
  40631. * Gets or sets an object used to store user defined information for the sound.
  40632. */
  40633. metadata: any;
  40634. /**
  40635. * Observable event when the current playing sound finishes.
  40636. */
  40637. onEndedObservable: Observable<Sound>;
  40638. private _panningModel;
  40639. private _playbackRate;
  40640. private _streaming;
  40641. private _startTime;
  40642. private _startOffset;
  40643. private _position;
  40644. /** @hidden */
  40645. _positionInEmitterSpace: boolean;
  40646. private _localDirection;
  40647. private _volume;
  40648. private _isReadyToPlay;
  40649. private _isDirectional;
  40650. private _readyToPlayCallback;
  40651. private _audioBuffer;
  40652. private _soundSource;
  40653. private _streamingSource;
  40654. private _soundPanner;
  40655. private _soundGain;
  40656. private _inputAudioNode;
  40657. private _outputAudioNode;
  40658. private _coneInnerAngle;
  40659. private _coneOuterAngle;
  40660. private _coneOuterGain;
  40661. private _scene;
  40662. private _connectedTransformNode;
  40663. private _customAttenuationFunction;
  40664. private _registerFunc;
  40665. private _isOutputConnected;
  40666. private _htmlAudioElement;
  40667. private _urlType;
  40668. private _length?;
  40669. private _offset?;
  40670. /** @hidden */
  40671. static _SceneComponentInitialization: (scene: Scene) => void;
  40672. /**
  40673. * Create a sound and attach it to a scene
  40674. * @param name Name of your sound
  40675. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40676. * @param scene defines the scene the sound belongs to
  40677. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40678. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40679. */
  40680. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40681. /**
  40682. * Release the sound and its associated resources
  40683. */
  40684. dispose(): void;
  40685. /**
  40686. * Gets if the sounds is ready to be played or not.
  40687. * @returns true if ready, otherwise false
  40688. */
  40689. isReady(): boolean;
  40690. private _soundLoaded;
  40691. /**
  40692. * Sets the data of the sound from an audiobuffer
  40693. * @param audioBuffer The audioBuffer containing the data
  40694. */
  40695. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40696. /**
  40697. * Updates the current sounds options such as maxdistance, loop...
  40698. * @param options A JSON object containing values named as the object properties
  40699. */
  40700. updateOptions(options: ISoundOptions): void;
  40701. private _createSpatialParameters;
  40702. private _updateSpatialParameters;
  40703. /**
  40704. * Switch the panning model to HRTF:
  40705. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40707. */
  40708. switchPanningModelToHRTF(): void;
  40709. /**
  40710. * Switch the panning model to Equal Power:
  40711. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40713. */
  40714. switchPanningModelToEqualPower(): void;
  40715. private _switchPanningModel;
  40716. /**
  40717. * Connect this sound to a sound track audio node like gain...
  40718. * @param soundTrackAudioNode the sound track audio node to connect to
  40719. */
  40720. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40721. /**
  40722. * Transform this sound into a directional source
  40723. * @param coneInnerAngle Size of the inner cone in degree
  40724. * @param coneOuterAngle Size of the outer cone in degree
  40725. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40726. */
  40727. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40728. /**
  40729. * Gets or sets the inner angle for the directional cone.
  40730. */
  40731. get directionalConeInnerAngle(): number;
  40732. /**
  40733. * Gets or sets the inner angle for the directional cone.
  40734. */
  40735. set directionalConeInnerAngle(value: number);
  40736. /**
  40737. * Gets or sets the outer angle for the directional cone.
  40738. */
  40739. get directionalConeOuterAngle(): number;
  40740. /**
  40741. * Gets or sets the outer angle for the directional cone.
  40742. */
  40743. set directionalConeOuterAngle(value: number);
  40744. /**
  40745. * Sets the position of the emitter if spatial sound is enabled
  40746. * @param newPosition Defines the new posisiton
  40747. */
  40748. setPosition(newPosition: Vector3): void;
  40749. /**
  40750. * Sets the local direction of the emitter if spatial sound is enabled
  40751. * @param newLocalDirection Defines the new local direction
  40752. */
  40753. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40754. private _updateDirection;
  40755. /** @hidden */
  40756. updateDistanceFromListener(): void;
  40757. /**
  40758. * Sets a new custom attenuation function for the sound.
  40759. * @param callback Defines the function used for the attenuation
  40760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40761. */
  40762. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40763. /**
  40764. * Play the sound
  40765. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40766. * @param offset (optional) Start the sound at a specific time in seconds
  40767. * @param length (optional) Sound duration (in seconds)
  40768. */
  40769. play(time?: number, offset?: number, length?: number): void;
  40770. private _onended;
  40771. /**
  40772. * Stop the sound
  40773. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40774. */
  40775. stop(time?: number): void;
  40776. /**
  40777. * Put the sound in pause
  40778. */
  40779. pause(): void;
  40780. /**
  40781. * Sets a dedicated volume for this sounds
  40782. * @param newVolume Define the new volume of the sound
  40783. * @param time Define time for gradual change to new volume
  40784. */
  40785. setVolume(newVolume: number, time?: number): void;
  40786. /**
  40787. * Set the sound play back rate
  40788. * @param newPlaybackRate Define the playback rate the sound should be played at
  40789. */
  40790. setPlaybackRate(newPlaybackRate: number): void;
  40791. /**
  40792. * Gets the volume of the sound.
  40793. * @returns the volume of the sound
  40794. */
  40795. getVolume(): number;
  40796. /**
  40797. * Attach the sound to a dedicated mesh
  40798. * @param transformNode The transform node to connect the sound with
  40799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40800. */
  40801. attachToMesh(transformNode: TransformNode): void;
  40802. /**
  40803. * Detach the sound from the previously attached mesh
  40804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40805. */
  40806. detachFromMesh(): void;
  40807. private _onRegisterAfterWorldMatrixUpdate;
  40808. /**
  40809. * Clone the current sound in the scene.
  40810. * @returns the new sound clone
  40811. */
  40812. clone(): Nullable<Sound>;
  40813. /**
  40814. * Gets the current underlying audio buffer containing the data
  40815. * @returns the audio buffer
  40816. */
  40817. getAudioBuffer(): Nullable<AudioBuffer>;
  40818. /**
  40819. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40820. * @returns the source node
  40821. */
  40822. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40823. /**
  40824. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40825. * @returns the gain node
  40826. */
  40827. getSoundGain(): Nullable<GainNode>;
  40828. /**
  40829. * Serializes the Sound in a JSON representation
  40830. * @returns the JSON representation of the sound
  40831. */
  40832. serialize(): any;
  40833. /**
  40834. * Parse a JSON representation of a sound to innstantiate in a given scene
  40835. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40836. * @param scene Define the scene the new parsed sound should be created in
  40837. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40838. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40839. * @returns the newly parsed sound
  40840. */
  40841. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40842. }
  40843. }
  40844. declare module BABYLON {
  40845. /**
  40846. * This defines an action helpful to play a defined sound on a triggered action.
  40847. */
  40848. export class PlaySoundAction extends Action {
  40849. private _sound;
  40850. /**
  40851. * Instantiate the action
  40852. * @param triggerOptions defines the trigger options
  40853. * @param sound defines the sound to play
  40854. * @param condition defines the trigger related conditions
  40855. */
  40856. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40857. /** @hidden */
  40858. _prepare(): void;
  40859. /**
  40860. * Execute the action and play the sound.
  40861. */
  40862. execute(): void;
  40863. /**
  40864. * Serializes the actions and its related information.
  40865. * @param parent defines the object to serialize in
  40866. * @returns the serialized object
  40867. */
  40868. serialize(parent: any): any;
  40869. }
  40870. /**
  40871. * This defines an action helpful to stop a defined sound on a triggered action.
  40872. */
  40873. export class StopSoundAction extends Action {
  40874. private _sound;
  40875. /**
  40876. * Instantiate the action
  40877. * @param triggerOptions defines the trigger options
  40878. * @param sound defines the sound to stop
  40879. * @param condition defines the trigger related conditions
  40880. */
  40881. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40882. /** @hidden */
  40883. _prepare(): void;
  40884. /**
  40885. * Execute the action and stop the sound.
  40886. */
  40887. execute(): void;
  40888. /**
  40889. * Serializes the actions and its related information.
  40890. * @param parent defines the object to serialize in
  40891. * @returns the serialized object
  40892. */
  40893. serialize(parent: any): any;
  40894. }
  40895. }
  40896. declare module BABYLON {
  40897. /**
  40898. * This defines an action responsible to change the value of a property
  40899. * by interpolating between its current value and the newly set one once triggered.
  40900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40901. */
  40902. export class InterpolateValueAction extends Action {
  40903. /**
  40904. * Defines the path of the property where the value should be interpolated
  40905. */
  40906. propertyPath: string;
  40907. /**
  40908. * Defines the target value at the end of the interpolation.
  40909. */
  40910. value: any;
  40911. /**
  40912. * Defines the time it will take for the property to interpolate to the value.
  40913. */
  40914. duration: number;
  40915. /**
  40916. * Defines if the other scene animations should be stopped when the action has been triggered
  40917. */
  40918. stopOtherAnimations?: boolean;
  40919. /**
  40920. * Defines a callback raised once the interpolation animation has been done.
  40921. */
  40922. onInterpolationDone?: () => void;
  40923. /**
  40924. * Observable triggered once the interpolation animation has been done.
  40925. */
  40926. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40927. private _target;
  40928. private _effectiveTarget;
  40929. private _property;
  40930. /**
  40931. * Instantiate the action
  40932. * @param triggerOptions defines the trigger options
  40933. * @param target defines the object containing the value to interpolate
  40934. * @param propertyPath defines the path to the property in the target object
  40935. * @param value defines the target value at the end of the interpolation
  40936. * @param duration deines the time it will take for the property to interpolate to the value.
  40937. * @param condition defines the trigger related conditions
  40938. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40939. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40940. */
  40941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40942. /** @hidden */
  40943. _prepare(): void;
  40944. /**
  40945. * Execute the action starts the value interpolation.
  40946. */
  40947. execute(): void;
  40948. /**
  40949. * Serializes the actions and its related information.
  40950. * @param parent defines the object to serialize in
  40951. * @returns the serialized object
  40952. */
  40953. serialize(parent: any): any;
  40954. }
  40955. }
  40956. declare module BABYLON {
  40957. /**
  40958. * Options allowed during the creation of a sound track.
  40959. */
  40960. export interface ISoundTrackOptions {
  40961. /**
  40962. * The volume the sound track should take during creation
  40963. */
  40964. volume?: number;
  40965. /**
  40966. * Define if the sound track is the main sound track of the scene
  40967. */
  40968. mainTrack?: boolean;
  40969. }
  40970. /**
  40971. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40972. * It will be also used in a future release to apply effects on a specific track.
  40973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40974. */
  40975. export class SoundTrack {
  40976. /**
  40977. * The unique identifier of the sound track in the scene.
  40978. */
  40979. id: number;
  40980. /**
  40981. * The list of sounds included in the sound track.
  40982. */
  40983. soundCollection: Array<Sound>;
  40984. private _outputAudioNode;
  40985. private _scene;
  40986. private _connectedAnalyser;
  40987. private _options;
  40988. private _isInitialized;
  40989. /**
  40990. * Creates a new sound track.
  40991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40992. * @param scene Define the scene the sound track belongs to
  40993. * @param options
  40994. */
  40995. constructor(scene: Scene, options?: ISoundTrackOptions);
  40996. private _initializeSoundTrackAudioGraph;
  40997. /**
  40998. * Release the sound track and its associated resources
  40999. */
  41000. dispose(): void;
  41001. /**
  41002. * Adds a sound to this sound track
  41003. * @param sound define the cound to add
  41004. * @ignoreNaming
  41005. */
  41006. AddSound(sound: Sound): void;
  41007. /**
  41008. * Removes a sound to this sound track
  41009. * @param sound define the cound to remove
  41010. * @ignoreNaming
  41011. */
  41012. RemoveSound(sound: Sound): void;
  41013. /**
  41014. * Set a global volume for the full sound track.
  41015. * @param newVolume Define the new volume of the sound track
  41016. */
  41017. setVolume(newVolume: number): void;
  41018. /**
  41019. * Switch the panning model to HRTF:
  41020. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41022. */
  41023. switchPanningModelToHRTF(): void;
  41024. /**
  41025. * Switch the panning model to Equal Power:
  41026. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41028. */
  41029. switchPanningModelToEqualPower(): void;
  41030. /**
  41031. * Connect the sound track to an audio analyser allowing some amazing
  41032. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41034. * @param analyser The analyser to connect to the engine
  41035. */
  41036. connectToAnalyser(analyser: Analyser): void;
  41037. }
  41038. }
  41039. declare module BABYLON {
  41040. interface AbstractScene {
  41041. /**
  41042. * The list of sounds used in the scene.
  41043. */
  41044. sounds: Nullable<Array<Sound>>;
  41045. }
  41046. interface Scene {
  41047. /**
  41048. * @hidden
  41049. * Backing field
  41050. */
  41051. _mainSoundTrack: SoundTrack;
  41052. /**
  41053. * The main sound track played by the scene.
  41054. * It cotains your primary collection of sounds.
  41055. */
  41056. mainSoundTrack: SoundTrack;
  41057. /**
  41058. * The list of sound tracks added to the scene
  41059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41060. */
  41061. soundTracks: Nullable<Array<SoundTrack>>;
  41062. /**
  41063. * Gets a sound using a given name
  41064. * @param name defines the name to search for
  41065. * @return the found sound or null if not found at all.
  41066. */
  41067. getSoundByName(name: string): Nullable<Sound>;
  41068. /**
  41069. * Gets or sets if audio support is enabled
  41070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41071. */
  41072. audioEnabled: boolean;
  41073. /**
  41074. * Gets or sets if audio will be output to headphones
  41075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41076. */
  41077. headphone: boolean;
  41078. /**
  41079. * Gets or sets custom audio listener position provider
  41080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41081. */
  41082. audioListenerPositionProvider: Nullable<() => Vector3>;
  41083. /**
  41084. * Gets or sets a refresh rate when using 3D audio positioning
  41085. */
  41086. audioPositioningRefreshRate: number;
  41087. }
  41088. /**
  41089. * Defines the sound scene component responsible to manage any sounds
  41090. * in a given scene.
  41091. */
  41092. export class AudioSceneComponent implements ISceneSerializableComponent {
  41093. /**
  41094. * The component name helpfull to identify the component in the list of scene components.
  41095. */
  41096. readonly name: string;
  41097. /**
  41098. * The scene the component belongs to.
  41099. */
  41100. scene: Scene;
  41101. private _audioEnabled;
  41102. /**
  41103. * Gets whether audio is enabled or not.
  41104. * Please use related enable/disable method to switch state.
  41105. */
  41106. get audioEnabled(): boolean;
  41107. private _headphone;
  41108. /**
  41109. * Gets whether audio is outputing to headphone or not.
  41110. * Please use the according Switch methods to change output.
  41111. */
  41112. get headphone(): boolean;
  41113. /**
  41114. * Gets or sets a refresh rate when using 3D audio positioning
  41115. */
  41116. audioPositioningRefreshRate: number;
  41117. private _audioListenerPositionProvider;
  41118. /**
  41119. * Gets the current audio listener position provider
  41120. */
  41121. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41122. /**
  41123. * Sets a custom listener position for all sounds in the scene
  41124. * By default, this is the position of the first active camera
  41125. */
  41126. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41127. /**
  41128. * Creates a new instance of the component for the given scene
  41129. * @param scene Defines the scene to register the component in
  41130. */
  41131. constructor(scene: Scene);
  41132. /**
  41133. * Registers the component in a given scene
  41134. */
  41135. register(): void;
  41136. /**
  41137. * Rebuilds the elements related to this component in case of
  41138. * context lost for instance.
  41139. */
  41140. rebuild(): void;
  41141. /**
  41142. * Serializes the component data to the specified json object
  41143. * @param serializationObject The object to serialize to
  41144. */
  41145. serialize(serializationObject: any): void;
  41146. /**
  41147. * Adds all the elements from the container to the scene
  41148. * @param container the container holding the elements
  41149. */
  41150. addFromContainer(container: AbstractScene): void;
  41151. /**
  41152. * Removes all the elements in the container from the scene
  41153. * @param container contains the elements to remove
  41154. * @param dispose if the removed element should be disposed (default: false)
  41155. */
  41156. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41157. /**
  41158. * Disposes the component and the associated ressources.
  41159. */
  41160. dispose(): void;
  41161. /**
  41162. * Disables audio in the associated scene.
  41163. */
  41164. disableAudio(): void;
  41165. /**
  41166. * Enables audio in the associated scene.
  41167. */
  41168. enableAudio(): void;
  41169. /**
  41170. * Switch audio to headphone output.
  41171. */
  41172. switchAudioModeForHeadphones(): void;
  41173. /**
  41174. * Switch audio to normal speakers.
  41175. */
  41176. switchAudioModeForNormalSpeakers(): void;
  41177. private _cachedCameraDirection;
  41178. private _cachedCameraPosition;
  41179. private _lastCheck;
  41180. private _afterRender;
  41181. }
  41182. }
  41183. declare module BABYLON {
  41184. /**
  41185. * Wraps one or more Sound objects and selects one with random weight for playback.
  41186. */
  41187. export class WeightedSound {
  41188. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41189. loop: boolean;
  41190. private _coneInnerAngle;
  41191. private _coneOuterAngle;
  41192. private _volume;
  41193. /** A Sound is currently playing. */
  41194. isPlaying: boolean;
  41195. /** A Sound is currently paused. */
  41196. isPaused: boolean;
  41197. private _sounds;
  41198. private _weights;
  41199. private _currentIndex?;
  41200. /**
  41201. * Creates a new WeightedSound from the list of sounds given.
  41202. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41203. * @param sounds Array of Sounds that will be selected from.
  41204. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41205. */
  41206. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41207. /**
  41208. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41209. */
  41210. get directionalConeInnerAngle(): number;
  41211. /**
  41212. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41213. */
  41214. set directionalConeInnerAngle(value: number);
  41215. /**
  41216. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41217. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41218. */
  41219. get directionalConeOuterAngle(): number;
  41220. /**
  41221. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41222. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41223. */
  41224. set directionalConeOuterAngle(value: number);
  41225. /**
  41226. * Playback volume.
  41227. */
  41228. get volume(): number;
  41229. /**
  41230. * Playback volume.
  41231. */
  41232. set volume(value: number);
  41233. private _onended;
  41234. /**
  41235. * Suspend playback
  41236. */
  41237. pause(): void;
  41238. /**
  41239. * Stop playback
  41240. */
  41241. stop(): void;
  41242. /**
  41243. * Start playback.
  41244. * @param startOffset Position the clip head at a specific time in seconds.
  41245. */
  41246. play(startOffset?: number): void;
  41247. }
  41248. }
  41249. declare module BABYLON {
  41250. /**
  41251. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41253. */
  41254. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41255. /**
  41256. * Gets the name of the behavior.
  41257. */
  41258. get name(): string;
  41259. /**
  41260. * The easing function used by animations
  41261. */
  41262. static EasingFunction: BackEase;
  41263. /**
  41264. * The easing mode used by animations
  41265. */
  41266. static EasingMode: number;
  41267. /**
  41268. * The duration of the animation, in milliseconds
  41269. */
  41270. transitionDuration: number;
  41271. /**
  41272. * Length of the distance animated by the transition when lower radius is reached
  41273. */
  41274. lowerRadiusTransitionRange: number;
  41275. /**
  41276. * Length of the distance animated by the transition when upper radius is reached
  41277. */
  41278. upperRadiusTransitionRange: number;
  41279. private _autoTransitionRange;
  41280. /**
  41281. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41282. */
  41283. get autoTransitionRange(): boolean;
  41284. /**
  41285. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41286. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41287. */
  41288. set autoTransitionRange(value: boolean);
  41289. private _attachedCamera;
  41290. private _onAfterCheckInputsObserver;
  41291. private _onMeshTargetChangedObserver;
  41292. /**
  41293. * Initializes the behavior.
  41294. */
  41295. init(): void;
  41296. /**
  41297. * Attaches the behavior to its arc rotate camera.
  41298. * @param camera Defines the camera to attach the behavior to
  41299. */
  41300. attach(camera: ArcRotateCamera): void;
  41301. /**
  41302. * Detaches the behavior from its current arc rotate camera.
  41303. */
  41304. detach(): void;
  41305. private _radiusIsAnimating;
  41306. private _radiusBounceTransition;
  41307. private _animatables;
  41308. private _cachedWheelPrecision;
  41309. /**
  41310. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41311. * @param radiusLimit The limit to check against.
  41312. * @return Bool to indicate if at limit.
  41313. */
  41314. private _isRadiusAtLimit;
  41315. /**
  41316. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41317. * @param radiusDelta The delta by which to animate to. Can be negative.
  41318. */
  41319. private _applyBoundRadiusAnimation;
  41320. /**
  41321. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41322. */
  41323. protected _clearAnimationLocks(): void;
  41324. /**
  41325. * Stops and removes all animations that have been applied to the camera
  41326. */
  41327. stopAllAnimations(): void;
  41328. }
  41329. }
  41330. declare module BABYLON {
  41331. /**
  41332. * 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.
  41333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41334. */
  41335. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41336. /**
  41337. * Gets the name of the behavior.
  41338. */
  41339. get name(): string;
  41340. private _mode;
  41341. private _radiusScale;
  41342. private _positionScale;
  41343. private _defaultElevation;
  41344. private _elevationReturnTime;
  41345. private _elevationReturnWaitTime;
  41346. private _zoomStopsAnimation;
  41347. private _framingTime;
  41348. /**
  41349. * The easing function used by animations
  41350. */
  41351. static EasingFunction: ExponentialEase;
  41352. /**
  41353. * The easing mode used by animations
  41354. */
  41355. static EasingMode: number;
  41356. /**
  41357. * Sets the current mode used by the behavior
  41358. */
  41359. set mode(mode: number);
  41360. /**
  41361. * Gets current mode used by the behavior.
  41362. */
  41363. get mode(): number;
  41364. /**
  41365. * Sets the scale applied to the radius (1 by default)
  41366. */
  41367. set radiusScale(radius: number);
  41368. /**
  41369. * Gets the scale applied to the radius
  41370. */
  41371. get radiusScale(): number;
  41372. /**
  41373. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41374. */
  41375. set positionScale(scale: number);
  41376. /**
  41377. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41378. */
  41379. get positionScale(): number;
  41380. /**
  41381. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41382. * behaviour is triggered, in radians.
  41383. */
  41384. set defaultElevation(elevation: number);
  41385. /**
  41386. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41387. * behaviour is triggered, in radians.
  41388. */
  41389. get defaultElevation(): number;
  41390. /**
  41391. * Sets the time (in milliseconds) taken to return to the default beta position.
  41392. * Negative value indicates camera should not return to default.
  41393. */
  41394. set elevationReturnTime(speed: number);
  41395. /**
  41396. * Gets the time (in milliseconds) taken to return to the default beta position.
  41397. * Negative value indicates camera should not return to default.
  41398. */
  41399. get elevationReturnTime(): number;
  41400. /**
  41401. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41402. */
  41403. set elevationReturnWaitTime(time: number);
  41404. /**
  41405. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41406. */
  41407. get elevationReturnWaitTime(): number;
  41408. /**
  41409. * Sets the flag that indicates if user zooming should stop animation.
  41410. */
  41411. set zoomStopsAnimation(flag: boolean);
  41412. /**
  41413. * Gets the flag that indicates if user zooming should stop animation.
  41414. */
  41415. get zoomStopsAnimation(): boolean;
  41416. /**
  41417. * Sets the transition time when framing the mesh, in milliseconds
  41418. */
  41419. set framingTime(time: number);
  41420. /**
  41421. * Gets the transition time when framing the mesh, in milliseconds
  41422. */
  41423. get framingTime(): number;
  41424. /**
  41425. * Define if the behavior should automatically change the configured
  41426. * camera limits and sensibilities.
  41427. */
  41428. autoCorrectCameraLimitsAndSensibility: boolean;
  41429. private _onPrePointerObservableObserver;
  41430. private _onAfterCheckInputsObserver;
  41431. private _onMeshTargetChangedObserver;
  41432. private _attachedCamera;
  41433. private _isPointerDown;
  41434. private _lastInteractionTime;
  41435. /**
  41436. * Initializes the behavior.
  41437. */
  41438. init(): void;
  41439. /**
  41440. * Attaches the behavior to its arc rotate camera.
  41441. * @param camera Defines the camera to attach the behavior to
  41442. */
  41443. attach(camera: ArcRotateCamera): void;
  41444. /**
  41445. * Detaches the behavior from its current arc rotate camera.
  41446. */
  41447. detach(): void;
  41448. private _animatables;
  41449. private _betaIsAnimating;
  41450. private _betaTransition;
  41451. private _radiusTransition;
  41452. private _vectorTransition;
  41453. /**
  41454. * Targets the given mesh and updates zoom level accordingly.
  41455. * @param mesh The mesh to target.
  41456. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41457. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41458. */
  41459. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41460. /**
  41461. * Targets the given mesh with its children and updates zoom level accordingly.
  41462. * @param mesh The mesh to target.
  41463. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41464. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41465. */
  41466. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41467. /**
  41468. * Targets the given meshes with their children and updates zoom level accordingly.
  41469. * @param meshes The mesh to target.
  41470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41472. */
  41473. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41474. /**
  41475. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41476. * @param minimumWorld Determines the smaller position of the bounding box extend
  41477. * @param maximumWorld Determines the bigger position of the bounding box extend
  41478. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41479. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41480. */
  41481. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41482. /**
  41483. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41484. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41485. * frustum width.
  41486. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41487. * to fully enclose the mesh in the viewing frustum.
  41488. */
  41489. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41490. /**
  41491. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41492. * is automatically returned to its default position (expected to be above ground plane).
  41493. */
  41494. private _maintainCameraAboveGround;
  41495. /**
  41496. * Returns the frustum slope based on the canvas ratio and camera FOV
  41497. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41498. */
  41499. private _getFrustumSlope;
  41500. /**
  41501. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41502. */
  41503. private _clearAnimationLocks;
  41504. /**
  41505. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41506. */
  41507. private _applyUserInteraction;
  41508. /**
  41509. * Stops and removes all animations that have been applied to the camera
  41510. */
  41511. stopAllAnimations(): void;
  41512. /**
  41513. * Gets a value indicating if the user is moving the camera
  41514. */
  41515. get isUserIsMoving(): boolean;
  41516. /**
  41517. * The camera can move all the way towards the mesh.
  41518. */
  41519. static IgnoreBoundsSizeMode: number;
  41520. /**
  41521. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41522. */
  41523. static FitFrustumSidesMode: number;
  41524. }
  41525. }
  41526. declare module BABYLON {
  41527. /**
  41528. * Base class for Camera Pointer Inputs.
  41529. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41530. * for example usage.
  41531. */
  41532. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41533. /**
  41534. * Defines the camera the input is attached to.
  41535. */
  41536. abstract camera: Camera;
  41537. /**
  41538. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41539. */
  41540. protected _altKey: boolean;
  41541. protected _ctrlKey: boolean;
  41542. protected _metaKey: boolean;
  41543. protected _shiftKey: boolean;
  41544. /**
  41545. * Which mouse buttons were pressed at time of last mouse event.
  41546. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41547. */
  41548. protected _buttonsPressed: number;
  41549. /**
  41550. * Defines the buttons associated with the input to handle camera move.
  41551. */
  41552. buttons: number[];
  41553. /**
  41554. * Attach the input controls to a specific dom element to get the input from.
  41555. * @param element Defines the element the controls should be listened from
  41556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41557. */
  41558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41559. /**
  41560. * Detach the current controls from the specified dom element.
  41561. * @param element Defines the element to stop listening the inputs from
  41562. */
  41563. detachControl(element: Nullable<HTMLElement>): void;
  41564. /**
  41565. * Gets the class name of the current input.
  41566. * @returns the class name
  41567. */
  41568. getClassName(): string;
  41569. /**
  41570. * Get the friendly name associated with the input class.
  41571. * @returns the input friendly name
  41572. */
  41573. getSimpleName(): string;
  41574. /**
  41575. * Called on pointer POINTERDOUBLETAP event.
  41576. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41577. */
  41578. protected onDoubleTap(type: string): void;
  41579. /**
  41580. * Called on pointer POINTERMOVE event if only a single touch is active.
  41581. * Override this method to provide functionality.
  41582. */
  41583. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41584. /**
  41585. * Called on pointer POINTERMOVE event if multiple touches are active.
  41586. * Override this method to provide functionality.
  41587. */
  41588. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41589. /**
  41590. * Called on JS contextmenu event.
  41591. * Override this method to provide functionality.
  41592. */
  41593. protected onContextMenu(evt: PointerEvent): void;
  41594. /**
  41595. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41596. * press.
  41597. * Override this method to provide functionality.
  41598. */
  41599. protected onButtonDown(evt: PointerEvent): void;
  41600. /**
  41601. * Called each time a new POINTERUP event occurs. Ie, for each button
  41602. * release.
  41603. * Override this method to provide functionality.
  41604. */
  41605. protected onButtonUp(evt: PointerEvent): void;
  41606. /**
  41607. * Called when window becomes inactive.
  41608. * Override this method to provide functionality.
  41609. */
  41610. protected onLostFocus(): void;
  41611. private _pointerInput;
  41612. private _observer;
  41613. private _onLostFocus;
  41614. private pointA;
  41615. private pointB;
  41616. }
  41617. }
  41618. declare module BABYLON {
  41619. /**
  41620. * Manage the pointers inputs to control an arc rotate camera.
  41621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41622. */
  41623. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41624. /**
  41625. * Defines the camera the input is attached to.
  41626. */
  41627. camera: ArcRotateCamera;
  41628. /**
  41629. * Gets the class name of the current input.
  41630. * @returns the class name
  41631. */
  41632. getClassName(): string;
  41633. /**
  41634. * Defines the buttons associated with the input to handle camera move.
  41635. */
  41636. buttons: number[];
  41637. /**
  41638. * Defines the pointer angular sensibility along the X axis or how fast is
  41639. * the camera rotating.
  41640. */
  41641. angularSensibilityX: number;
  41642. /**
  41643. * Defines the pointer angular sensibility along the Y axis or how fast is
  41644. * the camera rotating.
  41645. */
  41646. angularSensibilityY: number;
  41647. /**
  41648. * Defines the pointer pinch precision or how fast is the camera zooming.
  41649. */
  41650. pinchPrecision: number;
  41651. /**
  41652. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41653. * from 0.
  41654. * It defines the percentage of current camera.radius to use as delta when
  41655. * pinch zoom is used.
  41656. */
  41657. pinchDeltaPercentage: number;
  41658. /**
  41659. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41660. * that any object in the plane at the camera's target point will scale
  41661. * perfectly with finger motion.
  41662. * Overrides pinchDeltaPercentage and pinchPrecision.
  41663. */
  41664. useNaturalPinchZoom: boolean;
  41665. /**
  41666. * Defines the pointer panning sensibility or how fast is the camera moving.
  41667. */
  41668. panningSensibility: number;
  41669. /**
  41670. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41671. */
  41672. multiTouchPanning: boolean;
  41673. /**
  41674. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41675. * zoom (pinch) through multitouch.
  41676. */
  41677. multiTouchPanAndZoom: boolean;
  41678. /**
  41679. * Revers pinch action direction.
  41680. */
  41681. pinchInwards: boolean;
  41682. private _isPanClick;
  41683. private _twoFingerActivityCount;
  41684. private _isPinching;
  41685. /**
  41686. * Called on pointer POINTERMOVE event if only a single touch is active.
  41687. */
  41688. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41689. /**
  41690. * Called on pointer POINTERDOUBLETAP event.
  41691. */
  41692. protected onDoubleTap(type: string): void;
  41693. /**
  41694. * Called on pointer POINTERMOVE event if multiple touches are active.
  41695. */
  41696. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41697. /**
  41698. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41699. * press.
  41700. */
  41701. protected onButtonDown(evt: PointerEvent): void;
  41702. /**
  41703. * Called each time a new POINTERUP event occurs. Ie, for each button
  41704. * release.
  41705. */
  41706. protected onButtonUp(evt: PointerEvent): void;
  41707. /**
  41708. * Called when window becomes inactive.
  41709. */
  41710. protected onLostFocus(): void;
  41711. }
  41712. }
  41713. declare module BABYLON {
  41714. /**
  41715. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41717. */
  41718. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41719. /**
  41720. * Defines the camera the input is attached to.
  41721. */
  41722. camera: ArcRotateCamera;
  41723. /**
  41724. * Defines the list of key codes associated with the up action (increase alpha)
  41725. */
  41726. keysUp: number[];
  41727. /**
  41728. * Defines the list of key codes associated with the down action (decrease alpha)
  41729. */
  41730. keysDown: number[];
  41731. /**
  41732. * Defines the list of key codes associated with the left action (increase beta)
  41733. */
  41734. keysLeft: number[];
  41735. /**
  41736. * Defines the list of key codes associated with the right action (decrease beta)
  41737. */
  41738. keysRight: number[];
  41739. /**
  41740. * Defines the list of key codes associated with the reset action.
  41741. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41742. */
  41743. keysReset: number[];
  41744. /**
  41745. * Defines the panning sensibility of the inputs.
  41746. * (How fast is the camera panning)
  41747. */
  41748. panningSensibility: number;
  41749. /**
  41750. * Defines the zooming sensibility of the inputs.
  41751. * (How fast is the camera zooming)
  41752. */
  41753. zoomingSensibility: number;
  41754. /**
  41755. * Defines whether maintaining the alt key down switch the movement mode from
  41756. * orientation to zoom.
  41757. */
  41758. useAltToZoom: boolean;
  41759. /**
  41760. * Rotation speed of the camera
  41761. */
  41762. angularSpeed: number;
  41763. private _keys;
  41764. private _ctrlPressed;
  41765. private _altPressed;
  41766. private _onCanvasBlurObserver;
  41767. private _onKeyboardObserver;
  41768. private _engine;
  41769. private _scene;
  41770. /**
  41771. * Attach the input controls to a specific dom element to get the input from.
  41772. * @param element Defines the element the controls should be listened from
  41773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41774. */
  41775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41776. /**
  41777. * Detach the current controls from the specified dom element.
  41778. * @param element Defines the element to stop listening the inputs from
  41779. */
  41780. detachControl(element: Nullable<HTMLElement>): void;
  41781. /**
  41782. * Update the current camera state depending on the inputs that have been used this frame.
  41783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41784. */
  41785. checkInputs(): void;
  41786. /**
  41787. * Gets the class name of the current intput.
  41788. * @returns the class name
  41789. */
  41790. getClassName(): string;
  41791. /**
  41792. * Get the friendly name associated with the input class.
  41793. * @returns the input friendly name
  41794. */
  41795. getSimpleName(): string;
  41796. }
  41797. }
  41798. declare module BABYLON {
  41799. /**
  41800. * Manage the mouse wheel inputs to control an arc rotate camera.
  41801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41802. */
  41803. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41804. /**
  41805. * Defines the camera the input is attached to.
  41806. */
  41807. camera: ArcRotateCamera;
  41808. /**
  41809. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41810. */
  41811. wheelPrecision: number;
  41812. /**
  41813. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41814. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41815. */
  41816. wheelDeltaPercentage: number;
  41817. private _wheel;
  41818. private _observer;
  41819. private computeDeltaFromMouseWheelLegacyEvent;
  41820. /**
  41821. * Attach the input controls to a specific dom element to get the input from.
  41822. * @param element Defines the element the controls should be listened from
  41823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41824. */
  41825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41826. /**
  41827. * Detach the current controls from the specified dom element.
  41828. * @param element Defines the element to stop listening the inputs from
  41829. */
  41830. detachControl(element: Nullable<HTMLElement>): void;
  41831. /**
  41832. * Gets the class name of the current intput.
  41833. * @returns the class name
  41834. */
  41835. getClassName(): string;
  41836. /**
  41837. * Get the friendly name associated with the input class.
  41838. * @returns the input friendly name
  41839. */
  41840. getSimpleName(): string;
  41841. }
  41842. }
  41843. declare module BABYLON {
  41844. /**
  41845. * Default Inputs manager for the ArcRotateCamera.
  41846. * It groups all the default supported inputs for ease of use.
  41847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41848. */
  41849. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41850. /**
  41851. * Instantiates a new ArcRotateCameraInputsManager.
  41852. * @param camera Defines the camera the inputs belong to
  41853. */
  41854. constructor(camera: ArcRotateCamera);
  41855. /**
  41856. * Add mouse wheel input support to the input manager.
  41857. * @returns the current input manager
  41858. */
  41859. addMouseWheel(): ArcRotateCameraInputsManager;
  41860. /**
  41861. * Add pointers input support to the input manager.
  41862. * @returns the current input manager
  41863. */
  41864. addPointers(): ArcRotateCameraInputsManager;
  41865. /**
  41866. * Add keyboard input support to the input manager.
  41867. * @returns the current input manager
  41868. */
  41869. addKeyboard(): ArcRotateCameraInputsManager;
  41870. }
  41871. }
  41872. declare module BABYLON {
  41873. /**
  41874. * This represents an orbital type of camera.
  41875. *
  41876. * 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.
  41877. * 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.
  41878. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41879. */
  41880. export class ArcRotateCamera extends TargetCamera {
  41881. /**
  41882. * Defines the rotation angle of the camera along the longitudinal axis.
  41883. */
  41884. alpha: number;
  41885. /**
  41886. * Defines the rotation angle of the camera along the latitudinal axis.
  41887. */
  41888. beta: number;
  41889. /**
  41890. * Defines the radius of the camera from it s target point.
  41891. */
  41892. radius: number;
  41893. protected _target: Vector3;
  41894. protected _targetHost: Nullable<AbstractMesh>;
  41895. /**
  41896. * Defines the target point of the camera.
  41897. * The camera looks towards it form the radius distance.
  41898. */
  41899. get target(): Vector3;
  41900. set target(value: Vector3);
  41901. /**
  41902. * Define the current local position of the camera in the scene
  41903. */
  41904. get position(): Vector3;
  41905. set position(newPosition: Vector3);
  41906. protected _upVector: Vector3;
  41907. protected _upToYMatrix: Matrix;
  41908. protected _YToUpMatrix: Matrix;
  41909. /**
  41910. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41911. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41912. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41913. */
  41914. set upVector(vec: Vector3);
  41915. get upVector(): Vector3;
  41916. /**
  41917. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41918. */
  41919. setMatUp(): void;
  41920. /**
  41921. * Current inertia value on the longitudinal axis.
  41922. * The bigger this number the longer it will take for the camera to stop.
  41923. */
  41924. inertialAlphaOffset: number;
  41925. /**
  41926. * Current inertia value on the latitudinal axis.
  41927. * The bigger this number the longer it will take for the camera to stop.
  41928. */
  41929. inertialBetaOffset: number;
  41930. /**
  41931. * Current inertia value on the radius axis.
  41932. * The bigger this number the longer it will take for the camera to stop.
  41933. */
  41934. inertialRadiusOffset: number;
  41935. /**
  41936. * Minimum allowed angle on the longitudinal axis.
  41937. * This can help limiting how the Camera is able to move in the scene.
  41938. */
  41939. lowerAlphaLimit: Nullable<number>;
  41940. /**
  41941. * Maximum allowed angle on the longitudinal axis.
  41942. * This can help limiting how the Camera is able to move in the scene.
  41943. */
  41944. upperAlphaLimit: Nullable<number>;
  41945. /**
  41946. * Minimum allowed angle on the latitudinal axis.
  41947. * This can help limiting how the Camera is able to move in the scene.
  41948. */
  41949. lowerBetaLimit: number;
  41950. /**
  41951. * Maximum allowed angle on the latitudinal axis.
  41952. * This can help limiting how the Camera is able to move in the scene.
  41953. */
  41954. upperBetaLimit: number;
  41955. /**
  41956. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41957. * This can help limiting how the Camera is able to move in the scene.
  41958. */
  41959. lowerRadiusLimit: Nullable<number>;
  41960. /**
  41961. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41962. * This can help limiting how the Camera is able to move in the scene.
  41963. */
  41964. upperRadiusLimit: Nullable<number>;
  41965. /**
  41966. * Defines the current inertia value used during panning of the camera along the X axis.
  41967. */
  41968. inertialPanningX: number;
  41969. /**
  41970. * Defines the current inertia value used during panning of the camera along the Y axis.
  41971. */
  41972. inertialPanningY: number;
  41973. /**
  41974. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41975. * Basically if your fingers moves away from more than this distance you will be considered
  41976. * in pinch mode.
  41977. */
  41978. pinchToPanMaxDistance: number;
  41979. /**
  41980. * Defines the maximum distance the camera can pan.
  41981. * This could help keeping the cammera always in your scene.
  41982. */
  41983. panningDistanceLimit: Nullable<number>;
  41984. /**
  41985. * Defines the target of the camera before paning.
  41986. */
  41987. panningOriginTarget: Vector3;
  41988. /**
  41989. * Defines the value of the inertia used during panning.
  41990. * 0 would mean stop inertia and one would mean no decelleration at all.
  41991. */
  41992. panningInertia: number;
  41993. /**
  41994. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41995. */
  41996. get angularSensibilityX(): number;
  41997. set angularSensibilityX(value: number);
  41998. /**
  41999. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42000. */
  42001. get angularSensibilityY(): number;
  42002. set angularSensibilityY(value: number);
  42003. /**
  42004. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42005. */
  42006. get pinchPrecision(): number;
  42007. set pinchPrecision(value: number);
  42008. /**
  42009. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42010. * It will be used instead of pinchDeltaPrecision if different from 0.
  42011. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42012. */
  42013. get pinchDeltaPercentage(): number;
  42014. set pinchDeltaPercentage(value: number);
  42015. /**
  42016. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42017. * and pinch delta percentage.
  42018. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42019. * that any object in the plane at the camera's target point will scale
  42020. * perfectly with finger motion.
  42021. */
  42022. get useNaturalPinchZoom(): boolean;
  42023. set useNaturalPinchZoom(value: boolean);
  42024. /**
  42025. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42026. */
  42027. get panningSensibility(): number;
  42028. set panningSensibility(value: number);
  42029. /**
  42030. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42031. */
  42032. get keysUp(): number[];
  42033. set keysUp(value: number[]);
  42034. /**
  42035. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42036. */
  42037. get keysDown(): number[];
  42038. set keysDown(value: number[]);
  42039. /**
  42040. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42041. */
  42042. get keysLeft(): number[];
  42043. set keysLeft(value: number[]);
  42044. /**
  42045. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42046. */
  42047. get keysRight(): number[];
  42048. set keysRight(value: number[]);
  42049. /**
  42050. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42051. */
  42052. get wheelPrecision(): number;
  42053. set wheelPrecision(value: number);
  42054. /**
  42055. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42056. * It will be used instead of pinchDeltaPrecision if different from 0.
  42057. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42058. */
  42059. get wheelDeltaPercentage(): number;
  42060. set wheelDeltaPercentage(value: number);
  42061. /**
  42062. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42063. */
  42064. zoomOnFactor: number;
  42065. /**
  42066. * Defines a screen offset for the camera position.
  42067. */
  42068. targetScreenOffset: Vector2;
  42069. /**
  42070. * Allows the camera to be completely reversed.
  42071. * If false the camera can not arrive upside down.
  42072. */
  42073. allowUpsideDown: boolean;
  42074. /**
  42075. * Define if double tap/click is used to restore the previously saved state of the camera.
  42076. */
  42077. useInputToRestoreState: boolean;
  42078. /** @hidden */
  42079. _viewMatrix: Matrix;
  42080. /** @hidden */
  42081. _useCtrlForPanning: boolean;
  42082. /** @hidden */
  42083. _panningMouseButton: number;
  42084. /**
  42085. * Defines the input associated to the camera.
  42086. */
  42087. inputs: ArcRotateCameraInputsManager;
  42088. /** @hidden */
  42089. _reset: () => void;
  42090. /**
  42091. * Defines the allowed panning axis.
  42092. */
  42093. panningAxis: Vector3;
  42094. protected _localDirection: Vector3;
  42095. protected _transformedDirection: Vector3;
  42096. private _bouncingBehavior;
  42097. /**
  42098. * Gets the bouncing behavior of the camera if it has been enabled.
  42099. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42100. */
  42101. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42102. /**
  42103. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42105. */
  42106. get useBouncingBehavior(): boolean;
  42107. set useBouncingBehavior(value: boolean);
  42108. private _framingBehavior;
  42109. /**
  42110. * Gets the framing behavior of the camera if it has been enabled.
  42111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42112. */
  42113. get framingBehavior(): Nullable<FramingBehavior>;
  42114. /**
  42115. * Defines if the framing behavior of the camera is enabled on the camera.
  42116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42117. */
  42118. get useFramingBehavior(): boolean;
  42119. set useFramingBehavior(value: boolean);
  42120. private _autoRotationBehavior;
  42121. /**
  42122. * Gets the auto rotation behavior of the camera if it has been enabled.
  42123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42124. */
  42125. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42126. /**
  42127. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42128. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42129. */
  42130. get useAutoRotationBehavior(): boolean;
  42131. set useAutoRotationBehavior(value: boolean);
  42132. /**
  42133. * Observable triggered when the mesh target has been changed on the camera.
  42134. */
  42135. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42136. /**
  42137. * Event raised when the camera is colliding with a mesh.
  42138. */
  42139. onCollide: (collidedMesh: AbstractMesh) => void;
  42140. /**
  42141. * Defines whether the camera should check collision with the objects oh the scene.
  42142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42143. */
  42144. checkCollisions: boolean;
  42145. /**
  42146. * Defines the collision radius of the camera.
  42147. * This simulates a sphere around the camera.
  42148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42149. */
  42150. collisionRadius: Vector3;
  42151. protected _collider: Collider;
  42152. protected _previousPosition: Vector3;
  42153. protected _collisionVelocity: Vector3;
  42154. protected _newPosition: Vector3;
  42155. protected _previousAlpha: number;
  42156. protected _previousBeta: number;
  42157. protected _previousRadius: number;
  42158. protected _collisionTriggered: boolean;
  42159. protected _targetBoundingCenter: Nullable<Vector3>;
  42160. private _computationVector;
  42161. /**
  42162. * Instantiates a new ArcRotateCamera in a given scene
  42163. * @param name Defines the name of the camera
  42164. * @param alpha Defines the camera rotation along the logitudinal axis
  42165. * @param beta Defines the camera rotation along the latitudinal axis
  42166. * @param radius Defines the camera distance from its target
  42167. * @param target Defines the camera target
  42168. * @param scene Defines the scene the camera belongs to
  42169. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42170. */
  42171. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42172. /** @hidden */
  42173. _initCache(): void;
  42174. /** @hidden */
  42175. _updateCache(ignoreParentClass?: boolean): void;
  42176. protected _getTargetPosition(): Vector3;
  42177. private _storedAlpha;
  42178. private _storedBeta;
  42179. private _storedRadius;
  42180. private _storedTarget;
  42181. private _storedTargetScreenOffset;
  42182. /**
  42183. * Stores the current state of the camera (alpha, beta, radius and target)
  42184. * @returns the camera itself
  42185. */
  42186. storeState(): Camera;
  42187. /**
  42188. * @hidden
  42189. * Restored camera state. You must call storeState() first
  42190. */
  42191. _restoreStateValues(): boolean;
  42192. /** @hidden */
  42193. _isSynchronizedViewMatrix(): boolean;
  42194. /**
  42195. * Attached controls to the current camera.
  42196. * @param element Defines the element the controls should be listened from
  42197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42198. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42199. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42200. */
  42201. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42202. /**
  42203. * Detach the current controls from the camera.
  42204. * The camera will stop reacting to inputs.
  42205. * @param element Defines the element to stop listening the inputs from
  42206. */
  42207. detachControl(element: HTMLElement): void;
  42208. /** @hidden */
  42209. _checkInputs(): void;
  42210. protected _checkLimits(): void;
  42211. /**
  42212. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42213. */
  42214. rebuildAnglesAndRadius(): void;
  42215. /**
  42216. * Use a position to define the current camera related information like alpha, beta and radius
  42217. * @param position Defines the position to set the camera at
  42218. */
  42219. setPosition(position: Vector3): void;
  42220. /**
  42221. * Defines the target the camera should look at.
  42222. * This will automatically adapt alpha beta and radius to fit within the new target.
  42223. * @param target Defines the new target as a Vector or a mesh
  42224. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42225. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42226. */
  42227. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42228. /** @hidden */
  42229. _getViewMatrix(): Matrix;
  42230. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42231. /**
  42232. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42233. * @param meshes Defines the mesh to zoom on
  42234. * @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)
  42235. */
  42236. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42237. /**
  42238. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42239. * The target will be changed but the radius
  42240. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42241. * @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)
  42242. */
  42243. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42244. min: Vector3;
  42245. max: Vector3;
  42246. distance: number;
  42247. }, doNotUpdateMaxZ?: boolean): void;
  42248. /**
  42249. * @override
  42250. * Override Camera.createRigCamera
  42251. */
  42252. createRigCamera(name: string, cameraIndex: number): Camera;
  42253. /**
  42254. * @hidden
  42255. * @override
  42256. * Override Camera._updateRigCameras
  42257. */
  42258. _updateRigCameras(): void;
  42259. /**
  42260. * Destroy the camera and release the current resources hold by it.
  42261. */
  42262. dispose(): void;
  42263. /**
  42264. * Gets the current object class name.
  42265. * @return the class name
  42266. */
  42267. getClassName(): string;
  42268. }
  42269. }
  42270. declare module BABYLON {
  42271. /**
  42272. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42274. */
  42275. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42276. /**
  42277. * Gets the name of the behavior.
  42278. */
  42279. get name(): string;
  42280. private _zoomStopsAnimation;
  42281. private _idleRotationSpeed;
  42282. private _idleRotationWaitTime;
  42283. private _idleRotationSpinupTime;
  42284. /**
  42285. * Sets the flag that indicates if user zooming should stop animation.
  42286. */
  42287. set zoomStopsAnimation(flag: boolean);
  42288. /**
  42289. * Gets the flag that indicates if user zooming should stop animation.
  42290. */
  42291. get zoomStopsAnimation(): boolean;
  42292. /**
  42293. * Sets the default speed at which the camera rotates around the model.
  42294. */
  42295. set idleRotationSpeed(speed: number);
  42296. /**
  42297. * Gets the default speed at which the camera rotates around the model.
  42298. */
  42299. get idleRotationSpeed(): number;
  42300. /**
  42301. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42302. */
  42303. set idleRotationWaitTime(time: number);
  42304. /**
  42305. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42306. */
  42307. get idleRotationWaitTime(): number;
  42308. /**
  42309. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42310. */
  42311. set idleRotationSpinupTime(time: number);
  42312. /**
  42313. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42314. */
  42315. get idleRotationSpinupTime(): number;
  42316. /**
  42317. * Gets a value indicating if the camera is currently rotating because of this behavior
  42318. */
  42319. get rotationInProgress(): boolean;
  42320. private _onPrePointerObservableObserver;
  42321. private _onAfterCheckInputsObserver;
  42322. private _attachedCamera;
  42323. private _isPointerDown;
  42324. private _lastFrameTime;
  42325. private _lastInteractionTime;
  42326. private _cameraRotationSpeed;
  42327. /**
  42328. * Initializes the behavior.
  42329. */
  42330. init(): void;
  42331. /**
  42332. * Attaches the behavior to its arc rotate camera.
  42333. * @param camera Defines the camera to attach the behavior to
  42334. */
  42335. attach(camera: ArcRotateCamera): void;
  42336. /**
  42337. * Detaches the behavior from its current arc rotate camera.
  42338. */
  42339. detach(): void;
  42340. /**
  42341. * Returns true if user is scrolling.
  42342. * @return true if user is scrolling.
  42343. */
  42344. private _userIsZooming;
  42345. private _lastFrameRadius;
  42346. private _shouldAnimationStopForInteraction;
  42347. /**
  42348. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42349. */
  42350. private _applyUserInteraction;
  42351. private _userIsMoving;
  42352. }
  42353. }
  42354. declare module BABYLON {
  42355. /**
  42356. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42357. */
  42358. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42359. private ui;
  42360. /**
  42361. * The name of the behavior
  42362. */
  42363. name: string;
  42364. /**
  42365. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42366. */
  42367. distanceAwayFromFace: number;
  42368. /**
  42369. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42370. */
  42371. distanceAwayFromBottomOfFace: number;
  42372. private _faceVectors;
  42373. private _target;
  42374. private _scene;
  42375. private _onRenderObserver;
  42376. private _tmpMatrix;
  42377. private _tmpVector;
  42378. /**
  42379. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42380. * @param ui The transform node that should be attched to the mesh
  42381. */
  42382. constructor(ui: TransformNode);
  42383. /**
  42384. * Initializes the behavior
  42385. */
  42386. init(): void;
  42387. private _closestFace;
  42388. private _zeroVector;
  42389. private _lookAtTmpMatrix;
  42390. private _lookAtToRef;
  42391. /**
  42392. * Attaches the AttachToBoxBehavior to the passed in mesh
  42393. * @param target The mesh that the specified node will be attached to
  42394. */
  42395. attach(target: Mesh): void;
  42396. /**
  42397. * Detaches the behavior from the mesh
  42398. */
  42399. detach(): void;
  42400. }
  42401. }
  42402. declare module BABYLON {
  42403. /**
  42404. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42405. */
  42406. export class FadeInOutBehavior implements Behavior<Mesh> {
  42407. /**
  42408. * Time in milliseconds to delay before fading in (Default: 0)
  42409. */
  42410. delay: number;
  42411. /**
  42412. * Time in milliseconds for the mesh to fade in (Default: 300)
  42413. */
  42414. fadeInTime: number;
  42415. private _millisecondsPerFrame;
  42416. private _hovered;
  42417. private _hoverValue;
  42418. private _ownerNode;
  42419. /**
  42420. * Instatiates the FadeInOutBehavior
  42421. */
  42422. constructor();
  42423. /**
  42424. * The name of the behavior
  42425. */
  42426. get name(): string;
  42427. /**
  42428. * Initializes the behavior
  42429. */
  42430. init(): void;
  42431. /**
  42432. * Attaches the fade behavior on the passed in mesh
  42433. * @param ownerNode The mesh that will be faded in/out once attached
  42434. */
  42435. attach(ownerNode: Mesh): void;
  42436. /**
  42437. * Detaches the behavior from the mesh
  42438. */
  42439. detach(): void;
  42440. /**
  42441. * Triggers the mesh to begin fading in or out
  42442. * @param value if the object should fade in or out (true to fade in)
  42443. */
  42444. fadeIn(value: boolean): void;
  42445. private _update;
  42446. private _setAllVisibility;
  42447. }
  42448. }
  42449. declare module BABYLON {
  42450. /**
  42451. * Class containing a set of static utilities functions for managing Pivots
  42452. * @hidden
  42453. */
  42454. export class PivotTools {
  42455. private static _PivotCached;
  42456. private static _OldPivotPoint;
  42457. private static _PivotTranslation;
  42458. private static _PivotTmpVector;
  42459. /** @hidden */
  42460. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42461. /** @hidden */
  42462. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42463. }
  42464. }
  42465. declare module BABYLON {
  42466. /**
  42467. * Class containing static functions to help procedurally build meshes
  42468. */
  42469. export class PlaneBuilder {
  42470. /**
  42471. * Creates a plane mesh
  42472. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42473. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42474. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42476. * * 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
  42477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42478. * @param name defines the name of the mesh
  42479. * @param options defines the options used to create the mesh
  42480. * @param scene defines the hosting scene
  42481. * @returns the plane mesh
  42482. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42483. */
  42484. static CreatePlane(name: string, options: {
  42485. size?: number;
  42486. width?: number;
  42487. height?: number;
  42488. sideOrientation?: number;
  42489. frontUVs?: Vector4;
  42490. backUVs?: Vector4;
  42491. updatable?: boolean;
  42492. sourcePlane?: Plane;
  42493. }, scene?: Nullable<Scene>): Mesh;
  42494. }
  42495. }
  42496. declare module BABYLON {
  42497. /**
  42498. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42499. */
  42500. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42501. private static _AnyMouseID;
  42502. /**
  42503. * Abstract mesh the behavior is set on
  42504. */
  42505. attachedNode: AbstractMesh;
  42506. private _dragPlane;
  42507. private _scene;
  42508. private _pointerObserver;
  42509. private _beforeRenderObserver;
  42510. private static _planeScene;
  42511. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42512. /**
  42513. * 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)
  42514. */
  42515. maxDragAngle: number;
  42516. /**
  42517. * @hidden
  42518. */
  42519. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42520. /**
  42521. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42522. */
  42523. currentDraggingPointerID: number;
  42524. /**
  42525. * The last position where the pointer hit the drag plane in world space
  42526. */
  42527. lastDragPosition: Vector3;
  42528. /**
  42529. * If the behavior is currently in a dragging state
  42530. */
  42531. dragging: boolean;
  42532. /**
  42533. * 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)
  42534. */
  42535. dragDeltaRatio: number;
  42536. /**
  42537. * If the drag plane orientation should be updated during the dragging (Default: true)
  42538. */
  42539. updateDragPlane: boolean;
  42540. private _debugMode;
  42541. private _moving;
  42542. /**
  42543. * Fires each time the attached mesh is dragged with the pointer
  42544. * * delta between last drag position and current drag position in world space
  42545. * * dragDistance along the drag axis
  42546. * * dragPlaneNormal normal of the current drag plane used during the drag
  42547. * * dragPlanePoint in world space where the drag intersects the drag plane
  42548. */
  42549. onDragObservable: Observable<{
  42550. delta: Vector3;
  42551. dragPlanePoint: Vector3;
  42552. dragPlaneNormal: Vector3;
  42553. dragDistance: number;
  42554. pointerId: number;
  42555. }>;
  42556. /**
  42557. * Fires each time a drag begins (eg. mouse down on mesh)
  42558. */
  42559. onDragStartObservable: Observable<{
  42560. dragPlanePoint: Vector3;
  42561. pointerId: number;
  42562. }>;
  42563. /**
  42564. * Fires each time a drag ends (eg. mouse release after drag)
  42565. */
  42566. onDragEndObservable: Observable<{
  42567. dragPlanePoint: Vector3;
  42568. pointerId: number;
  42569. }>;
  42570. /**
  42571. * If the attached mesh should be moved when dragged
  42572. */
  42573. moveAttached: boolean;
  42574. /**
  42575. * If the drag behavior will react to drag events (Default: true)
  42576. */
  42577. enabled: boolean;
  42578. /**
  42579. * If pointer events should start and release the drag (Default: true)
  42580. */
  42581. startAndReleaseDragOnPointerEvents: boolean;
  42582. /**
  42583. * If camera controls should be detached during the drag
  42584. */
  42585. detachCameraControls: boolean;
  42586. /**
  42587. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42588. */
  42589. useObjectOrientationForDragging: boolean;
  42590. private _options;
  42591. /**
  42592. * Gets the options used by the behavior
  42593. */
  42594. get options(): {
  42595. dragAxis?: Vector3;
  42596. dragPlaneNormal?: Vector3;
  42597. };
  42598. /**
  42599. * Sets the options used by the behavior
  42600. */
  42601. set options(options: {
  42602. dragAxis?: Vector3;
  42603. dragPlaneNormal?: Vector3;
  42604. });
  42605. /**
  42606. * Creates a pointer drag behavior that can be attached to a mesh
  42607. * @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)
  42608. */
  42609. constructor(options?: {
  42610. dragAxis?: Vector3;
  42611. dragPlaneNormal?: Vector3;
  42612. });
  42613. /**
  42614. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42615. */
  42616. validateDrag: (targetPosition: Vector3) => boolean;
  42617. /**
  42618. * The name of the behavior
  42619. */
  42620. get name(): string;
  42621. /**
  42622. * Initializes the behavior
  42623. */
  42624. init(): void;
  42625. private _tmpVector;
  42626. private _alternatePickedPoint;
  42627. private _worldDragAxis;
  42628. private _targetPosition;
  42629. private _attachedElement;
  42630. /**
  42631. * Attaches the drag behavior the passed in mesh
  42632. * @param ownerNode The mesh that will be dragged around once attached
  42633. * @param predicate Predicate to use for pick filtering
  42634. */
  42635. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42636. /**
  42637. * Force relase the drag action by code.
  42638. */
  42639. releaseDrag(): void;
  42640. private _startDragRay;
  42641. private _lastPointerRay;
  42642. /**
  42643. * Simulates the start of a pointer drag event on the behavior
  42644. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42645. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42646. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42647. */
  42648. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42649. private _startDrag;
  42650. private _dragDelta;
  42651. private _moveDrag;
  42652. private _pickWithRayOnDragPlane;
  42653. private _pointA;
  42654. private _pointB;
  42655. private _pointC;
  42656. private _lineA;
  42657. private _lineB;
  42658. private _localAxis;
  42659. private _lookAt;
  42660. private _updateDragPlanePosition;
  42661. /**
  42662. * Detaches the behavior from the mesh
  42663. */
  42664. detach(): void;
  42665. }
  42666. }
  42667. declare module BABYLON {
  42668. /**
  42669. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42670. */
  42671. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42672. private _dragBehaviorA;
  42673. private _dragBehaviorB;
  42674. private _startDistance;
  42675. private _initialScale;
  42676. private _targetScale;
  42677. private _ownerNode;
  42678. private _sceneRenderObserver;
  42679. /**
  42680. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42681. */
  42682. constructor();
  42683. /**
  42684. * The name of the behavior
  42685. */
  42686. get name(): string;
  42687. /**
  42688. * Initializes the behavior
  42689. */
  42690. init(): void;
  42691. private _getCurrentDistance;
  42692. /**
  42693. * Attaches the scale behavior the passed in mesh
  42694. * @param ownerNode The mesh that will be scaled around once attached
  42695. */
  42696. attach(ownerNode: Mesh): void;
  42697. /**
  42698. * Detaches the behavior from the mesh
  42699. */
  42700. detach(): void;
  42701. }
  42702. }
  42703. declare module BABYLON {
  42704. /**
  42705. * 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
  42706. */
  42707. export class SixDofDragBehavior implements Behavior<Mesh> {
  42708. private static _virtualScene;
  42709. private _ownerNode;
  42710. private _sceneRenderObserver;
  42711. private _scene;
  42712. private _targetPosition;
  42713. private _virtualOriginMesh;
  42714. private _virtualDragMesh;
  42715. private _pointerObserver;
  42716. private _moving;
  42717. private _startingOrientation;
  42718. private _attachedElement;
  42719. /**
  42720. * 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)
  42721. */
  42722. private zDragFactor;
  42723. /**
  42724. * If the object should rotate to face the drag origin
  42725. */
  42726. rotateDraggedObject: boolean;
  42727. /**
  42728. * If the behavior is currently in a dragging state
  42729. */
  42730. dragging: boolean;
  42731. /**
  42732. * 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)
  42733. */
  42734. dragDeltaRatio: number;
  42735. /**
  42736. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42737. */
  42738. currentDraggingPointerID: number;
  42739. /**
  42740. * If camera controls should be detached during the drag
  42741. */
  42742. detachCameraControls: boolean;
  42743. /**
  42744. * Fires each time a drag starts
  42745. */
  42746. onDragStartObservable: Observable<{}>;
  42747. /**
  42748. * Fires each time a drag ends (eg. mouse release after drag)
  42749. */
  42750. onDragEndObservable: Observable<{}>;
  42751. /**
  42752. * 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
  42753. */
  42754. constructor();
  42755. /**
  42756. * The name of the behavior
  42757. */
  42758. get name(): string;
  42759. /**
  42760. * Initializes the behavior
  42761. */
  42762. init(): void;
  42763. /**
  42764. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42765. */
  42766. private get _pointerCamera();
  42767. /**
  42768. * Attaches the scale behavior the passed in mesh
  42769. * @param ownerNode The mesh that will be scaled around once attached
  42770. */
  42771. attach(ownerNode: Mesh): void;
  42772. /**
  42773. * Detaches the behavior from the mesh
  42774. */
  42775. detach(): void;
  42776. }
  42777. }
  42778. declare module BABYLON {
  42779. /**
  42780. * Class used to apply inverse kinematics to bones
  42781. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42782. */
  42783. export class BoneIKController {
  42784. private static _tmpVecs;
  42785. private static _tmpQuat;
  42786. private static _tmpMats;
  42787. /**
  42788. * Gets or sets the target mesh
  42789. */
  42790. targetMesh: AbstractMesh;
  42791. /** Gets or sets the mesh used as pole */
  42792. poleTargetMesh: AbstractMesh;
  42793. /**
  42794. * Gets or sets the bone used as pole
  42795. */
  42796. poleTargetBone: Nullable<Bone>;
  42797. /**
  42798. * Gets or sets the target position
  42799. */
  42800. targetPosition: Vector3;
  42801. /**
  42802. * Gets or sets the pole target position
  42803. */
  42804. poleTargetPosition: Vector3;
  42805. /**
  42806. * Gets or sets the pole target local offset
  42807. */
  42808. poleTargetLocalOffset: Vector3;
  42809. /**
  42810. * Gets or sets the pole angle
  42811. */
  42812. poleAngle: number;
  42813. /**
  42814. * Gets or sets the mesh associated with the controller
  42815. */
  42816. mesh: AbstractMesh;
  42817. /**
  42818. * 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)
  42819. */
  42820. slerpAmount: number;
  42821. private _bone1Quat;
  42822. private _bone1Mat;
  42823. private _bone2Ang;
  42824. private _bone1;
  42825. private _bone2;
  42826. private _bone1Length;
  42827. private _bone2Length;
  42828. private _maxAngle;
  42829. private _maxReach;
  42830. private _rightHandedSystem;
  42831. private _bendAxis;
  42832. private _slerping;
  42833. private _adjustRoll;
  42834. /**
  42835. * Gets or sets maximum allowed angle
  42836. */
  42837. get maxAngle(): number;
  42838. set maxAngle(value: number);
  42839. /**
  42840. * Creates a new BoneIKController
  42841. * @param mesh defines the mesh to control
  42842. * @param bone defines the bone to control
  42843. * @param options defines options to set up the controller
  42844. */
  42845. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42846. targetMesh?: AbstractMesh;
  42847. poleTargetMesh?: AbstractMesh;
  42848. poleTargetBone?: Bone;
  42849. poleTargetLocalOffset?: Vector3;
  42850. poleAngle?: number;
  42851. bendAxis?: Vector3;
  42852. maxAngle?: number;
  42853. slerpAmount?: number;
  42854. });
  42855. private _setMaxAngle;
  42856. /**
  42857. * Force the controller to update the bones
  42858. */
  42859. update(): void;
  42860. }
  42861. }
  42862. declare module BABYLON {
  42863. /**
  42864. * Class used to make a bone look toward a point in space
  42865. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42866. */
  42867. export class BoneLookController {
  42868. private static _tmpVecs;
  42869. private static _tmpQuat;
  42870. private static _tmpMats;
  42871. /**
  42872. * The target Vector3 that the bone will look at
  42873. */
  42874. target: Vector3;
  42875. /**
  42876. * The mesh that the bone is attached to
  42877. */
  42878. mesh: AbstractMesh;
  42879. /**
  42880. * The bone that will be looking to the target
  42881. */
  42882. bone: Bone;
  42883. /**
  42884. * The up axis of the coordinate system that is used when the bone is rotated
  42885. */
  42886. upAxis: Vector3;
  42887. /**
  42888. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42889. */
  42890. upAxisSpace: Space;
  42891. /**
  42892. * Used to make an adjustment to the yaw of the bone
  42893. */
  42894. adjustYaw: number;
  42895. /**
  42896. * Used to make an adjustment to the pitch of the bone
  42897. */
  42898. adjustPitch: number;
  42899. /**
  42900. * Used to make an adjustment to the roll of the bone
  42901. */
  42902. adjustRoll: number;
  42903. /**
  42904. * 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)
  42905. */
  42906. slerpAmount: number;
  42907. private _minYaw;
  42908. private _maxYaw;
  42909. private _minPitch;
  42910. private _maxPitch;
  42911. private _minYawSin;
  42912. private _minYawCos;
  42913. private _maxYawSin;
  42914. private _maxYawCos;
  42915. private _midYawConstraint;
  42916. private _minPitchTan;
  42917. private _maxPitchTan;
  42918. private _boneQuat;
  42919. private _slerping;
  42920. private _transformYawPitch;
  42921. private _transformYawPitchInv;
  42922. private _firstFrameSkipped;
  42923. private _yawRange;
  42924. private _fowardAxis;
  42925. /**
  42926. * Gets or sets the minimum yaw angle that the bone can look to
  42927. */
  42928. get minYaw(): number;
  42929. set minYaw(value: number);
  42930. /**
  42931. * Gets or sets the maximum yaw angle that the bone can look to
  42932. */
  42933. get maxYaw(): number;
  42934. set maxYaw(value: number);
  42935. /**
  42936. * Gets or sets the minimum pitch angle that the bone can look to
  42937. */
  42938. get minPitch(): number;
  42939. set minPitch(value: number);
  42940. /**
  42941. * Gets or sets the maximum pitch angle that the bone can look to
  42942. */
  42943. get maxPitch(): number;
  42944. set maxPitch(value: number);
  42945. /**
  42946. * Create a BoneLookController
  42947. * @param mesh the mesh that the bone belongs to
  42948. * @param bone the bone that will be looking to the target
  42949. * @param target the target Vector3 to look at
  42950. * @param options optional settings:
  42951. * * maxYaw: the maximum angle the bone will yaw to
  42952. * * minYaw: the minimum angle the bone will yaw to
  42953. * * maxPitch: the maximum angle the bone will pitch to
  42954. * * minPitch: the minimum angle the bone will yaw to
  42955. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42956. * * upAxis: the up axis of the coordinate system
  42957. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42958. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42959. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42960. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42961. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42962. * * adjustRoll: used to make an adjustment to the roll of the bone
  42963. **/
  42964. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42965. maxYaw?: number;
  42966. minYaw?: number;
  42967. maxPitch?: number;
  42968. minPitch?: number;
  42969. slerpAmount?: number;
  42970. upAxis?: Vector3;
  42971. upAxisSpace?: Space;
  42972. yawAxis?: Vector3;
  42973. pitchAxis?: Vector3;
  42974. adjustYaw?: number;
  42975. adjustPitch?: number;
  42976. adjustRoll?: number;
  42977. });
  42978. /**
  42979. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42980. */
  42981. update(): void;
  42982. private _getAngleDiff;
  42983. private _getAngleBetween;
  42984. private _isAngleBetween;
  42985. }
  42986. }
  42987. declare module BABYLON {
  42988. /**
  42989. * Manage the gamepad inputs to control an arc rotate camera.
  42990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42991. */
  42992. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42993. /**
  42994. * Defines the camera the input is attached to.
  42995. */
  42996. camera: ArcRotateCamera;
  42997. /**
  42998. * Defines the gamepad the input is gathering event from.
  42999. */
  43000. gamepad: Nullable<Gamepad>;
  43001. /**
  43002. * Defines the gamepad rotation sensiblity.
  43003. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43004. */
  43005. gamepadRotationSensibility: number;
  43006. /**
  43007. * Defines the gamepad move sensiblity.
  43008. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43009. */
  43010. gamepadMoveSensibility: number;
  43011. private _yAxisScale;
  43012. /**
  43013. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43014. */
  43015. get invertYAxis(): boolean;
  43016. set invertYAxis(value: boolean);
  43017. private _onGamepadConnectedObserver;
  43018. private _onGamepadDisconnectedObserver;
  43019. /**
  43020. * Attach the input controls to a specific dom element to get the input from.
  43021. * @param element Defines the element the controls should be listened from
  43022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43023. */
  43024. attachControl(element: HTMLElement, noPreventDefault?: boolean): 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. * Update the current camera state depending on the inputs that have been used this frame.
  43032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43033. */
  43034. checkInputs(): void;
  43035. /**
  43036. * Gets the class name of the current intput.
  43037. * @returns the class name
  43038. */
  43039. getClassName(): string;
  43040. /**
  43041. * Get the friendly name associated with the input class.
  43042. * @returns the input friendly name
  43043. */
  43044. getSimpleName(): string;
  43045. }
  43046. }
  43047. declare module BABYLON {
  43048. interface ArcRotateCameraInputsManager {
  43049. /**
  43050. * Add orientation input support to the input manager.
  43051. * @returns the current input manager
  43052. */
  43053. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43054. }
  43055. /**
  43056. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43058. */
  43059. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43060. /**
  43061. * Defines the camera the input is attached to.
  43062. */
  43063. camera: ArcRotateCamera;
  43064. /**
  43065. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43066. */
  43067. alphaCorrection: number;
  43068. /**
  43069. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43070. */
  43071. gammaCorrection: number;
  43072. private _alpha;
  43073. private _gamma;
  43074. private _dirty;
  43075. private _deviceOrientationHandler;
  43076. /**
  43077. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43078. */
  43079. constructor();
  43080. /**
  43081. * Attach the input controls to a specific dom element to get the input from.
  43082. * @param element Defines the element the controls should be listened from
  43083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43084. */
  43085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43086. /** @hidden */
  43087. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43088. /**
  43089. * Update the current camera state depending on the inputs that have been used this frame.
  43090. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43091. */
  43092. checkInputs(): void;
  43093. /**
  43094. * Detach the current controls from the specified dom element.
  43095. * @param element Defines the element to stop listening the inputs from
  43096. */
  43097. detachControl(element: Nullable<HTMLElement>): void;
  43098. /**
  43099. * Gets the class name of the current intput.
  43100. * @returns the class name
  43101. */
  43102. getClassName(): string;
  43103. /**
  43104. * Get the friendly name associated with the input class.
  43105. * @returns the input friendly name
  43106. */
  43107. getSimpleName(): string;
  43108. }
  43109. }
  43110. declare module BABYLON {
  43111. /**
  43112. * Listen to mouse events to control the camera.
  43113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43114. */
  43115. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43116. /**
  43117. * Defines the camera the input is attached to.
  43118. */
  43119. camera: FlyCamera;
  43120. /**
  43121. * Defines if touch is enabled. (Default is true.)
  43122. */
  43123. touchEnabled: boolean;
  43124. /**
  43125. * Defines the buttons associated with the input to handle camera rotation.
  43126. */
  43127. buttons: number[];
  43128. /**
  43129. * Assign buttons for Yaw control.
  43130. */
  43131. buttonsYaw: number[];
  43132. /**
  43133. * Assign buttons for Pitch control.
  43134. */
  43135. buttonsPitch: number[];
  43136. /**
  43137. * Assign buttons for Roll control.
  43138. */
  43139. buttonsRoll: number[];
  43140. /**
  43141. * Detect if any button is being pressed while mouse is moved.
  43142. * -1 = Mouse locked.
  43143. * 0 = Left button.
  43144. * 1 = Middle Button.
  43145. * 2 = Right Button.
  43146. */
  43147. activeButton: number;
  43148. /**
  43149. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43150. * Higher values reduce its sensitivity.
  43151. */
  43152. angularSensibility: number;
  43153. private _mousemoveCallback;
  43154. private _observer;
  43155. private _rollObserver;
  43156. private previousPosition;
  43157. private noPreventDefault;
  43158. private element;
  43159. /**
  43160. * Listen to mouse events to control the camera.
  43161. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43163. */
  43164. constructor(touchEnabled?: boolean);
  43165. /**
  43166. * Attach the mouse control to the HTML DOM element.
  43167. * @param element Defines the element that listens to the input events.
  43168. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43169. */
  43170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43171. /**
  43172. * Detach the current controls from the specified dom element.
  43173. * @param element Defines the element to stop listening the inputs from
  43174. */
  43175. detachControl(element: Nullable<HTMLElement>): void;
  43176. /**
  43177. * Gets the class name of the current input.
  43178. * @returns the class name.
  43179. */
  43180. getClassName(): string;
  43181. /**
  43182. * Get the friendly name associated with the input class.
  43183. * @returns the input's friendly name.
  43184. */
  43185. getSimpleName(): string;
  43186. private _pointerInput;
  43187. private _onMouseMove;
  43188. /**
  43189. * Rotate camera by mouse offset.
  43190. */
  43191. private rotateCamera;
  43192. }
  43193. }
  43194. declare module BABYLON {
  43195. /**
  43196. * Default Inputs manager for the FlyCamera.
  43197. * It groups all the default supported inputs for ease of use.
  43198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43199. */
  43200. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43201. /**
  43202. * Instantiates a new FlyCameraInputsManager.
  43203. * @param camera Defines the camera the inputs belong to.
  43204. */
  43205. constructor(camera: FlyCamera);
  43206. /**
  43207. * Add keyboard input support to the input manager.
  43208. * @returns the new FlyCameraKeyboardMoveInput().
  43209. */
  43210. addKeyboard(): FlyCameraInputsManager;
  43211. /**
  43212. * Add mouse input support to the input manager.
  43213. * @param touchEnabled Enable touch screen support.
  43214. * @returns the new FlyCameraMouseInput().
  43215. */
  43216. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43217. }
  43218. }
  43219. declare module BABYLON {
  43220. /**
  43221. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43222. * such as in a 3D Space Shooter or a Flight Simulator.
  43223. */
  43224. export class FlyCamera extends TargetCamera {
  43225. /**
  43226. * Define the collision ellipsoid of the camera.
  43227. * This is helpful for simulating a camera body, like a player's body.
  43228. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43229. */
  43230. ellipsoid: Vector3;
  43231. /**
  43232. * Define an offset for the position of the ellipsoid around the camera.
  43233. * This can be helpful if the camera is attached away from the player's body center,
  43234. * such as at its head.
  43235. */
  43236. ellipsoidOffset: Vector3;
  43237. /**
  43238. * Enable or disable collisions of the camera with the rest of the scene objects.
  43239. */
  43240. checkCollisions: boolean;
  43241. /**
  43242. * Enable or disable gravity on the camera.
  43243. */
  43244. applyGravity: boolean;
  43245. /**
  43246. * Define the current direction the camera is moving to.
  43247. */
  43248. cameraDirection: Vector3;
  43249. /**
  43250. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43251. * This overrides and empties cameraRotation.
  43252. */
  43253. rotationQuaternion: Quaternion;
  43254. /**
  43255. * Track Roll to maintain the wanted Rolling when looking around.
  43256. */
  43257. _trackRoll: number;
  43258. /**
  43259. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43260. */
  43261. rollCorrect: number;
  43262. /**
  43263. * Mimic a banked turn, Rolling the camera when Yawing.
  43264. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43265. */
  43266. bankedTurn: boolean;
  43267. /**
  43268. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43269. */
  43270. bankedTurnLimit: number;
  43271. /**
  43272. * Value of 0 disables the banked Roll.
  43273. * Value of 1 is equal to the Yaw angle in radians.
  43274. */
  43275. bankedTurnMultiplier: number;
  43276. /**
  43277. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43278. */
  43279. inputs: FlyCameraInputsManager;
  43280. /**
  43281. * Gets the input sensibility for mouse input.
  43282. * Higher values reduce sensitivity.
  43283. */
  43284. get angularSensibility(): number;
  43285. /**
  43286. * Sets the input sensibility for a mouse input.
  43287. * Higher values reduce sensitivity.
  43288. */
  43289. set angularSensibility(value: number);
  43290. /**
  43291. * Get the keys for camera movement forward.
  43292. */
  43293. get keysForward(): number[];
  43294. /**
  43295. * Set the keys for camera movement forward.
  43296. */
  43297. set keysForward(value: number[]);
  43298. /**
  43299. * Get the keys for camera movement backward.
  43300. */
  43301. get keysBackward(): number[];
  43302. set keysBackward(value: number[]);
  43303. /**
  43304. * Get the keys for camera movement up.
  43305. */
  43306. get keysUp(): number[];
  43307. /**
  43308. * Set the keys for camera movement up.
  43309. */
  43310. set keysUp(value: number[]);
  43311. /**
  43312. * Get the keys for camera movement down.
  43313. */
  43314. get keysDown(): number[];
  43315. /**
  43316. * Set the keys for camera movement down.
  43317. */
  43318. set keysDown(value: number[]);
  43319. /**
  43320. * Get the keys for camera movement left.
  43321. */
  43322. get keysLeft(): number[];
  43323. /**
  43324. * Set the keys for camera movement left.
  43325. */
  43326. set keysLeft(value: number[]);
  43327. /**
  43328. * Set the keys for camera movement right.
  43329. */
  43330. get keysRight(): number[];
  43331. /**
  43332. * Set the keys for camera movement right.
  43333. */
  43334. set keysRight(value: number[]);
  43335. /**
  43336. * Event raised when the camera collides with a mesh in the scene.
  43337. */
  43338. onCollide: (collidedMesh: AbstractMesh) => void;
  43339. private _collider;
  43340. private _needMoveForGravity;
  43341. private _oldPosition;
  43342. private _diffPosition;
  43343. private _newPosition;
  43344. /** @hidden */
  43345. _localDirection: Vector3;
  43346. /** @hidden */
  43347. _transformedDirection: Vector3;
  43348. /**
  43349. * Instantiates a FlyCamera.
  43350. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43351. * such as in a 3D Space Shooter or a Flight Simulator.
  43352. * @param name Define the name of the camera in the scene.
  43353. * @param position Define the starting position of the camera in the scene.
  43354. * @param scene Define the scene the camera belongs to.
  43355. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43356. */
  43357. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43358. /**
  43359. * Attach a control to the HTML DOM element.
  43360. * @param element Defines the element that listens to the input events.
  43361. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43362. */
  43363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43364. /**
  43365. * Detach a control from the HTML DOM element.
  43366. * The camera will stop reacting to that input.
  43367. * @param element Defines the element that listens to the input events.
  43368. */
  43369. detachControl(element: HTMLElement): void;
  43370. private _collisionMask;
  43371. /**
  43372. * Get the mask that the camera ignores in collision events.
  43373. */
  43374. get collisionMask(): number;
  43375. /**
  43376. * Set the mask that the camera ignores in collision events.
  43377. */
  43378. set collisionMask(mask: number);
  43379. /** @hidden */
  43380. _collideWithWorld(displacement: Vector3): void;
  43381. /** @hidden */
  43382. private _onCollisionPositionChange;
  43383. /** @hidden */
  43384. _checkInputs(): void;
  43385. /** @hidden */
  43386. _decideIfNeedsToMove(): boolean;
  43387. /** @hidden */
  43388. _updatePosition(): void;
  43389. /**
  43390. * Restore the Roll to its target value at the rate specified.
  43391. * @param rate - Higher means slower restoring.
  43392. * @hidden
  43393. */
  43394. restoreRoll(rate: number): void;
  43395. /**
  43396. * Destroy the camera and release the current resources held by it.
  43397. */
  43398. dispose(): void;
  43399. /**
  43400. * Get the current object class name.
  43401. * @returns the class name.
  43402. */
  43403. getClassName(): string;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * Listen to keyboard events to control the camera.
  43409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43410. */
  43411. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43412. /**
  43413. * Defines the camera the input is attached to.
  43414. */
  43415. camera: FlyCamera;
  43416. /**
  43417. * The list of keyboard keys used to control the forward move of the camera.
  43418. */
  43419. keysForward: number[];
  43420. /**
  43421. * The list of keyboard keys used to control the backward move of the camera.
  43422. */
  43423. keysBackward: number[];
  43424. /**
  43425. * The list of keyboard keys used to control the forward move of the camera.
  43426. */
  43427. keysUp: number[];
  43428. /**
  43429. * The list of keyboard keys used to control the backward move of the camera.
  43430. */
  43431. keysDown: number[];
  43432. /**
  43433. * The list of keyboard keys used to control the right strafe move of the camera.
  43434. */
  43435. keysRight: number[];
  43436. /**
  43437. * The list of keyboard keys used to control the left strafe move of the camera.
  43438. */
  43439. keysLeft: number[];
  43440. private _keys;
  43441. private _onCanvasBlurObserver;
  43442. private _onKeyboardObserver;
  43443. private _engine;
  43444. private _scene;
  43445. /**
  43446. * Attach the input controls to a specific dom element to get the input from.
  43447. * @param element Defines the element the controls should be listened from
  43448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43449. */
  43450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43451. /**
  43452. * Detach the current controls from the specified dom element.
  43453. * @param element Defines the element to stop listening the inputs from
  43454. */
  43455. detachControl(element: Nullable<HTMLElement>): void;
  43456. /**
  43457. * Gets the class name of the current intput.
  43458. * @returns the class name
  43459. */
  43460. getClassName(): string;
  43461. /** @hidden */
  43462. _onLostFocus(e: FocusEvent): void;
  43463. /**
  43464. * Get the friendly name associated with the input class.
  43465. * @returns the input friendly name
  43466. */
  43467. getSimpleName(): string;
  43468. /**
  43469. * Update the current camera state depending on the inputs that have been used this frame.
  43470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43471. */
  43472. checkInputs(): void;
  43473. }
  43474. }
  43475. declare module BABYLON {
  43476. /**
  43477. * Manage the mouse wheel inputs to control a follow camera.
  43478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43479. */
  43480. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43481. /**
  43482. * Defines the camera the input is attached to.
  43483. */
  43484. camera: FollowCamera;
  43485. /**
  43486. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43487. */
  43488. axisControlRadius: boolean;
  43489. /**
  43490. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43491. */
  43492. axisControlHeight: boolean;
  43493. /**
  43494. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43495. */
  43496. axisControlRotation: boolean;
  43497. /**
  43498. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43499. * relation to mouseWheel events.
  43500. */
  43501. wheelPrecision: number;
  43502. /**
  43503. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43504. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43505. */
  43506. wheelDeltaPercentage: number;
  43507. private _wheel;
  43508. private _observer;
  43509. /**
  43510. * Attach the input controls to a specific dom element to get the input from.
  43511. * @param element Defines the element the controls should be listened from
  43512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43513. */
  43514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43515. /**
  43516. * Detach the current controls from the specified dom element.
  43517. * @param element Defines the element to stop listening the inputs from
  43518. */
  43519. detachControl(element: Nullable<HTMLElement>): void;
  43520. /**
  43521. * Gets the class name of the current intput.
  43522. * @returns the class name
  43523. */
  43524. getClassName(): string;
  43525. /**
  43526. * Get the friendly name associated with the input class.
  43527. * @returns the input friendly name
  43528. */
  43529. getSimpleName(): string;
  43530. }
  43531. }
  43532. declare module BABYLON {
  43533. /**
  43534. * Manage the pointers inputs to control an follow camera.
  43535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43536. */
  43537. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43538. /**
  43539. * Defines the camera the input is attached to.
  43540. */
  43541. camera: FollowCamera;
  43542. /**
  43543. * Gets the class name of the current input.
  43544. * @returns the class name
  43545. */
  43546. getClassName(): string;
  43547. /**
  43548. * Defines the pointer angular sensibility along the X axis or how fast is
  43549. * the camera rotating.
  43550. * A negative number will reverse the axis direction.
  43551. */
  43552. angularSensibilityX: number;
  43553. /**
  43554. * Defines the pointer angular sensibility along the Y axis or how fast is
  43555. * the camera rotating.
  43556. * A negative number will reverse the axis direction.
  43557. */
  43558. angularSensibilityY: number;
  43559. /**
  43560. * Defines the pointer pinch precision or how fast is the camera zooming.
  43561. * A negative number will reverse the axis direction.
  43562. */
  43563. pinchPrecision: number;
  43564. /**
  43565. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43566. * from 0.
  43567. * It defines the percentage of current camera.radius to use as delta when
  43568. * pinch zoom is used.
  43569. */
  43570. pinchDeltaPercentage: number;
  43571. /**
  43572. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43573. */
  43574. axisXControlRadius: boolean;
  43575. /**
  43576. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43577. */
  43578. axisXControlHeight: boolean;
  43579. /**
  43580. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43581. */
  43582. axisXControlRotation: boolean;
  43583. /**
  43584. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43585. */
  43586. axisYControlRadius: boolean;
  43587. /**
  43588. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43589. */
  43590. axisYControlHeight: boolean;
  43591. /**
  43592. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43593. */
  43594. axisYControlRotation: boolean;
  43595. /**
  43596. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43597. */
  43598. axisPinchControlRadius: boolean;
  43599. /**
  43600. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43601. */
  43602. axisPinchControlHeight: boolean;
  43603. /**
  43604. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43605. */
  43606. axisPinchControlRotation: boolean;
  43607. /**
  43608. * Log error messages if basic misconfiguration has occurred.
  43609. */
  43610. warningEnable: boolean;
  43611. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43612. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43613. private _warningCounter;
  43614. private _warning;
  43615. }
  43616. }
  43617. declare module BABYLON {
  43618. /**
  43619. * Default Inputs manager for the FollowCamera.
  43620. * It groups all the default supported inputs for ease of use.
  43621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43622. */
  43623. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43624. /**
  43625. * Instantiates a new FollowCameraInputsManager.
  43626. * @param camera Defines the camera the inputs belong to
  43627. */
  43628. constructor(camera: FollowCamera);
  43629. /**
  43630. * Add keyboard input support to the input manager.
  43631. * @returns the current input manager
  43632. */
  43633. addKeyboard(): FollowCameraInputsManager;
  43634. /**
  43635. * Add mouse wheel input support to the input manager.
  43636. * @returns the current input manager
  43637. */
  43638. addMouseWheel(): FollowCameraInputsManager;
  43639. /**
  43640. * Add pointers input support to the input manager.
  43641. * @returns the current input manager
  43642. */
  43643. addPointers(): FollowCameraInputsManager;
  43644. /**
  43645. * Add orientation input support to the input manager.
  43646. * @returns the current input manager
  43647. */
  43648. addVRDeviceOrientation(): FollowCameraInputsManager;
  43649. }
  43650. }
  43651. declare module BABYLON {
  43652. /**
  43653. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43654. * an arc rotate version arcFollowCamera are available.
  43655. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43656. */
  43657. export class FollowCamera extends TargetCamera {
  43658. /**
  43659. * Distance the follow camera should follow an object at
  43660. */
  43661. radius: number;
  43662. /**
  43663. * Minimum allowed distance of the camera to the axis of rotation
  43664. * (The camera can not get closer).
  43665. * This can help limiting how the Camera is able to move in the scene.
  43666. */
  43667. lowerRadiusLimit: Nullable<number>;
  43668. /**
  43669. * Maximum allowed distance of the camera to the axis of rotation
  43670. * (The camera can not get further).
  43671. * This can help limiting how the Camera is able to move in the scene.
  43672. */
  43673. upperRadiusLimit: Nullable<number>;
  43674. /**
  43675. * Define a rotation offset between the camera and the object it follows
  43676. */
  43677. rotationOffset: number;
  43678. /**
  43679. * Minimum allowed angle to camera position relative to target object.
  43680. * This can help limiting how the Camera is able to move in the scene.
  43681. */
  43682. lowerRotationOffsetLimit: Nullable<number>;
  43683. /**
  43684. * Maximum allowed angle to camera position relative to target object.
  43685. * This can help limiting how the Camera is able to move in the scene.
  43686. */
  43687. upperRotationOffsetLimit: Nullable<number>;
  43688. /**
  43689. * Define a height offset between the camera and the object it follows.
  43690. * It can help following an object from the top (like a car chaing a plane)
  43691. */
  43692. heightOffset: number;
  43693. /**
  43694. * Minimum allowed height of camera position relative to target object.
  43695. * This can help limiting how the Camera is able to move in the scene.
  43696. */
  43697. lowerHeightOffsetLimit: Nullable<number>;
  43698. /**
  43699. * Maximum allowed height of camera position relative to target object.
  43700. * This can help limiting how the Camera is able to move in the scene.
  43701. */
  43702. upperHeightOffsetLimit: Nullable<number>;
  43703. /**
  43704. * Define how fast the camera can accelerate to follow it s target.
  43705. */
  43706. cameraAcceleration: number;
  43707. /**
  43708. * Define the speed limit of the camera following an object.
  43709. */
  43710. maxCameraSpeed: number;
  43711. /**
  43712. * Define the target of the camera.
  43713. */
  43714. lockedTarget: Nullable<AbstractMesh>;
  43715. /**
  43716. * Defines the input associated with the camera.
  43717. */
  43718. inputs: FollowCameraInputsManager;
  43719. /**
  43720. * Instantiates the follow camera.
  43721. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43722. * @param name Define the name of the camera in the scene
  43723. * @param position Define the position of the camera
  43724. * @param scene Define the scene the camera belong to
  43725. * @param lockedTarget Define the target of the camera
  43726. */
  43727. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43728. private _follow;
  43729. /**
  43730. * Attached controls to the current camera.
  43731. * @param element Defines the element the controls should be listened from
  43732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43733. */
  43734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43735. /**
  43736. * Detach the current controls from the camera.
  43737. * The camera will stop reacting to inputs.
  43738. * @param element Defines the element to stop listening the inputs from
  43739. */
  43740. detachControl(element: HTMLElement): void;
  43741. /** @hidden */
  43742. _checkInputs(): void;
  43743. private _checkLimits;
  43744. /**
  43745. * Gets the camera class name.
  43746. * @returns the class name
  43747. */
  43748. getClassName(): string;
  43749. }
  43750. /**
  43751. * Arc Rotate version of the follow camera.
  43752. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43753. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43754. */
  43755. export class ArcFollowCamera extends TargetCamera {
  43756. /** The longitudinal angle of the camera */
  43757. alpha: number;
  43758. /** The latitudinal angle of the camera */
  43759. beta: number;
  43760. /** The radius of the camera from its target */
  43761. radius: number;
  43762. /** Define the camera target (the mesh it should follow) */
  43763. target: Nullable<AbstractMesh>;
  43764. private _cartesianCoordinates;
  43765. /**
  43766. * Instantiates a new ArcFollowCamera
  43767. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43768. * @param name Define the name of the camera
  43769. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43770. * @param beta Define the rotation angle of the camera around the elevation axis
  43771. * @param radius Define the radius of the camera from its target point
  43772. * @param target Define the target of the camera
  43773. * @param scene Define the scene the camera belongs to
  43774. */
  43775. constructor(name: string,
  43776. /** The longitudinal angle of the camera */
  43777. alpha: number,
  43778. /** The latitudinal angle of the camera */
  43779. beta: number,
  43780. /** The radius of the camera from its target */
  43781. radius: number,
  43782. /** Define the camera target (the mesh it should follow) */
  43783. target: Nullable<AbstractMesh>, scene: Scene);
  43784. private _follow;
  43785. /** @hidden */
  43786. _checkInputs(): void;
  43787. /**
  43788. * Returns the class name of the object.
  43789. * It is mostly used internally for serialization purposes.
  43790. */
  43791. getClassName(): string;
  43792. }
  43793. }
  43794. declare module BABYLON {
  43795. /**
  43796. * Manage the keyboard inputs to control the movement of a follow camera.
  43797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43798. */
  43799. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43800. /**
  43801. * Defines the camera the input is attached to.
  43802. */
  43803. camera: FollowCamera;
  43804. /**
  43805. * Defines the list of key codes associated with the up action (increase heightOffset)
  43806. */
  43807. keysHeightOffsetIncr: number[];
  43808. /**
  43809. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43810. */
  43811. keysHeightOffsetDecr: number[];
  43812. /**
  43813. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43814. */
  43815. keysHeightOffsetModifierAlt: boolean;
  43816. /**
  43817. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43818. */
  43819. keysHeightOffsetModifierCtrl: boolean;
  43820. /**
  43821. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43822. */
  43823. keysHeightOffsetModifierShift: boolean;
  43824. /**
  43825. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43826. */
  43827. keysRotationOffsetIncr: number[];
  43828. /**
  43829. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43830. */
  43831. keysRotationOffsetDecr: number[];
  43832. /**
  43833. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43834. */
  43835. keysRotationOffsetModifierAlt: boolean;
  43836. /**
  43837. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43838. */
  43839. keysRotationOffsetModifierCtrl: boolean;
  43840. /**
  43841. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43842. */
  43843. keysRotationOffsetModifierShift: boolean;
  43844. /**
  43845. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43846. */
  43847. keysRadiusIncr: number[];
  43848. /**
  43849. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43850. */
  43851. keysRadiusDecr: number[];
  43852. /**
  43853. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43854. */
  43855. keysRadiusModifierAlt: boolean;
  43856. /**
  43857. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43858. */
  43859. keysRadiusModifierCtrl: boolean;
  43860. /**
  43861. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43862. */
  43863. keysRadiusModifierShift: boolean;
  43864. /**
  43865. * Defines the rate of change of heightOffset.
  43866. */
  43867. heightSensibility: number;
  43868. /**
  43869. * Defines the rate of change of rotationOffset.
  43870. */
  43871. rotationSensibility: number;
  43872. /**
  43873. * Defines the rate of change of radius.
  43874. */
  43875. radiusSensibility: number;
  43876. private _keys;
  43877. private _ctrlPressed;
  43878. private _altPressed;
  43879. private _shiftPressed;
  43880. private _onCanvasBlurObserver;
  43881. private _onKeyboardObserver;
  43882. private _engine;
  43883. private _scene;
  43884. /**
  43885. * Attach the input controls to a specific dom element to get the input from.
  43886. * @param element Defines the element the controls should be listened from
  43887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43888. */
  43889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43890. /**
  43891. * Detach the current controls from the specified dom element.
  43892. * @param element Defines the element to stop listening the inputs from
  43893. */
  43894. detachControl(element: Nullable<HTMLElement>): void;
  43895. /**
  43896. * Update the current camera state depending on the inputs that have been used this frame.
  43897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43898. */
  43899. checkInputs(): void;
  43900. /**
  43901. * Gets the class name of the current input.
  43902. * @returns the class name
  43903. */
  43904. getClassName(): string;
  43905. /**
  43906. * Get the friendly name associated with the input class.
  43907. * @returns the input friendly name
  43908. */
  43909. getSimpleName(): string;
  43910. /**
  43911. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43912. * allow modification of the heightOffset value.
  43913. */
  43914. private _modifierHeightOffset;
  43915. /**
  43916. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43917. * allow modification of the rotationOffset value.
  43918. */
  43919. private _modifierRotationOffset;
  43920. /**
  43921. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43922. * allow modification of the radius value.
  43923. */
  43924. private _modifierRadius;
  43925. }
  43926. }
  43927. declare module BABYLON {
  43928. interface FreeCameraInputsManager {
  43929. /**
  43930. * @hidden
  43931. */
  43932. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43933. /**
  43934. * Add orientation input support to the input manager.
  43935. * @returns the current input manager
  43936. */
  43937. addDeviceOrientation(): FreeCameraInputsManager;
  43938. }
  43939. /**
  43940. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43941. * Screen rotation is taken into account.
  43942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43943. */
  43944. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43945. private _camera;
  43946. private _screenOrientationAngle;
  43947. private _constantTranform;
  43948. private _screenQuaternion;
  43949. private _alpha;
  43950. private _beta;
  43951. private _gamma;
  43952. /**
  43953. * Can be used to detect if a device orientation sensor is available on a device
  43954. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43955. * @returns a promise that will resolve on orientation change
  43956. */
  43957. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43958. /**
  43959. * @hidden
  43960. */
  43961. _onDeviceOrientationChangedObservable: Observable<void>;
  43962. /**
  43963. * Instantiates a new input
  43964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43965. */
  43966. constructor();
  43967. /**
  43968. * Define the camera controlled by the input.
  43969. */
  43970. get camera(): FreeCamera;
  43971. set camera(camera: FreeCamera);
  43972. /**
  43973. * Attach the input controls to a specific dom element to get the input from.
  43974. * @param element Defines the element the controls should be listened from
  43975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43976. */
  43977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43978. private _orientationChanged;
  43979. private _deviceOrientation;
  43980. /**
  43981. * Detach the current controls from the specified dom element.
  43982. * @param element Defines the element to stop listening the inputs from
  43983. */
  43984. detachControl(element: Nullable<HTMLElement>): void;
  43985. /**
  43986. * Update the current camera state depending on the inputs that have been used this frame.
  43987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43988. */
  43989. checkInputs(): void;
  43990. /**
  43991. * Gets the class name of the current intput.
  43992. * @returns the class name
  43993. */
  43994. getClassName(): string;
  43995. /**
  43996. * Get the friendly name associated with the input class.
  43997. * @returns the input friendly name
  43998. */
  43999. getSimpleName(): string;
  44000. }
  44001. }
  44002. declare module BABYLON {
  44003. /**
  44004. * Manage the gamepad inputs to control a free camera.
  44005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44006. */
  44007. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44008. /**
  44009. * Define the camera the input is attached to.
  44010. */
  44011. camera: FreeCamera;
  44012. /**
  44013. * Define the Gamepad controlling the input
  44014. */
  44015. gamepad: Nullable<Gamepad>;
  44016. /**
  44017. * Defines the gamepad rotation sensiblity.
  44018. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44019. */
  44020. gamepadAngularSensibility: number;
  44021. /**
  44022. * Defines the gamepad move sensiblity.
  44023. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44024. */
  44025. gamepadMoveSensibility: number;
  44026. private _yAxisScale;
  44027. /**
  44028. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44029. */
  44030. get invertYAxis(): boolean;
  44031. set invertYAxis(value: boolean);
  44032. private _onGamepadConnectedObserver;
  44033. private _onGamepadDisconnectedObserver;
  44034. private _cameraTransform;
  44035. private _deltaTransform;
  44036. private _vector3;
  44037. private _vector2;
  44038. /**
  44039. * Attach the input controls to a specific dom element to get the input from.
  44040. * @param element Defines the element the controls should be listened from
  44041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44042. */
  44043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44044. /**
  44045. * Detach the current controls from the specified dom element.
  44046. * @param element Defines the element to stop listening the inputs from
  44047. */
  44048. detachControl(element: Nullable<HTMLElement>): void;
  44049. /**
  44050. * Update the current camera state depending on the inputs that have been used this frame.
  44051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44052. */
  44053. checkInputs(): void;
  44054. /**
  44055. * Gets the class name of the current intput.
  44056. * @returns the class name
  44057. */
  44058. getClassName(): string;
  44059. /**
  44060. * Get the friendly name associated with the input class.
  44061. * @returns the input friendly name
  44062. */
  44063. getSimpleName(): string;
  44064. }
  44065. }
  44066. declare module BABYLON {
  44067. /**
  44068. * Defines the potential axis of a Joystick
  44069. */
  44070. export enum JoystickAxis {
  44071. /** X axis */
  44072. X = 0,
  44073. /** Y axis */
  44074. Y = 1,
  44075. /** Z axis */
  44076. Z = 2
  44077. }
  44078. /**
  44079. * Class used to define virtual joystick (used in touch mode)
  44080. */
  44081. export class VirtualJoystick {
  44082. /**
  44083. * Gets or sets a boolean indicating that left and right values must be inverted
  44084. */
  44085. reverseLeftRight: boolean;
  44086. /**
  44087. * Gets or sets a boolean indicating that up and down values must be inverted
  44088. */
  44089. reverseUpDown: boolean;
  44090. /**
  44091. * Gets the offset value for the position (ie. the change of the position value)
  44092. */
  44093. deltaPosition: Vector3;
  44094. /**
  44095. * Gets a boolean indicating if the virtual joystick was pressed
  44096. */
  44097. pressed: boolean;
  44098. /**
  44099. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44100. */
  44101. static Canvas: Nullable<HTMLCanvasElement>;
  44102. private static _globalJoystickIndex;
  44103. private static vjCanvasContext;
  44104. private static vjCanvasWidth;
  44105. private static vjCanvasHeight;
  44106. private static halfWidth;
  44107. private _action;
  44108. private _axisTargetedByLeftAndRight;
  44109. private _axisTargetedByUpAndDown;
  44110. private _joystickSensibility;
  44111. private _inversedSensibility;
  44112. private _joystickPointerID;
  44113. private _joystickColor;
  44114. private _joystickPointerPos;
  44115. private _joystickPreviousPointerPos;
  44116. private _joystickPointerStartPos;
  44117. private _deltaJoystickVector;
  44118. private _leftJoystick;
  44119. private _touches;
  44120. private _onPointerDownHandlerRef;
  44121. private _onPointerMoveHandlerRef;
  44122. private _onPointerUpHandlerRef;
  44123. private _onResize;
  44124. /**
  44125. * Creates a new virtual joystick
  44126. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44127. */
  44128. constructor(leftJoystick?: boolean);
  44129. /**
  44130. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44131. * @param newJoystickSensibility defines the new sensibility
  44132. */
  44133. setJoystickSensibility(newJoystickSensibility: number): void;
  44134. private _onPointerDown;
  44135. private _onPointerMove;
  44136. private _onPointerUp;
  44137. /**
  44138. * Change the color of the virtual joystick
  44139. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44140. */
  44141. setJoystickColor(newColor: string): void;
  44142. /**
  44143. * Defines a callback to call when the joystick is touched
  44144. * @param action defines the callback
  44145. */
  44146. setActionOnTouch(action: () => any): void;
  44147. /**
  44148. * Defines which axis you'd like to control for left & right
  44149. * @param axis defines the axis to use
  44150. */
  44151. setAxisForLeftRight(axis: JoystickAxis): void;
  44152. /**
  44153. * Defines which axis you'd like to control for up & down
  44154. * @param axis defines the axis to use
  44155. */
  44156. setAxisForUpDown(axis: JoystickAxis): void;
  44157. private _drawVirtualJoystick;
  44158. /**
  44159. * Release internal HTML canvas
  44160. */
  44161. releaseCanvas(): void;
  44162. }
  44163. }
  44164. declare module BABYLON {
  44165. interface FreeCameraInputsManager {
  44166. /**
  44167. * Add virtual joystick input support to the input manager.
  44168. * @returns the current input manager
  44169. */
  44170. addVirtualJoystick(): FreeCameraInputsManager;
  44171. }
  44172. /**
  44173. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44175. */
  44176. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44177. /**
  44178. * Defines the camera the input is attached to.
  44179. */
  44180. camera: FreeCamera;
  44181. private _leftjoystick;
  44182. private _rightjoystick;
  44183. /**
  44184. * Gets the left stick of the virtual joystick.
  44185. * @returns The virtual Joystick
  44186. */
  44187. getLeftJoystick(): VirtualJoystick;
  44188. /**
  44189. * Gets the right stick of the virtual joystick.
  44190. * @returns The virtual Joystick
  44191. */
  44192. getRightJoystick(): VirtualJoystick;
  44193. /**
  44194. * Update the current camera state depending on the inputs that have been used this frame.
  44195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44196. */
  44197. checkInputs(): void;
  44198. /**
  44199. * Attach the input controls to a specific dom element to get the input from.
  44200. * @param element Defines the element the controls should be listened from
  44201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44202. */
  44203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44204. /**
  44205. * Detach the current controls from the specified dom element.
  44206. * @param element Defines the element to stop listening the inputs from
  44207. */
  44208. detachControl(element: Nullable<HTMLElement>): void;
  44209. /**
  44210. * Gets the class name of the current intput.
  44211. * @returns the class name
  44212. */
  44213. getClassName(): string;
  44214. /**
  44215. * Get the friendly name associated with the input class.
  44216. * @returns the input friendly name
  44217. */
  44218. getSimpleName(): string;
  44219. }
  44220. }
  44221. declare module BABYLON {
  44222. /**
  44223. * This represents a FPS type of camera controlled by touch.
  44224. * This is like a universal camera minus the Gamepad controls.
  44225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44226. */
  44227. export class TouchCamera extends FreeCamera {
  44228. /**
  44229. * Defines the touch sensibility for rotation.
  44230. * The higher the faster.
  44231. */
  44232. get touchAngularSensibility(): number;
  44233. set touchAngularSensibility(value: number);
  44234. /**
  44235. * Defines the touch sensibility for move.
  44236. * The higher the faster.
  44237. */
  44238. get touchMoveSensibility(): number;
  44239. set touchMoveSensibility(value: number);
  44240. /**
  44241. * Instantiates a new touch camera.
  44242. * This represents a FPS type of camera controlled by touch.
  44243. * This is like a universal camera minus the Gamepad controls.
  44244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44245. * @param name Define the name of the camera in the scene
  44246. * @param position Define the start position of the camera in the scene
  44247. * @param scene Define the scene the camera belongs to
  44248. */
  44249. constructor(name: string, position: Vector3, scene: Scene);
  44250. /**
  44251. * Gets the current object class name.
  44252. * @return the class name
  44253. */
  44254. getClassName(): string;
  44255. /** @hidden */
  44256. _setupInputs(): void;
  44257. }
  44258. }
  44259. declare module BABYLON {
  44260. /**
  44261. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44262. * being tilted forward or back and left or right.
  44263. */
  44264. export class DeviceOrientationCamera extends FreeCamera {
  44265. private _initialQuaternion;
  44266. private _quaternionCache;
  44267. private _tmpDragQuaternion;
  44268. private _disablePointerInputWhenUsingDeviceOrientation;
  44269. /**
  44270. * Creates a new device orientation camera
  44271. * @param name The name of the camera
  44272. * @param position The start position camera
  44273. * @param scene The scene the camera belongs to
  44274. */
  44275. constructor(name: string, position: Vector3, scene: Scene);
  44276. /**
  44277. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44278. */
  44279. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44280. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44281. private _dragFactor;
  44282. /**
  44283. * Enabled turning on the y axis when the orientation sensor is active
  44284. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44285. */
  44286. enableHorizontalDragging(dragFactor?: number): void;
  44287. /**
  44288. * Gets the current instance class name ("DeviceOrientationCamera").
  44289. * This helps avoiding instanceof at run time.
  44290. * @returns the class name
  44291. */
  44292. getClassName(): string;
  44293. /**
  44294. * @hidden
  44295. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44296. */
  44297. _checkInputs(): void;
  44298. /**
  44299. * Reset the camera to its default orientation on the specified axis only.
  44300. * @param axis The axis to reset
  44301. */
  44302. resetToCurrentRotation(axis?: Axis): void;
  44303. }
  44304. }
  44305. declare module BABYLON {
  44306. /**
  44307. * Defines supported buttons for XBox360 compatible gamepads
  44308. */
  44309. export enum Xbox360Button {
  44310. /** A */
  44311. A = 0,
  44312. /** B */
  44313. B = 1,
  44314. /** X */
  44315. X = 2,
  44316. /** Y */
  44317. Y = 3,
  44318. /** Left button */
  44319. LB = 4,
  44320. /** Right button */
  44321. RB = 5,
  44322. /** Back */
  44323. Back = 8,
  44324. /** Start */
  44325. Start = 9,
  44326. /** Left stick */
  44327. LeftStick = 10,
  44328. /** Right stick */
  44329. RightStick = 11
  44330. }
  44331. /** Defines values for XBox360 DPad */
  44332. export enum Xbox360Dpad {
  44333. /** Up */
  44334. Up = 12,
  44335. /** Down */
  44336. Down = 13,
  44337. /** Left */
  44338. Left = 14,
  44339. /** Right */
  44340. Right = 15
  44341. }
  44342. /**
  44343. * Defines a XBox360 gamepad
  44344. */
  44345. export class Xbox360Pad extends Gamepad {
  44346. private _leftTrigger;
  44347. private _rightTrigger;
  44348. private _onlefttriggerchanged;
  44349. private _onrighttriggerchanged;
  44350. private _onbuttondown;
  44351. private _onbuttonup;
  44352. private _ondpaddown;
  44353. private _ondpadup;
  44354. /** Observable raised when a button is pressed */
  44355. onButtonDownObservable: Observable<Xbox360Button>;
  44356. /** Observable raised when a button is released */
  44357. onButtonUpObservable: Observable<Xbox360Button>;
  44358. /** Observable raised when a pad is pressed */
  44359. onPadDownObservable: Observable<Xbox360Dpad>;
  44360. /** Observable raised when a pad is released */
  44361. onPadUpObservable: Observable<Xbox360Dpad>;
  44362. private _buttonA;
  44363. private _buttonB;
  44364. private _buttonX;
  44365. private _buttonY;
  44366. private _buttonBack;
  44367. private _buttonStart;
  44368. private _buttonLB;
  44369. private _buttonRB;
  44370. private _buttonLeftStick;
  44371. private _buttonRightStick;
  44372. private _dPadUp;
  44373. private _dPadDown;
  44374. private _dPadLeft;
  44375. private _dPadRight;
  44376. private _isXboxOnePad;
  44377. /**
  44378. * Creates a new XBox360 gamepad object
  44379. * @param id defines the id of this gamepad
  44380. * @param index defines its index
  44381. * @param gamepad defines the internal HTML gamepad object
  44382. * @param xboxOne defines if it is a XBox One gamepad
  44383. */
  44384. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44385. /**
  44386. * Defines the callback to call when left trigger is pressed
  44387. * @param callback defines the callback to use
  44388. */
  44389. onlefttriggerchanged(callback: (value: number) => void): void;
  44390. /**
  44391. * Defines the callback to call when right trigger is pressed
  44392. * @param callback defines the callback to use
  44393. */
  44394. onrighttriggerchanged(callback: (value: number) => void): void;
  44395. /**
  44396. * Gets the left trigger value
  44397. */
  44398. get leftTrigger(): number;
  44399. /**
  44400. * Sets the left trigger value
  44401. */
  44402. set leftTrigger(newValue: number);
  44403. /**
  44404. * Gets the right trigger value
  44405. */
  44406. get rightTrigger(): number;
  44407. /**
  44408. * Sets the right trigger value
  44409. */
  44410. set rightTrigger(newValue: number);
  44411. /**
  44412. * Defines the callback to call when a button is pressed
  44413. * @param callback defines the callback to use
  44414. */
  44415. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44416. /**
  44417. * Defines the callback to call when a button is released
  44418. * @param callback defines the callback to use
  44419. */
  44420. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44421. /**
  44422. * Defines the callback to call when a pad is pressed
  44423. * @param callback defines the callback to use
  44424. */
  44425. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44426. /**
  44427. * Defines the callback to call when a pad is released
  44428. * @param callback defines the callback to use
  44429. */
  44430. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44431. private _setButtonValue;
  44432. private _setDPadValue;
  44433. /**
  44434. * Gets the value of the `A` button
  44435. */
  44436. get buttonA(): number;
  44437. /**
  44438. * Sets the value of the `A` button
  44439. */
  44440. set buttonA(value: number);
  44441. /**
  44442. * Gets the value of the `B` button
  44443. */
  44444. get buttonB(): number;
  44445. /**
  44446. * Sets the value of the `B` button
  44447. */
  44448. set buttonB(value: number);
  44449. /**
  44450. * Gets the value of the `X` button
  44451. */
  44452. get buttonX(): number;
  44453. /**
  44454. * Sets the value of the `X` button
  44455. */
  44456. set buttonX(value: number);
  44457. /**
  44458. * Gets the value of the `Y` button
  44459. */
  44460. get buttonY(): number;
  44461. /**
  44462. * Sets the value of the `Y` button
  44463. */
  44464. set buttonY(value: number);
  44465. /**
  44466. * Gets the value of the `Start` button
  44467. */
  44468. get buttonStart(): number;
  44469. /**
  44470. * Sets the value of the `Start` button
  44471. */
  44472. set buttonStart(value: number);
  44473. /**
  44474. * Gets the value of the `Back` button
  44475. */
  44476. get buttonBack(): number;
  44477. /**
  44478. * Sets the value of the `Back` button
  44479. */
  44480. set buttonBack(value: number);
  44481. /**
  44482. * Gets the value of the `Left` button
  44483. */
  44484. get buttonLB(): number;
  44485. /**
  44486. * Sets the value of the `Left` button
  44487. */
  44488. set buttonLB(value: number);
  44489. /**
  44490. * Gets the value of the `Right` button
  44491. */
  44492. get buttonRB(): number;
  44493. /**
  44494. * Sets the value of the `Right` button
  44495. */
  44496. set buttonRB(value: number);
  44497. /**
  44498. * Gets the value of the Left joystick
  44499. */
  44500. get buttonLeftStick(): number;
  44501. /**
  44502. * Sets the value of the Left joystick
  44503. */
  44504. set buttonLeftStick(value: number);
  44505. /**
  44506. * Gets the value of the Right joystick
  44507. */
  44508. get buttonRightStick(): number;
  44509. /**
  44510. * Sets the value of the Right joystick
  44511. */
  44512. set buttonRightStick(value: number);
  44513. /**
  44514. * Gets the value of D-pad up
  44515. */
  44516. get dPadUp(): number;
  44517. /**
  44518. * Sets the value of D-pad up
  44519. */
  44520. set dPadUp(value: number);
  44521. /**
  44522. * Gets the value of D-pad down
  44523. */
  44524. get dPadDown(): number;
  44525. /**
  44526. * Sets the value of D-pad down
  44527. */
  44528. set dPadDown(value: number);
  44529. /**
  44530. * Gets the value of D-pad left
  44531. */
  44532. get dPadLeft(): number;
  44533. /**
  44534. * Sets the value of D-pad left
  44535. */
  44536. set dPadLeft(value: number);
  44537. /**
  44538. * Gets the value of D-pad right
  44539. */
  44540. get dPadRight(): number;
  44541. /**
  44542. * Sets the value of D-pad right
  44543. */
  44544. set dPadRight(value: number);
  44545. /**
  44546. * Force the gamepad to synchronize with device values
  44547. */
  44548. update(): void;
  44549. /**
  44550. * Disposes the gamepad
  44551. */
  44552. dispose(): void;
  44553. }
  44554. }
  44555. declare module BABYLON {
  44556. /**
  44557. * Defines supported buttons for DualShock compatible gamepads
  44558. */
  44559. export enum DualShockButton {
  44560. /** Cross */
  44561. Cross = 0,
  44562. /** Circle */
  44563. Circle = 1,
  44564. /** Square */
  44565. Square = 2,
  44566. /** Triangle */
  44567. Triangle = 3,
  44568. /** L1 */
  44569. L1 = 4,
  44570. /** R1 */
  44571. R1 = 5,
  44572. /** Share */
  44573. Share = 8,
  44574. /** Options */
  44575. Options = 9,
  44576. /** Left stick */
  44577. LeftStick = 10,
  44578. /** Right stick */
  44579. RightStick = 11
  44580. }
  44581. /** Defines values for DualShock DPad */
  44582. export enum DualShockDpad {
  44583. /** Up */
  44584. Up = 12,
  44585. /** Down */
  44586. Down = 13,
  44587. /** Left */
  44588. Left = 14,
  44589. /** Right */
  44590. Right = 15
  44591. }
  44592. /**
  44593. * Defines a DualShock gamepad
  44594. */
  44595. export class DualShockPad extends Gamepad {
  44596. private _leftTrigger;
  44597. private _rightTrigger;
  44598. private _onlefttriggerchanged;
  44599. private _onrighttriggerchanged;
  44600. private _onbuttondown;
  44601. private _onbuttonup;
  44602. private _ondpaddown;
  44603. private _ondpadup;
  44604. /** Observable raised when a button is pressed */
  44605. onButtonDownObservable: Observable<DualShockButton>;
  44606. /** Observable raised when a button is released */
  44607. onButtonUpObservable: Observable<DualShockButton>;
  44608. /** Observable raised when a pad is pressed */
  44609. onPadDownObservable: Observable<DualShockDpad>;
  44610. /** Observable raised when a pad is released */
  44611. onPadUpObservable: Observable<DualShockDpad>;
  44612. private _buttonCross;
  44613. private _buttonCircle;
  44614. private _buttonSquare;
  44615. private _buttonTriangle;
  44616. private _buttonShare;
  44617. private _buttonOptions;
  44618. private _buttonL1;
  44619. private _buttonR1;
  44620. private _buttonLeftStick;
  44621. private _buttonRightStick;
  44622. private _dPadUp;
  44623. private _dPadDown;
  44624. private _dPadLeft;
  44625. private _dPadRight;
  44626. /**
  44627. * Creates a new DualShock gamepad object
  44628. * @param id defines the id of this gamepad
  44629. * @param index defines its index
  44630. * @param gamepad defines the internal HTML gamepad object
  44631. */
  44632. constructor(id: string, index: number, gamepad: any);
  44633. /**
  44634. * Defines the callback to call when left trigger is pressed
  44635. * @param callback defines the callback to use
  44636. */
  44637. onlefttriggerchanged(callback: (value: number) => void): void;
  44638. /**
  44639. * Defines the callback to call when right trigger is pressed
  44640. * @param callback defines the callback to use
  44641. */
  44642. onrighttriggerchanged(callback: (value: number) => void): void;
  44643. /**
  44644. * Gets the left trigger value
  44645. */
  44646. get leftTrigger(): number;
  44647. /**
  44648. * Sets the left trigger value
  44649. */
  44650. set leftTrigger(newValue: number);
  44651. /**
  44652. * Gets the right trigger value
  44653. */
  44654. get rightTrigger(): number;
  44655. /**
  44656. * Sets the right trigger value
  44657. */
  44658. set rightTrigger(newValue: number);
  44659. /**
  44660. * Defines the callback to call when a button is pressed
  44661. * @param callback defines the callback to use
  44662. */
  44663. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44664. /**
  44665. * Defines the callback to call when a button is released
  44666. * @param callback defines the callback to use
  44667. */
  44668. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44669. /**
  44670. * Defines the callback to call when a pad is pressed
  44671. * @param callback defines the callback to use
  44672. */
  44673. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44674. /**
  44675. * Defines the callback to call when a pad is released
  44676. * @param callback defines the callback to use
  44677. */
  44678. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44679. private _setButtonValue;
  44680. private _setDPadValue;
  44681. /**
  44682. * Gets the value of the `Cross` button
  44683. */
  44684. get buttonCross(): number;
  44685. /**
  44686. * Sets the value of the `Cross` button
  44687. */
  44688. set buttonCross(value: number);
  44689. /**
  44690. * Gets the value of the `Circle` button
  44691. */
  44692. get buttonCircle(): number;
  44693. /**
  44694. * Sets the value of the `Circle` button
  44695. */
  44696. set buttonCircle(value: number);
  44697. /**
  44698. * Gets the value of the `Square` button
  44699. */
  44700. get buttonSquare(): number;
  44701. /**
  44702. * Sets the value of the `Square` button
  44703. */
  44704. set buttonSquare(value: number);
  44705. /**
  44706. * Gets the value of the `Triangle` button
  44707. */
  44708. get buttonTriangle(): number;
  44709. /**
  44710. * Sets the value of the `Triangle` button
  44711. */
  44712. set buttonTriangle(value: number);
  44713. /**
  44714. * Gets the value of the `Options` button
  44715. */
  44716. get buttonOptions(): number;
  44717. /**
  44718. * Sets the value of the `Options` button
  44719. */
  44720. set buttonOptions(value: number);
  44721. /**
  44722. * Gets the value of the `Share` button
  44723. */
  44724. get buttonShare(): number;
  44725. /**
  44726. * Sets the value of the `Share` button
  44727. */
  44728. set buttonShare(value: number);
  44729. /**
  44730. * Gets the value of the `L1` button
  44731. */
  44732. get buttonL1(): number;
  44733. /**
  44734. * Sets the value of the `L1` button
  44735. */
  44736. set buttonL1(value: number);
  44737. /**
  44738. * Gets the value of the `R1` button
  44739. */
  44740. get buttonR1(): number;
  44741. /**
  44742. * Sets the value of the `R1` button
  44743. */
  44744. set buttonR1(value: number);
  44745. /**
  44746. * Gets the value of the Left joystick
  44747. */
  44748. get buttonLeftStick(): number;
  44749. /**
  44750. * Sets the value of the Left joystick
  44751. */
  44752. set buttonLeftStick(value: number);
  44753. /**
  44754. * Gets the value of the Right joystick
  44755. */
  44756. get buttonRightStick(): number;
  44757. /**
  44758. * Sets the value of the Right joystick
  44759. */
  44760. set buttonRightStick(value: number);
  44761. /**
  44762. * Gets the value of D-pad up
  44763. */
  44764. get dPadUp(): number;
  44765. /**
  44766. * Sets the value of D-pad up
  44767. */
  44768. set dPadUp(value: number);
  44769. /**
  44770. * Gets the value of D-pad down
  44771. */
  44772. get dPadDown(): number;
  44773. /**
  44774. * Sets the value of D-pad down
  44775. */
  44776. set dPadDown(value: number);
  44777. /**
  44778. * Gets the value of D-pad left
  44779. */
  44780. get dPadLeft(): number;
  44781. /**
  44782. * Sets the value of D-pad left
  44783. */
  44784. set dPadLeft(value: number);
  44785. /**
  44786. * Gets the value of D-pad right
  44787. */
  44788. get dPadRight(): number;
  44789. /**
  44790. * Sets the value of D-pad right
  44791. */
  44792. set dPadRight(value: number);
  44793. /**
  44794. * Force the gamepad to synchronize with device values
  44795. */
  44796. update(): void;
  44797. /**
  44798. * Disposes the gamepad
  44799. */
  44800. dispose(): void;
  44801. }
  44802. }
  44803. declare module BABYLON {
  44804. /**
  44805. * Manager for handling gamepads
  44806. */
  44807. export class GamepadManager {
  44808. private _scene?;
  44809. private _babylonGamepads;
  44810. private _oneGamepadConnected;
  44811. /** @hidden */
  44812. _isMonitoring: boolean;
  44813. private _gamepadEventSupported;
  44814. private _gamepadSupport?;
  44815. /**
  44816. * observable to be triggered when the gamepad controller has been connected
  44817. */
  44818. onGamepadConnectedObservable: Observable<Gamepad>;
  44819. /**
  44820. * observable to be triggered when the gamepad controller has been disconnected
  44821. */
  44822. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44823. private _onGamepadConnectedEvent;
  44824. private _onGamepadDisconnectedEvent;
  44825. /**
  44826. * Initializes the gamepad manager
  44827. * @param _scene BabylonJS scene
  44828. */
  44829. constructor(_scene?: Scene | undefined);
  44830. /**
  44831. * The gamepads in the game pad manager
  44832. */
  44833. get gamepads(): Gamepad[];
  44834. /**
  44835. * Get the gamepad controllers based on type
  44836. * @param type The type of gamepad controller
  44837. * @returns Nullable gamepad
  44838. */
  44839. getGamepadByType(type?: number): Nullable<Gamepad>;
  44840. /**
  44841. * Disposes the gamepad manager
  44842. */
  44843. dispose(): void;
  44844. private _addNewGamepad;
  44845. private _startMonitoringGamepads;
  44846. private _stopMonitoringGamepads;
  44847. /** @hidden */
  44848. _checkGamepadsStatus(): void;
  44849. private _updateGamepadObjects;
  44850. }
  44851. }
  44852. declare module BABYLON {
  44853. interface Scene {
  44854. /** @hidden */
  44855. _gamepadManager: Nullable<GamepadManager>;
  44856. /**
  44857. * Gets the gamepad manager associated with the scene
  44858. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44859. */
  44860. gamepadManager: GamepadManager;
  44861. }
  44862. /**
  44863. * Interface representing a free camera inputs manager
  44864. */
  44865. interface FreeCameraInputsManager {
  44866. /**
  44867. * Adds gamepad input support to the FreeCameraInputsManager.
  44868. * @returns the FreeCameraInputsManager
  44869. */
  44870. addGamepad(): FreeCameraInputsManager;
  44871. }
  44872. /**
  44873. * Interface representing an arc rotate camera inputs manager
  44874. */
  44875. interface ArcRotateCameraInputsManager {
  44876. /**
  44877. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44878. * @returns the camera inputs manager
  44879. */
  44880. addGamepad(): ArcRotateCameraInputsManager;
  44881. }
  44882. /**
  44883. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44884. */
  44885. export class GamepadSystemSceneComponent implements ISceneComponent {
  44886. /**
  44887. * The component name helpfull to identify the component in the list of scene components.
  44888. */
  44889. readonly name: string;
  44890. /**
  44891. * The scene the component belongs to.
  44892. */
  44893. scene: Scene;
  44894. /**
  44895. * Creates a new instance of the component for the given scene
  44896. * @param scene Defines the scene to register the component in
  44897. */
  44898. constructor(scene: Scene);
  44899. /**
  44900. * Registers the component in a given scene
  44901. */
  44902. register(): void;
  44903. /**
  44904. * Rebuilds the elements related to this component in case of
  44905. * context lost for instance.
  44906. */
  44907. rebuild(): void;
  44908. /**
  44909. * Disposes the component and the associated ressources
  44910. */
  44911. dispose(): void;
  44912. private _beforeCameraUpdate;
  44913. }
  44914. }
  44915. declare module BABYLON {
  44916. /**
  44917. * 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,
  44918. * which still works and will still be found in many Playgrounds.
  44919. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44920. */
  44921. export class UniversalCamera extends TouchCamera {
  44922. /**
  44923. * Defines the gamepad rotation sensiblity.
  44924. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44925. */
  44926. get gamepadAngularSensibility(): number;
  44927. set gamepadAngularSensibility(value: number);
  44928. /**
  44929. * Defines the gamepad move sensiblity.
  44930. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44931. */
  44932. get gamepadMoveSensibility(): number;
  44933. set gamepadMoveSensibility(value: number);
  44934. /**
  44935. * 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,
  44936. * which still works and will still be found in many Playgrounds.
  44937. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44938. * @param name Define the name of the camera in the scene
  44939. * @param position Define the start position of the camera in the scene
  44940. * @param scene Define the scene the camera belongs to
  44941. */
  44942. constructor(name: string, position: Vector3, scene: Scene);
  44943. /**
  44944. * Gets the current object class name.
  44945. * @return the class name
  44946. */
  44947. getClassName(): string;
  44948. }
  44949. }
  44950. declare module BABYLON {
  44951. /**
  44952. * This represents a FPS type of camera. This is only here for back compat purpose.
  44953. * Please use the UniversalCamera instead as both are identical.
  44954. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44955. */
  44956. export class GamepadCamera extends UniversalCamera {
  44957. /**
  44958. * Instantiates a new Gamepad Camera
  44959. * This represents a FPS type of camera. This is only here for back compat purpose.
  44960. * Please use the UniversalCamera instead as both are identical.
  44961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44962. * @param name Define the name of the camera in the scene
  44963. * @param position Define the start position of the camera in the scene
  44964. * @param scene Define the scene the camera belongs to
  44965. */
  44966. constructor(name: string, position: Vector3, scene: Scene);
  44967. /**
  44968. * Gets the current object class name.
  44969. * @return the class name
  44970. */
  44971. getClassName(): string;
  44972. }
  44973. }
  44974. declare module BABYLON {
  44975. /** @hidden */
  44976. export var passPixelShader: {
  44977. name: string;
  44978. shader: string;
  44979. };
  44980. }
  44981. declare module BABYLON {
  44982. /** @hidden */
  44983. export var passCubePixelShader: {
  44984. name: string;
  44985. shader: string;
  44986. };
  44987. }
  44988. declare module BABYLON {
  44989. /**
  44990. * PassPostProcess which produces an output the same as it's input
  44991. */
  44992. export class PassPostProcess extends PostProcess {
  44993. /**
  44994. * Creates the PassPostProcess
  44995. * @param name The name of the effect.
  44996. * @param options The required width/height ratio to downsize to before computing the render pass.
  44997. * @param camera The camera to apply the render pass to.
  44998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44999. * @param engine The engine which the post process will be applied. (default: current engine)
  45000. * @param reusable If the post process can be reused on the same frame. (default: false)
  45001. * @param textureType The type of texture to be used when performing the post processing.
  45002. * @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)
  45003. */
  45004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45005. }
  45006. /**
  45007. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45008. */
  45009. export class PassCubePostProcess extends PostProcess {
  45010. private _face;
  45011. /**
  45012. * Gets or sets the cube face to display.
  45013. * * 0 is +X
  45014. * * 1 is -X
  45015. * * 2 is +Y
  45016. * * 3 is -Y
  45017. * * 4 is +Z
  45018. * * 5 is -Z
  45019. */
  45020. get face(): number;
  45021. set face(value: number);
  45022. /**
  45023. * Creates the PassCubePostProcess
  45024. * @param name The name of the effect.
  45025. * @param options The required width/height ratio to downsize to before computing the render pass.
  45026. * @param camera The camera to apply the render pass to.
  45027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45028. * @param engine The engine which the post process will be applied. (default: current engine)
  45029. * @param reusable If the post process can be reused on the same frame. (default: false)
  45030. * @param textureType The type of texture to be used when performing the post processing.
  45031. * @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)
  45032. */
  45033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45034. }
  45035. }
  45036. declare module BABYLON {
  45037. /** @hidden */
  45038. export var anaglyphPixelShader: {
  45039. name: string;
  45040. shader: string;
  45041. };
  45042. }
  45043. declare module BABYLON {
  45044. /**
  45045. * Postprocess used to generate anaglyphic rendering
  45046. */
  45047. export class AnaglyphPostProcess extends PostProcess {
  45048. private _passedProcess;
  45049. /**
  45050. * Creates a new AnaglyphPostProcess
  45051. * @param name defines postprocess name
  45052. * @param options defines creation options or target ratio scale
  45053. * @param rigCameras defines cameras using this postprocess
  45054. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45055. * @param engine defines hosting engine
  45056. * @param reusable defines if the postprocess will be reused multiple times per frame
  45057. */
  45058. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45059. }
  45060. }
  45061. declare module BABYLON {
  45062. /**
  45063. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45064. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45065. */
  45066. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45067. /**
  45068. * Creates a new AnaglyphArcRotateCamera
  45069. * @param name defines camera name
  45070. * @param alpha defines alpha angle (in radians)
  45071. * @param beta defines beta angle (in radians)
  45072. * @param radius defines radius
  45073. * @param target defines camera target
  45074. * @param interaxialDistance defines distance between each color axis
  45075. * @param scene defines the hosting scene
  45076. */
  45077. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45078. /**
  45079. * Gets camera class name
  45080. * @returns AnaglyphArcRotateCamera
  45081. */
  45082. getClassName(): string;
  45083. }
  45084. }
  45085. declare module BABYLON {
  45086. /**
  45087. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45088. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45089. */
  45090. export class AnaglyphFreeCamera extends FreeCamera {
  45091. /**
  45092. * Creates a new AnaglyphFreeCamera
  45093. * @param name defines camera name
  45094. * @param position defines initial position
  45095. * @param interaxialDistance defines distance between each color axis
  45096. * @param scene defines the hosting scene
  45097. */
  45098. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45099. /**
  45100. * Gets camera class name
  45101. * @returns AnaglyphFreeCamera
  45102. */
  45103. getClassName(): string;
  45104. }
  45105. }
  45106. declare module BABYLON {
  45107. /**
  45108. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45109. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45110. */
  45111. export class AnaglyphGamepadCamera extends GamepadCamera {
  45112. /**
  45113. * Creates a new AnaglyphGamepadCamera
  45114. * @param name defines camera name
  45115. * @param position defines initial position
  45116. * @param interaxialDistance defines distance between each color axis
  45117. * @param scene defines the hosting scene
  45118. */
  45119. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45120. /**
  45121. * Gets camera class name
  45122. * @returns AnaglyphGamepadCamera
  45123. */
  45124. getClassName(): string;
  45125. }
  45126. }
  45127. declare module BABYLON {
  45128. /**
  45129. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45130. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45131. */
  45132. export class AnaglyphUniversalCamera extends UniversalCamera {
  45133. /**
  45134. * Creates a new AnaglyphUniversalCamera
  45135. * @param name defines camera name
  45136. * @param position defines initial position
  45137. * @param interaxialDistance defines distance between each color axis
  45138. * @param scene defines the hosting scene
  45139. */
  45140. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45141. /**
  45142. * Gets camera class name
  45143. * @returns AnaglyphUniversalCamera
  45144. */
  45145. getClassName(): string;
  45146. }
  45147. }
  45148. declare module BABYLON {
  45149. /**
  45150. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45151. * @see http://doc.babylonjs.com/features/cameras
  45152. */
  45153. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45154. /**
  45155. * Creates a new StereoscopicArcRotateCamera
  45156. * @param name defines camera name
  45157. * @param alpha defines alpha angle (in radians)
  45158. * @param beta defines beta angle (in radians)
  45159. * @param radius defines radius
  45160. * @param target defines camera target
  45161. * @param interaxialDistance defines distance between each color axis
  45162. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45163. * @param scene defines the hosting scene
  45164. */
  45165. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45166. /**
  45167. * Gets camera class name
  45168. * @returns StereoscopicArcRotateCamera
  45169. */
  45170. getClassName(): string;
  45171. }
  45172. }
  45173. declare module BABYLON {
  45174. /**
  45175. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45176. * @see http://doc.babylonjs.com/features/cameras
  45177. */
  45178. export class StereoscopicFreeCamera extends FreeCamera {
  45179. /**
  45180. * Creates a new StereoscopicFreeCamera
  45181. * @param name defines camera name
  45182. * @param position defines initial position
  45183. * @param interaxialDistance defines distance between each color axis
  45184. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45185. * @param scene defines the hosting scene
  45186. */
  45187. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45188. /**
  45189. * Gets camera class name
  45190. * @returns StereoscopicFreeCamera
  45191. */
  45192. getClassName(): string;
  45193. }
  45194. }
  45195. declare module BABYLON {
  45196. /**
  45197. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45198. * @see http://doc.babylonjs.com/features/cameras
  45199. */
  45200. export class StereoscopicGamepadCamera extends GamepadCamera {
  45201. /**
  45202. * Creates a new StereoscopicGamepadCamera
  45203. * @param name defines camera name
  45204. * @param position defines initial position
  45205. * @param interaxialDistance defines distance between each color axis
  45206. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45207. * @param scene defines the hosting scene
  45208. */
  45209. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45210. /**
  45211. * Gets camera class name
  45212. * @returns StereoscopicGamepadCamera
  45213. */
  45214. getClassName(): string;
  45215. }
  45216. }
  45217. declare module BABYLON {
  45218. /**
  45219. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45220. * @see http://doc.babylonjs.com/features/cameras
  45221. */
  45222. export class StereoscopicUniversalCamera extends UniversalCamera {
  45223. /**
  45224. * Creates a new StereoscopicUniversalCamera
  45225. * @param name defines camera name
  45226. * @param position defines initial position
  45227. * @param interaxialDistance defines distance between each color axis
  45228. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45229. * @param scene defines the hosting scene
  45230. */
  45231. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45232. /**
  45233. * Gets camera class name
  45234. * @returns StereoscopicUniversalCamera
  45235. */
  45236. getClassName(): string;
  45237. }
  45238. }
  45239. declare module BABYLON {
  45240. /**
  45241. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45242. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45243. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45244. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45245. */
  45246. export class VirtualJoysticksCamera extends FreeCamera {
  45247. /**
  45248. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45249. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45250. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45251. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45252. * @param name Define the name of the camera in the scene
  45253. * @param position Define the start position of the camera in the scene
  45254. * @param scene Define the scene the camera belongs to
  45255. */
  45256. constructor(name: string, position: Vector3, scene: Scene);
  45257. /**
  45258. * Gets the current object class name.
  45259. * @return the class name
  45260. */
  45261. getClassName(): string;
  45262. }
  45263. }
  45264. declare module BABYLON {
  45265. /**
  45266. * This represents all the required metrics to create a VR camera.
  45267. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45268. */
  45269. export class VRCameraMetrics {
  45270. /**
  45271. * Define the horizontal resolution off the screen.
  45272. */
  45273. hResolution: number;
  45274. /**
  45275. * Define the vertical resolution off the screen.
  45276. */
  45277. vResolution: number;
  45278. /**
  45279. * Define the horizontal screen size.
  45280. */
  45281. hScreenSize: number;
  45282. /**
  45283. * Define the vertical screen size.
  45284. */
  45285. vScreenSize: number;
  45286. /**
  45287. * Define the vertical screen center position.
  45288. */
  45289. vScreenCenter: number;
  45290. /**
  45291. * Define the distance of the eyes to the screen.
  45292. */
  45293. eyeToScreenDistance: number;
  45294. /**
  45295. * Define the distance between both lenses
  45296. */
  45297. lensSeparationDistance: number;
  45298. /**
  45299. * Define the distance between both viewer's eyes.
  45300. */
  45301. interpupillaryDistance: number;
  45302. /**
  45303. * Define the distortion factor of the VR postprocess.
  45304. * Please, touch with care.
  45305. */
  45306. distortionK: number[];
  45307. /**
  45308. * Define the chromatic aberration correction factors for the VR post process.
  45309. */
  45310. chromaAbCorrection: number[];
  45311. /**
  45312. * Define the scale factor of the post process.
  45313. * The smaller the better but the slower.
  45314. */
  45315. postProcessScaleFactor: number;
  45316. /**
  45317. * Define an offset for the lens center.
  45318. */
  45319. lensCenterOffset: number;
  45320. /**
  45321. * Define if the current vr camera should compensate the distortion of the lense or not.
  45322. */
  45323. compensateDistortion: boolean;
  45324. /**
  45325. * Defines if multiview should be enabled when rendering (Default: false)
  45326. */
  45327. multiviewEnabled: boolean;
  45328. /**
  45329. * Gets the rendering aspect ratio based on the provided resolutions.
  45330. */
  45331. get aspectRatio(): number;
  45332. /**
  45333. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45334. */
  45335. get aspectRatioFov(): number;
  45336. /**
  45337. * @hidden
  45338. */
  45339. get leftHMatrix(): Matrix;
  45340. /**
  45341. * @hidden
  45342. */
  45343. get rightHMatrix(): Matrix;
  45344. /**
  45345. * @hidden
  45346. */
  45347. get leftPreViewMatrix(): Matrix;
  45348. /**
  45349. * @hidden
  45350. */
  45351. get rightPreViewMatrix(): Matrix;
  45352. /**
  45353. * Get the default VRMetrics based on the most generic setup.
  45354. * @returns the default vr metrics
  45355. */
  45356. static GetDefault(): VRCameraMetrics;
  45357. }
  45358. }
  45359. declare module BABYLON {
  45360. /** @hidden */
  45361. export var vrDistortionCorrectionPixelShader: {
  45362. name: string;
  45363. shader: string;
  45364. };
  45365. }
  45366. declare module BABYLON {
  45367. /**
  45368. * VRDistortionCorrectionPostProcess used for mobile VR
  45369. */
  45370. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45371. private _isRightEye;
  45372. private _distortionFactors;
  45373. private _postProcessScaleFactor;
  45374. private _lensCenterOffset;
  45375. private _scaleIn;
  45376. private _scaleFactor;
  45377. private _lensCenter;
  45378. /**
  45379. * Initializes the VRDistortionCorrectionPostProcess
  45380. * @param name The name of the effect.
  45381. * @param camera The camera to apply the render pass to.
  45382. * @param isRightEye If this is for the right eye distortion
  45383. * @param vrMetrics All the required metrics for the VR camera
  45384. */
  45385. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45386. }
  45387. }
  45388. declare module BABYLON {
  45389. /**
  45390. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45391. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45392. */
  45393. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45394. /**
  45395. * Creates a new VRDeviceOrientationArcRotateCamera
  45396. * @param name defines camera name
  45397. * @param alpha defines the camera rotation along the logitudinal axis
  45398. * @param beta defines the camera rotation along the latitudinal axis
  45399. * @param radius defines the camera distance from its target
  45400. * @param target defines the camera target
  45401. * @param scene defines the scene the camera belongs to
  45402. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45403. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45404. */
  45405. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45406. /**
  45407. * Gets camera class name
  45408. * @returns VRDeviceOrientationArcRotateCamera
  45409. */
  45410. getClassName(): string;
  45411. }
  45412. }
  45413. declare module BABYLON {
  45414. /**
  45415. * Camera used to simulate VR rendering (based on FreeCamera)
  45416. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45417. */
  45418. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45419. /**
  45420. * Creates a new VRDeviceOrientationFreeCamera
  45421. * @param name defines camera name
  45422. * @param position defines the start position of the camera
  45423. * @param scene defines the scene the camera belongs to
  45424. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45425. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45426. */
  45427. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45428. /**
  45429. * Gets camera class name
  45430. * @returns VRDeviceOrientationFreeCamera
  45431. */
  45432. getClassName(): string;
  45433. }
  45434. }
  45435. declare module BABYLON {
  45436. /**
  45437. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45438. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45439. */
  45440. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45441. /**
  45442. * Creates a new VRDeviceOrientationGamepadCamera
  45443. * @param name defines camera name
  45444. * @param position defines the start position of the camera
  45445. * @param scene defines the scene the camera belongs to
  45446. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45447. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45448. */
  45449. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45450. /**
  45451. * Gets camera class name
  45452. * @returns VRDeviceOrientationGamepadCamera
  45453. */
  45454. getClassName(): string;
  45455. }
  45456. }
  45457. declare module BABYLON {
  45458. /** @hidden */
  45459. export var imageProcessingPixelShader: {
  45460. name: string;
  45461. shader: string;
  45462. };
  45463. }
  45464. declare module BABYLON {
  45465. /**
  45466. * ImageProcessingPostProcess
  45467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45468. */
  45469. export class ImageProcessingPostProcess extends PostProcess {
  45470. /**
  45471. * Default configuration related to image processing available in the PBR Material.
  45472. */
  45473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45474. /**
  45475. * Gets the image processing configuration used either in this material.
  45476. */
  45477. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45478. /**
  45479. * Sets the Default image processing configuration used either in the this material.
  45480. *
  45481. * If sets to null, the scene one is in use.
  45482. */
  45483. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45484. /**
  45485. * Keep track of the image processing observer to allow dispose and replace.
  45486. */
  45487. private _imageProcessingObserver;
  45488. /**
  45489. * Attaches a new image processing configuration to the PBR Material.
  45490. * @param configuration
  45491. */
  45492. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45493. /**
  45494. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45495. */
  45496. get colorCurves(): Nullable<ColorCurves>;
  45497. /**
  45498. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45499. */
  45500. set colorCurves(value: Nullable<ColorCurves>);
  45501. /**
  45502. * Gets wether the color curves effect is enabled.
  45503. */
  45504. get colorCurvesEnabled(): boolean;
  45505. /**
  45506. * Sets wether the color curves effect is enabled.
  45507. */
  45508. set colorCurvesEnabled(value: boolean);
  45509. /**
  45510. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45511. */
  45512. get colorGradingTexture(): Nullable<BaseTexture>;
  45513. /**
  45514. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45515. */
  45516. set colorGradingTexture(value: Nullable<BaseTexture>);
  45517. /**
  45518. * Gets wether the color grading effect is enabled.
  45519. */
  45520. get colorGradingEnabled(): boolean;
  45521. /**
  45522. * Gets wether the color grading effect is enabled.
  45523. */
  45524. set colorGradingEnabled(value: boolean);
  45525. /**
  45526. * Gets exposure used in the effect.
  45527. */
  45528. get exposure(): number;
  45529. /**
  45530. * Sets exposure used in the effect.
  45531. */
  45532. set exposure(value: number);
  45533. /**
  45534. * Gets wether tonemapping is enabled or not.
  45535. */
  45536. get toneMappingEnabled(): boolean;
  45537. /**
  45538. * Sets wether tonemapping is enabled or not
  45539. */
  45540. set toneMappingEnabled(value: boolean);
  45541. /**
  45542. * Gets the type of tone mapping effect.
  45543. */
  45544. get toneMappingType(): number;
  45545. /**
  45546. * Sets the type of tone mapping effect.
  45547. */
  45548. set toneMappingType(value: number);
  45549. /**
  45550. * Gets contrast used in the effect.
  45551. */
  45552. get contrast(): number;
  45553. /**
  45554. * Sets contrast used in the effect.
  45555. */
  45556. set contrast(value: number);
  45557. /**
  45558. * Gets Vignette stretch size.
  45559. */
  45560. get vignetteStretch(): number;
  45561. /**
  45562. * Sets Vignette stretch size.
  45563. */
  45564. set vignetteStretch(value: number);
  45565. /**
  45566. * Gets Vignette centre X Offset.
  45567. */
  45568. get vignetteCentreX(): number;
  45569. /**
  45570. * Sets Vignette centre X Offset.
  45571. */
  45572. set vignetteCentreX(value: number);
  45573. /**
  45574. * Gets Vignette centre Y Offset.
  45575. */
  45576. get vignetteCentreY(): number;
  45577. /**
  45578. * Sets Vignette centre Y Offset.
  45579. */
  45580. set vignetteCentreY(value: number);
  45581. /**
  45582. * Gets Vignette weight or intensity of the vignette effect.
  45583. */
  45584. get vignetteWeight(): number;
  45585. /**
  45586. * Sets Vignette weight or intensity of the vignette effect.
  45587. */
  45588. set vignetteWeight(value: number);
  45589. /**
  45590. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45591. * if vignetteEnabled is set to true.
  45592. */
  45593. get vignetteColor(): Color4;
  45594. /**
  45595. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45596. * if vignetteEnabled is set to true.
  45597. */
  45598. set vignetteColor(value: Color4);
  45599. /**
  45600. * Gets Camera field of view used by the Vignette effect.
  45601. */
  45602. get vignetteCameraFov(): number;
  45603. /**
  45604. * Sets Camera field of view used by the Vignette effect.
  45605. */
  45606. set vignetteCameraFov(value: number);
  45607. /**
  45608. * Gets the vignette blend mode allowing different kind of effect.
  45609. */
  45610. get vignetteBlendMode(): number;
  45611. /**
  45612. * Sets the vignette blend mode allowing different kind of effect.
  45613. */
  45614. set vignetteBlendMode(value: number);
  45615. /**
  45616. * Gets wether the vignette effect is enabled.
  45617. */
  45618. get vignetteEnabled(): boolean;
  45619. /**
  45620. * Sets wether the vignette effect is enabled.
  45621. */
  45622. set vignetteEnabled(value: boolean);
  45623. private _fromLinearSpace;
  45624. /**
  45625. * Gets wether the input of the processing is in Gamma or Linear Space.
  45626. */
  45627. get fromLinearSpace(): boolean;
  45628. /**
  45629. * Sets wether the input of the processing is in Gamma or Linear Space.
  45630. */
  45631. set fromLinearSpace(value: boolean);
  45632. /**
  45633. * Defines cache preventing GC.
  45634. */
  45635. private _defines;
  45636. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45637. /**
  45638. * "ImageProcessingPostProcess"
  45639. * @returns "ImageProcessingPostProcess"
  45640. */
  45641. getClassName(): string;
  45642. protected _updateParameters(): void;
  45643. dispose(camera?: Camera): void;
  45644. }
  45645. }
  45646. declare module BABYLON {
  45647. /**
  45648. * Class containing static functions to help procedurally build meshes
  45649. */
  45650. export class GroundBuilder {
  45651. /**
  45652. * Creates a ground mesh
  45653. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45654. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45656. * @param name defines the name of the mesh
  45657. * @param options defines the options used to create the mesh
  45658. * @param scene defines the hosting scene
  45659. * @returns the ground mesh
  45660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45661. */
  45662. static CreateGround(name: string, options: {
  45663. width?: number;
  45664. height?: number;
  45665. subdivisions?: number;
  45666. subdivisionsX?: number;
  45667. subdivisionsY?: number;
  45668. updatable?: boolean;
  45669. }, scene: any): Mesh;
  45670. /**
  45671. * Creates a tiled ground mesh
  45672. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45673. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45674. * * 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
  45675. * * 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
  45676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45677. * @param name defines the name of the mesh
  45678. * @param options defines the options used to create the mesh
  45679. * @param scene defines the hosting scene
  45680. * @returns the tiled ground mesh
  45681. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45682. */
  45683. static CreateTiledGround(name: string, options: {
  45684. xmin: number;
  45685. zmin: number;
  45686. xmax: number;
  45687. zmax: number;
  45688. subdivisions?: {
  45689. w: number;
  45690. h: number;
  45691. };
  45692. precision?: {
  45693. w: number;
  45694. h: number;
  45695. };
  45696. updatable?: boolean;
  45697. }, scene?: Nullable<Scene>): Mesh;
  45698. /**
  45699. * Creates a ground mesh from a height map
  45700. * * The parameter `url` sets the URL of the height map image resource.
  45701. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45702. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45703. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45704. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45705. * * 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.
  45706. * * 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).
  45707. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45709. * @param name defines the name of the mesh
  45710. * @param url defines the url to the height map
  45711. * @param options defines the options used to create the mesh
  45712. * @param scene defines the hosting scene
  45713. * @returns the ground mesh
  45714. * @see https://doc.babylonjs.com/babylon101/height_map
  45715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45716. */
  45717. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45718. width?: number;
  45719. height?: number;
  45720. subdivisions?: number;
  45721. minHeight?: number;
  45722. maxHeight?: number;
  45723. colorFilter?: Color3;
  45724. alphaFilter?: number;
  45725. updatable?: boolean;
  45726. onReady?: (mesh: GroundMesh) => void;
  45727. }, scene?: Nullable<Scene>): GroundMesh;
  45728. }
  45729. }
  45730. declare module BABYLON {
  45731. /**
  45732. * Class containing static functions to help procedurally build meshes
  45733. */
  45734. export class TorusBuilder {
  45735. /**
  45736. * Creates a torus mesh
  45737. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45738. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45739. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45741. * * 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
  45742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45743. * @param name defines the name of the mesh
  45744. * @param options defines the options used to create the mesh
  45745. * @param scene defines the hosting scene
  45746. * @returns the torus mesh
  45747. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45748. */
  45749. static CreateTorus(name: string, options: {
  45750. diameter?: number;
  45751. thickness?: number;
  45752. tessellation?: number;
  45753. updatable?: boolean;
  45754. sideOrientation?: number;
  45755. frontUVs?: Vector4;
  45756. backUVs?: Vector4;
  45757. }, scene: any): Mesh;
  45758. }
  45759. }
  45760. declare module BABYLON {
  45761. /**
  45762. * Class containing static functions to help procedurally build meshes
  45763. */
  45764. export class CylinderBuilder {
  45765. /**
  45766. * Creates a cylinder or a cone mesh
  45767. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45768. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45769. * * 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.
  45770. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45771. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45772. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45773. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45774. * * 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).
  45775. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45776. * * 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).
  45777. * * 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
  45778. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45779. * * 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
  45780. * * 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.
  45781. * * If `enclose` is false, a ring surface is one element.
  45782. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45783. * * 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
  45784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45785. * * 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
  45786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45787. * @param name defines the name of the mesh
  45788. * @param options defines the options used to create the mesh
  45789. * @param scene defines the hosting scene
  45790. * @returns the cylinder mesh
  45791. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45792. */
  45793. static CreateCylinder(name: string, options: {
  45794. height?: number;
  45795. diameterTop?: number;
  45796. diameterBottom?: number;
  45797. diameter?: number;
  45798. tessellation?: number;
  45799. subdivisions?: number;
  45800. arc?: number;
  45801. faceColors?: Color4[];
  45802. faceUV?: Vector4[];
  45803. updatable?: boolean;
  45804. hasRings?: boolean;
  45805. enclose?: boolean;
  45806. cap?: number;
  45807. sideOrientation?: number;
  45808. frontUVs?: Vector4;
  45809. backUVs?: Vector4;
  45810. }, scene: any): Mesh;
  45811. }
  45812. }
  45813. declare module BABYLON {
  45814. /**
  45815. * States of the webXR experience
  45816. */
  45817. export enum WebXRState {
  45818. /**
  45819. * Transitioning to being in XR mode
  45820. */
  45821. ENTERING_XR = 0,
  45822. /**
  45823. * Transitioning to non XR mode
  45824. */
  45825. EXITING_XR = 1,
  45826. /**
  45827. * In XR mode and presenting
  45828. */
  45829. IN_XR = 2,
  45830. /**
  45831. * Not entered XR mode
  45832. */
  45833. NOT_IN_XR = 3
  45834. }
  45835. /**
  45836. * Abstraction of the XR render target
  45837. */
  45838. export interface WebXRRenderTarget extends IDisposable {
  45839. /**
  45840. * xrpresent context of the canvas which can be used to display/mirror xr content
  45841. */
  45842. canvasContext: WebGLRenderingContext;
  45843. /**
  45844. * xr layer for the canvas
  45845. */
  45846. xrLayer: Nullable<XRWebGLLayer>;
  45847. /**
  45848. * Initializes the xr layer for the session
  45849. * @param xrSession xr session
  45850. * @returns a promise that will resolve once the XR Layer has been created
  45851. */
  45852. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45853. }
  45854. }
  45855. declare module BABYLON {
  45856. /**
  45857. * COnfiguration object for WebXR output canvas
  45858. */
  45859. export class WebXRManagedOutputCanvasOptions {
  45860. /**
  45861. * An optional canvas in case you wish to create it yourself and provide it here.
  45862. * If not provided, a new canvas will be created
  45863. */
  45864. canvasElement?: HTMLCanvasElement;
  45865. /**
  45866. * Options for this XR Layer output
  45867. */
  45868. canvasOptions?: XRWebGLLayerOptions;
  45869. /**
  45870. * CSS styling for a newly created canvas (if not provided)
  45871. */
  45872. newCanvasCssStyle?: string;
  45873. /**
  45874. * Get the default values of the configuration object
  45875. * @returns default values of this configuration object
  45876. */
  45877. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45878. }
  45879. /**
  45880. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45881. */
  45882. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45883. private _options;
  45884. private _canvas;
  45885. private _engine;
  45886. /**
  45887. * Rendering context of the canvas which can be used to display/mirror xr content
  45888. */
  45889. canvasContext: WebGLRenderingContext;
  45890. /**
  45891. * xr layer for the canvas
  45892. */
  45893. xrLayer: Nullable<XRWebGLLayer>;
  45894. /**
  45895. * Initializes the canvas to be added/removed upon entering/exiting xr
  45896. * @param _xrSessionManager The XR Session manager
  45897. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45898. */
  45899. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45900. /**
  45901. * Disposes of the object
  45902. */
  45903. dispose(): void;
  45904. /**
  45905. * Initializes the xr layer for the session
  45906. * @param xrSession xr session
  45907. * @returns a promise that will resolve once the XR Layer has been created
  45908. */
  45909. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45910. private _addCanvas;
  45911. private _removeCanvas;
  45912. private _setManagedOutputCanvas;
  45913. }
  45914. }
  45915. declare module BABYLON {
  45916. /**
  45917. * Manages an XRSession to work with Babylon's engine
  45918. * @see https://doc.babylonjs.com/how_to/webxr
  45919. */
  45920. export class WebXRSessionManager implements IDisposable {
  45921. /** The scene which the session should be created for */
  45922. scene: Scene;
  45923. private _referenceSpace;
  45924. private _rttProvider;
  45925. private _sessionEnded;
  45926. private _xrNavigator;
  45927. private baseLayer;
  45928. /**
  45929. * The base reference space from which the session started. good if you want to reset your
  45930. * reference space
  45931. */
  45932. baseReferenceSpace: XRReferenceSpace;
  45933. /**
  45934. * Current XR frame
  45935. */
  45936. currentFrame: Nullable<XRFrame>;
  45937. /** WebXR timestamp updated every frame */
  45938. currentTimestamp: number;
  45939. /**
  45940. * Used just in case of a failure to initialize an immersive session.
  45941. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45942. */
  45943. defaultHeightCompensation: number;
  45944. /**
  45945. * Fires every time a new xrFrame arrives which can be used to update the camera
  45946. */
  45947. onXRFrameObservable: Observable<XRFrame>;
  45948. /**
  45949. * Fires when the reference space changed
  45950. */
  45951. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45952. /**
  45953. * Fires when the xr session is ended either by the device or manually done
  45954. */
  45955. onXRSessionEnded: Observable<any>;
  45956. /**
  45957. * Fires when the xr session is ended either by the device or manually done
  45958. */
  45959. onXRSessionInit: Observable<XRSession>;
  45960. /**
  45961. * Underlying xr session
  45962. */
  45963. session: XRSession;
  45964. /**
  45965. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45966. * or get the offset the player is currently at.
  45967. */
  45968. viewerReferenceSpace: XRReferenceSpace;
  45969. /**
  45970. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45971. * @param scene The scene which the session should be created for
  45972. */
  45973. constructor(
  45974. /** The scene which the session should be created for */
  45975. scene: Scene);
  45976. /**
  45977. * The current reference space used in this session. This reference space can constantly change!
  45978. * It is mainly used to offset the camera's position.
  45979. */
  45980. get referenceSpace(): XRReferenceSpace;
  45981. /**
  45982. * Set a new reference space and triggers the observable
  45983. */
  45984. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45985. /**
  45986. * Disposes of the session manager
  45987. */
  45988. dispose(): void;
  45989. /**
  45990. * Stops the xrSession and restores the render loop
  45991. * @returns Promise which resolves after it exits XR
  45992. */
  45993. exitXRAsync(): Promise<void>;
  45994. /**
  45995. * Gets the correct render target texture to be rendered this frame for this eye
  45996. * @param eye the eye for which to get the render target
  45997. * @returns the render target for the specified eye
  45998. */
  45999. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46000. /**
  46001. * Creates a WebXRRenderTarget object for the XR session
  46002. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46003. * @param options optional options to provide when creating a new render target
  46004. * @returns a WebXR render target to which the session can render
  46005. */
  46006. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46007. /**
  46008. * Initializes the manager
  46009. * After initialization enterXR can be called to start an XR session
  46010. * @returns Promise which resolves after it is initialized
  46011. */
  46012. initializeAsync(): Promise<void>;
  46013. /**
  46014. * Initializes an xr session
  46015. * @param xrSessionMode mode to initialize
  46016. * @param xrSessionInit defines optional and required values to pass to the session builder
  46017. * @returns a promise which will resolve once the session has been initialized
  46018. */
  46019. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46020. /**
  46021. * Checks if a session would be supported for the creation options specified
  46022. * @param sessionMode session mode to check if supported eg. immersive-vr
  46023. * @returns A Promise that resolves to true if supported and false if not
  46024. */
  46025. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46026. /**
  46027. * Resets the reference space to the one started the session
  46028. */
  46029. resetReferenceSpace(): void;
  46030. /**
  46031. * Starts rendering to the xr layer
  46032. */
  46033. runXRRenderLoop(): void;
  46034. /**
  46035. * Sets the reference space on the xr session
  46036. * @param referenceSpaceType space to set
  46037. * @returns a promise that will resolve once the reference space has been set
  46038. */
  46039. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46040. /**
  46041. * Updates the render state of the session
  46042. * @param state state to set
  46043. * @returns a promise that resolves once the render state has been updated
  46044. */
  46045. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46046. /**
  46047. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46048. * @param sessionMode defines the session to test
  46049. * @returns a promise with boolean as final value
  46050. */
  46051. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46052. private _createRenderTargetTexture;
  46053. }
  46054. }
  46055. declare module BABYLON {
  46056. /**
  46057. * WebXR Camera which holds the views for the xrSession
  46058. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46059. */
  46060. export class WebXRCamera extends FreeCamera {
  46061. private _xrSessionManager;
  46062. private _firstFrame;
  46063. private _referenceQuaternion;
  46064. private _referencedPosition;
  46065. private _xrInvPositionCache;
  46066. private _xrInvQuaternionCache;
  46067. /**
  46068. * Should position compensation execute on first frame.
  46069. * This is used when copying the position from a native (non XR) camera
  46070. */
  46071. compensateOnFirstFrame: boolean;
  46072. /**
  46073. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46074. * @param name the name of the camera
  46075. * @param scene the scene to add the camera to
  46076. * @param _xrSessionManager a constructed xr session manager
  46077. */
  46078. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46079. /**
  46080. * Return the user's height, unrelated to the current ground.
  46081. * This will be the y position of this camera, when ground level is 0.
  46082. */
  46083. get realWorldHeight(): number;
  46084. /** @hidden */
  46085. _updateForDualEyeDebugging(): void;
  46086. /**
  46087. * Sets this camera's transformation based on a non-vr camera
  46088. * @param otherCamera the non-vr camera to copy the transformation from
  46089. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46090. */
  46091. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46092. /**
  46093. * Gets the current instance class name ("WebXRCamera").
  46094. * @returns the class name
  46095. */
  46096. getClassName(): string;
  46097. /**
  46098. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46099. */
  46100. _getViewMatrix(): Matrix;
  46101. private _updateFromXRSession;
  46102. private _updateNumberOfRigCameras;
  46103. private _updateReferenceSpace;
  46104. private _updateReferenceSpaceOffset;
  46105. }
  46106. }
  46107. declare module BABYLON {
  46108. /**
  46109. * Defining the interface required for a (webxr) feature
  46110. */
  46111. export interface IWebXRFeature extends IDisposable {
  46112. /**
  46113. * Is this feature attached
  46114. */
  46115. attached: boolean;
  46116. /**
  46117. * Should auto-attach be disabled?
  46118. */
  46119. disableAutoAttach: boolean;
  46120. /**
  46121. * Attach the feature to the session
  46122. * Will usually be called by the features manager
  46123. *
  46124. * @param force should attachment be forced (even when already attached)
  46125. * @returns true if successful.
  46126. */
  46127. attach(force?: boolean): boolean;
  46128. /**
  46129. * Detach the feature from the session
  46130. * Will usually be called by the features manager
  46131. *
  46132. * @returns true if successful.
  46133. */
  46134. detach(): boolean;
  46135. }
  46136. /**
  46137. * A list of the currently available features without referencing them
  46138. */
  46139. export class WebXRFeatureName {
  46140. /**
  46141. * The name of the anchor system feature
  46142. */
  46143. static ANCHOR_SYSTEM: string;
  46144. /**
  46145. * The name of the background remover feature
  46146. */
  46147. static BACKGROUND_REMOVER: string;
  46148. /**
  46149. * The name of the hit test feature
  46150. */
  46151. static HIT_TEST: string;
  46152. /**
  46153. * physics impostors for xr controllers feature
  46154. */
  46155. static PHYSICS_CONTROLLERS: string;
  46156. /**
  46157. * The name of the plane detection feature
  46158. */
  46159. static PLANE_DETECTION: string;
  46160. /**
  46161. * The name of the pointer selection feature
  46162. */
  46163. static POINTER_SELECTION: string;
  46164. /**
  46165. * The name of the teleportation feature
  46166. */
  46167. static TELEPORTATION: string;
  46168. }
  46169. /**
  46170. * Defining the constructor of a feature. Used to register the modules.
  46171. */
  46172. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46173. /**
  46174. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46175. * It is mainly used in AR sessions.
  46176. *
  46177. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46178. */
  46179. export class WebXRFeaturesManager implements IDisposable {
  46180. private _xrSessionManager;
  46181. private static readonly _AvailableFeatures;
  46182. private _features;
  46183. /**
  46184. * constructs a new features manages.
  46185. *
  46186. * @param _xrSessionManager an instance of WebXRSessionManager
  46187. */
  46188. constructor(_xrSessionManager: WebXRSessionManager);
  46189. /**
  46190. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46191. * Mainly used internally.
  46192. *
  46193. * @param featureName the name of the feature to register
  46194. * @param constructorFunction the function used to construct the module
  46195. * @param version the (babylon) version of the module
  46196. * @param stable is that a stable version of this module
  46197. */
  46198. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46199. /**
  46200. * Returns a constructor of a specific feature.
  46201. *
  46202. * @param featureName the name of the feature to construct
  46203. * @param version the version of the feature to load
  46204. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46205. * @param options optional options provided to the module.
  46206. * @returns a function that, when called, will return a new instance of this feature
  46207. */
  46208. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46209. /**
  46210. * Can be used to return the list of features currently registered
  46211. *
  46212. * @returns an Array of available features
  46213. */
  46214. static GetAvailableFeatures(): string[];
  46215. /**
  46216. * Gets the versions available for a specific feature
  46217. * @param featureName the name of the feature
  46218. * @returns an array with the available versions
  46219. */
  46220. static GetAvailableVersions(featureName: string): string[];
  46221. /**
  46222. * Return the latest unstable version of this feature
  46223. * @param featureName the name of the feature to search
  46224. * @returns the version number. if not found will return -1
  46225. */
  46226. static GetLatestVersionOfFeature(featureName: string): number;
  46227. /**
  46228. * Return the latest stable version of this feature
  46229. * @param featureName the name of the feature to search
  46230. * @returns the version number. if not found will return -1
  46231. */
  46232. static GetStableVersionOfFeature(featureName: string): number;
  46233. /**
  46234. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46235. * Can be used during a session to start a feature
  46236. * @param featureName the name of feature to attach
  46237. */
  46238. attachFeature(featureName: string): void;
  46239. /**
  46240. * Can be used inside a session or when the session ends to detach a specific feature
  46241. * @param featureName the name of the feature to detach
  46242. */
  46243. detachFeature(featureName: string): void;
  46244. /**
  46245. * Used to disable an already-enabled feature
  46246. * The feature will be disposed and will be recreated once enabled.
  46247. * @param featureName the feature to disable
  46248. * @returns true if disable was successful
  46249. */
  46250. disableFeature(featureName: string | {
  46251. Name: string;
  46252. }): boolean;
  46253. /**
  46254. * dispose this features manager
  46255. */
  46256. dispose(): void;
  46257. /**
  46258. * 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.
  46259. * 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.
  46260. *
  46261. * @param featureName the name of the feature to load or the class of the feature
  46262. * @param version optional version to load. if not provided the latest version will be enabled
  46263. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46264. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46265. * @returns a new constructed feature or throws an error if feature not found.
  46266. */
  46267. enableFeature(featureName: string | {
  46268. Name: string;
  46269. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46270. /**
  46271. * get the implementation of an enabled feature.
  46272. * @param featureName the name of the feature to load
  46273. * @returns the feature class, if found
  46274. */
  46275. getEnabledFeature(featureName: string): IWebXRFeature;
  46276. /**
  46277. * Get the list of enabled features
  46278. * @returns an array of enabled features
  46279. */
  46280. getEnabledFeatures(): string[];
  46281. }
  46282. }
  46283. declare module BABYLON {
  46284. /**
  46285. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46286. * @see https://doc.babylonjs.com/how_to/webxr
  46287. */
  46288. export class WebXRExperienceHelper implements IDisposable {
  46289. private scene;
  46290. private _nonVRCamera;
  46291. private _originalSceneAutoClear;
  46292. private _supported;
  46293. /**
  46294. * Camera used to render xr content
  46295. */
  46296. camera: WebXRCamera;
  46297. /** A features manager for this xr session */
  46298. featuresManager: WebXRFeaturesManager;
  46299. /**
  46300. * Observers registered here will be triggered after the camera's initial transformation is set
  46301. * This can be used to set a different ground level or an extra rotation.
  46302. *
  46303. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46304. * to the position set after this observable is done executing.
  46305. */
  46306. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46307. /**
  46308. * Fires when the state of the experience helper has changed
  46309. */
  46310. onStateChangedObservable: Observable<WebXRState>;
  46311. /** Session manager used to keep track of xr session */
  46312. sessionManager: WebXRSessionManager;
  46313. /**
  46314. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46315. */
  46316. state: WebXRState;
  46317. /**
  46318. * Creates a WebXRExperienceHelper
  46319. * @param scene The scene the helper should be created in
  46320. */
  46321. private constructor();
  46322. /**
  46323. * Creates the experience helper
  46324. * @param scene the scene to attach the experience helper to
  46325. * @returns a promise for the experience helper
  46326. */
  46327. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46328. /**
  46329. * Disposes of the experience helper
  46330. */
  46331. dispose(): void;
  46332. /**
  46333. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46334. * @param sessionMode options for the XR session
  46335. * @param referenceSpaceType frame of reference of the XR session
  46336. * @param renderTarget the output canvas that will be used to enter XR mode
  46337. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46338. * @returns promise that resolves after xr mode has entered
  46339. */
  46340. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46341. /**
  46342. * Exits XR mode and returns the scene to its original state
  46343. * @returns promise that resolves after xr mode has exited
  46344. */
  46345. exitXRAsync(): Promise<void>;
  46346. private _nonXRToXRCamera;
  46347. private _setState;
  46348. }
  46349. }
  46350. declare module BABYLON {
  46351. /**
  46352. * X-Y values for axes in WebXR
  46353. */
  46354. export interface IWebXRMotionControllerAxesValue {
  46355. /**
  46356. * The value of the x axis
  46357. */
  46358. x: number;
  46359. /**
  46360. * The value of the y-axis
  46361. */
  46362. y: number;
  46363. }
  46364. /**
  46365. * changed / previous values for the values of this component
  46366. */
  46367. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46368. /**
  46369. * current (this frame) value
  46370. */
  46371. current: T;
  46372. /**
  46373. * previous (last change) value
  46374. */
  46375. previous: T;
  46376. }
  46377. /**
  46378. * Represents changes in the component between current frame and last values recorded
  46379. */
  46380. export interface IWebXRMotionControllerComponentChanges {
  46381. /**
  46382. * will be populated with previous and current values if axes changed
  46383. */
  46384. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46385. /**
  46386. * will be populated with previous and current values if pressed changed
  46387. */
  46388. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46389. /**
  46390. * will be populated with previous and current values if touched changed
  46391. */
  46392. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46393. /**
  46394. * will be populated with previous and current values if value changed
  46395. */
  46396. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46397. }
  46398. /**
  46399. * This class represents a single component (for example button or thumbstick) of a motion controller
  46400. */
  46401. export class WebXRControllerComponent implements IDisposable {
  46402. /**
  46403. * the id of this component
  46404. */
  46405. id: string;
  46406. /**
  46407. * the type of the component
  46408. */
  46409. type: MotionControllerComponentType;
  46410. private _buttonIndex;
  46411. private _axesIndices;
  46412. private _axes;
  46413. private _changes;
  46414. private _currentValue;
  46415. private _hasChanges;
  46416. private _pressed;
  46417. private _touched;
  46418. /**
  46419. * button component type
  46420. */
  46421. static BUTTON_TYPE: MotionControllerComponentType;
  46422. /**
  46423. * squeeze component type
  46424. */
  46425. static SQUEEZE_TYPE: MotionControllerComponentType;
  46426. /**
  46427. * Thumbstick component type
  46428. */
  46429. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46430. /**
  46431. * Touchpad component type
  46432. */
  46433. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46434. /**
  46435. * trigger component type
  46436. */
  46437. static TRIGGER_TYPE: MotionControllerComponentType;
  46438. /**
  46439. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46440. * the axes data changes
  46441. */
  46442. onAxisValueChangedObservable: Observable<{
  46443. x: number;
  46444. y: number;
  46445. }>;
  46446. /**
  46447. * Observers registered here will be triggered when the state of a button changes
  46448. * State change is either pressed / touched / value
  46449. */
  46450. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46451. /**
  46452. * Creates a new component for a motion controller.
  46453. * It is created by the motion controller itself
  46454. *
  46455. * @param id the id of this component
  46456. * @param type the type of the component
  46457. * @param _buttonIndex index in the buttons array of the gamepad
  46458. * @param _axesIndices indices of the values in the axes array of the gamepad
  46459. */
  46460. constructor(
  46461. /**
  46462. * the id of this component
  46463. */
  46464. id: string,
  46465. /**
  46466. * the type of the component
  46467. */
  46468. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46469. /**
  46470. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46471. */
  46472. get axes(): IWebXRMotionControllerAxesValue;
  46473. /**
  46474. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46475. */
  46476. get changes(): IWebXRMotionControllerComponentChanges;
  46477. /**
  46478. * Return whether or not the component changed the last frame
  46479. */
  46480. get hasChanges(): boolean;
  46481. /**
  46482. * is the button currently pressed
  46483. */
  46484. get pressed(): boolean;
  46485. /**
  46486. * is the button currently touched
  46487. */
  46488. get touched(): boolean;
  46489. /**
  46490. * Get the current value of this component
  46491. */
  46492. get value(): number;
  46493. /**
  46494. * Dispose this component
  46495. */
  46496. dispose(): void;
  46497. /**
  46498. * Are there axes correlating to this component
  46499. * @return true is axes data is available
  46500. */
  46501. isAxes(): boolean;
  46502. /**
  46503. * Is this component a button (hence - pressable)
  46504. * @returns true if can be pressed
  46505. */
  46506. isButton(): boolean;
  46507. /**
  46508. * update this component using the gamepad object it is in. Called on every frame
  46509. * @param nativeController the native gamepad controller object
  46510. */
  46511. update(nativeController: IMinimalMotionControllerObject): void;
  46512. }
  46513. }
  46514. declare module BABYLON {
  46515. /**
  46516. * Class used to represent data loading progression
  46517. */
  46518. export class SceneLoaderProgressEvent {
  46519. /** defines if data length to load can be evaluated */
  46520. readonly lengthComputable: boolean;
  46521. /** defines the loaded data length */
  46522. readonly loaded: number;
  46523. /** defines the data length to load */
  46524. readonly total: number;
  46525. /**
  46526. * Create a new progress event
  46527. * @param lengthComputable defines if data length to load can be evaluated
  46528. * @param loaded defines the loaded data length
  46529. * @param total defines the data length to load
  46530. */
  46531. constructor(
  46532. /** defines if data length to load can be evaluated */
  46533. lengthComputable: boolean,
  46534. /** defines the loaded data length */
  46535. loaded: number,
  46536. /** defines the data length to load */
  46537. total: number);
  46538. /**
  46539. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46540. * @param event defines the source event
  46541. * @returns a new SceneLoaderProgressEvent
  46542. */
  46543. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46544. }
  46545. /**
  46546. * Interface used by SceneLoader plugins to define supported file extensions
  46547. */
  46548. export interface ISceneLoaderPluginExtensions {
  46549. /**
  46550. * Defines the list of supported extensions
  46551. */
  46552. [extension: string]: {
  46553. isBinary: boolean;
  46554. };
  46555. }
  46556. /**
  46557. * Interface used by SceneLoader plugin factory
  46558. */
  46559. export interface ISceneLoaderPluginFactory {
  46560. /**
  46561. * Defines the name of the factory
  46562. */
  46563. name: string;
  46564. /**
  46565. * Function called to create a new plugin
  46566. * @return the new plugin
  46567. */
  46568. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46569. /**
  46570. * The callback that returns true if the data can be directly loaded.
  46571. * @param data string containing the file data
  46572. * @returns if the data can be loaded directly
  46573. */
  46574. canDirectLoad?(data: string): boolean;
  46575. }
  46576. /**
  46577. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46578. */
  46579. export interface ISceneLoaderPluginBase {
  46580. /**
  46581. * The friendly name of this plugin.
  46582. */
  46583. name: string;
  46584. /**
  46585. * The file extensions supported by this plugin.
  46586. */
  46587. extensions: string | ISceneLoaderPluginExtensions;
  46588. /**
  46589. * The callback called when loading from a url.
  46590. * @param scene scene loading this url
  46591. * @param url url to load
  46592. * @param onSuccess callback called when the file successfully loads
  46593. * @param onProgress callback called while file is loading (if the server supports this mode)
  46594. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46595. * @param onError callback called when the file fails to load
  46596. * @returns a file request object
  46597. */
  46598. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46599. /**
  46600. * The callback called when loading from a file object.
  46601. * @param scene scene loading this file
  46602. * @param file defines the file to load
  46603. * @param onSuccess defines the callback to call when data is loaded
  46604. * @param onProgress defines the callback to call during loading process
  46605. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46606. * @param onError defines the callback to call when an error occurs
  46607. * @returns a file request object
  46608. */
  46609. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46610. /**
  46611. * The callback that returns true if the data can be directly loaded.
  46612. * @param data string containing the file data
  46613. * @returns if the data can be loaded directly
  46614. */
  46615. canDirectLoad?(data: string): boolean;
  46616. /**
  46617. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46618. * @param scene scene loading this data
  46619. * @param data string containing the data
  46620. * @returns data to pass to the plugin
  46621. */
  46622. directLoad?(scene: Scene, data: string): any;
  46623. /**
  46624. * The callback that allows custom handling of the root url based on the response url.
  46625. * @param rootUrl the original root url
  46626. * @param responseURL the response url if available
  46627. * @returns the new root url
  46628. */
  46629. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46630. }
  46631. /**
  46632. * Interface used to define a SceneLoader plugin
  46633. */
  46634. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46635. /**
  46636. * Import meshes into a scene.
  46637. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46638. * @param scene The scene to import into
  46639. * @param data The data to import
  46640. * @param rootUrl The root url for scene and resources
  46641. * @param meshes The meshes array to import into
  46642. * @param particleSystems The particle systems array to import into
  46643. * @param skeletons The skeletons array to import into
  46644. * @param onError The callback when import fails
  46645. * @returns True if successful or false otherwise
  46646. */
  46647. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46648. /**
  46649. * Load into a scene.
  46650. * @param scene The scene to load into
  46651. * @param data The data to import
  46652. * @param rootUrl The root url for scene and resources
  46653. * @param onError The callback when import fails
  46654. * @returns True if successful or false otherwise
  46655. */
  46656. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46657. /**
  46658. * Load into an asset container.
  46659. * @param scene The scene to load into
  46660. * @param data The data to import
  46661. * @param rootUrl The root url for scene and resources
  46662. * @param onError The callback when import fails
  46663. * @returns The loaded asset container
  46664. */
  46665. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46666. }
  46667. /**
  46668. * Interface used to define an async SceneLoader plugin
  46669. */
  46670. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46671. /**
  46672. * Import meshes into a scene.
  46673. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46674. * @param scene The scene to import into
  46675. * @param data The data to import
  46676. * @param rootUrl The root url for scene and resources
  46677. * @param onProgress The callback when the load progresses
  46678. * @param fileName Defines the name of the file to load
  46679. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46680. */
  46681. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46682. meshes: AbstractMesh[];
  46683. particleSystems: IParticleSystem[];
  46684. skeletons: Skeleton[];
  46685. animationGroups: AnimationGroup[];
  46686. }>;
  46687. /**
  46688. * Load into a scene.
  46689. * @param scene The scene to load into
  46690. * @param data The data to import
  46691. * @param rootUrl The root url for scene and resources
  46692. * @param onProgress The callback when the load progresses
  46693. * @param fileName Defines the name of the file to load
  46694. * @returns Nothing
  46695. */
  46696. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46697. /**
  46698. * Load into an asset container.
  46699. * @param scene The scene to load into
  46700. * @param data The data to import
  46701. * @param rootUrl The root url for scene and resources
  46702. * @param onProgress The callback when the load progresses
  46703. * @param fileName Defines the name of the file to load
  46704. * @returns The loaded asset container
  46705. */
  46706. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46707. }
  46708. /**
  46709. * Mode that determines how to handle old animation groups before loading new ones.
  46710. */
  46711. export enum SceneLoaderAnimationGroupLoadingMode {
  46712. /**
  46713. * Reset all old animations to initial state then dispose them.
  46714. */
  46715. Clean = 0,
  46716. /**
  46717. * Stop all old animations.
  46718. */
  46719. Stop = 1,
  46720. /**
  46721. * Restart old animations from first frame.
  46722. */
  46723. Sync = 2,
  46724. /**
  46725. * Old animations remains untouched.
  46726. */
  46727. NoSync = 3
  46728. }
  46729. /**
  46730. * Class used to load scene from various file formats using registered plugins
  46731. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46732. */
  46733. export class SceneLoader {
  46734. /**
  46735. * No logging while loading
  46736. */
  46737. static readonly NO_LOGGING: number;
  46738. /**
  46739. * Minimal logging while loading
  46740. */
  46741. static readonly MINIMAL_LOGGING: number;
  46742. /**
  46743. * Summary logging while loading
  46744. */
  46745. static readonly SUMMARY_LOGGING: number;
  46746. /**
  46747. * Detailled logging while loading
  46748. */
  46749. static readonly DETAILED_LOGGING: number;
  46750. /**
  46751. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46752. */
  46753. static get ForceFullSceneLoadingForIncremental(): boolean;
  46754. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46755. /**
  46756. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46757. */
  46758. static get ShowLoadingScreen(): boolean;
  46759. static set ShowLoadingScreen(value: boolean);
  46760. /**
  46761. * Defines the current logging level (while loading the scene)
  46762. * @ignorenaming
  46763. */
  46764. static get loggingLevel(): number;
  46765. static set loggingLevel(value: number);
  46766. /**
  46767. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46768. */
  46769. static get CleanBoneMatrixWeights(): boolean;
  46770. static set CleanBoneMatrixWeights(value: boolean);
  46771. /**
  46772. * Event raised when a plugin is used to load a scene
  46773. */
  46774. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46775. private static _registeredPlugins;
  46776. private static _getDefaultPlugin;
  46777. private static _getPluginForExtension;
  46778. private static _getPluginForDirectLoad;
  46779. private static _getPluginForFilename;
  46780. private static _getDirectLoad;
  46781. private static _loadData;
  46782. private static _getFileInfo;
  46783. /**
  46784. * Gets a plugin that can load the given extension
  46785. * @param extension defines the extension to load
  46786. * @returns a plugin or null if none works
  46787. */
  46788. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46789. /**
  46790. * Gets a boolean indicating that the given extension can be loaded
  46791. * @param extension defines the extension to load
  46792. * @returns true if the extension is supported
  46793. */
  46794. static IsPluginForExtensionAvailable(extension: string): boolean;
  46795. /**
  46796. * Adds a new plugin to the list of registered plugins
  46797. * @param plugin defines the plugin to add
  46798. */
  46799. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46800. /**
  46801. * Import meshes into a scene
  46802. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46803. * @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)
  46804. * @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)
  46805. * @param scene the instance of BABYLON.Scene to append to
  46806. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46807. * @param onProgress a callback with a progress event for each file being loaded
  46808. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46809. * @param pluginExtension the extension used to determine the plugin
  46810. * @returns The loaded plugin
  46811. */
  46812. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46813. /**
  46814. * Import meshes into a scene
  46815. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46816. * @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)
  46817. * @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)
  46818. * @param scene the instance of BABYLON.Scene to append to
  46819. * @param onProgress a callback with a progress event for each file being loaded
  46820. * @param pluginExtension the extension used to determine the plugin
  46821. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46822. */
  46823. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46824. meshes: AbstractMesh[];
  46825. particleSystems: IParticleSystem[];
  46826. skeletons: Skeleton[];
  46827. animationGroups: AnimationGroup[];
  46828. }>;
  46829. /**
  46830. * Load a scene
  46831. * @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)
  46832. * @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)
  46833. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46834. * @param onSuccess a callback with the scene when import succeeds
  46835. * @param onProgress a callback with a progress event for each file being loaded
  46836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46837. * @param pluginExtension the extension used to determine the plugin
  46838. * @returns The loaded plugin
  46839. */
  46840. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46841. /**
  46842. * Load a scene
  46843. * @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)
  46844. * @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)
  46845. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46846. * @param onProgress a callback with a progress event for each file being loaded
  46847. * @param pluginExtension the extension used to determine the plugin
  46848. * @returns The loaded scene
  46849. */
  46850. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46851. /**
  46852. * Append a scene
  46853. * @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)
  46854. * @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)
  46855. * @param scene is the instance of BABYLON.Scene to append to
  46856. * @param onSuccess a callback with the scene when import succeeds
  46857. * @param onProgress a callback with a progress event for each file being loaded
  46858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46859. * @param pluginExtension the extension used to determine the plugin
  46860. * @returns The loaded plugin
  46861. */
  46862. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46863. /**
  46864. * Append a scene
  46865. * @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)
  46866. * @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)
  46867. * @param scene is the instance of BABYLON.Scene to append to
  46868. * @param onProgress a callback with a progress event for each file being loaded
  46869. * @param pluginExtension the extension used to determine the plugin
  46870. * @returns The given scene
  46871. */
  46872. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46873. /**
  46874. * Load a scene into an asset container
  46875. * @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)
  46876. * @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)
  46877. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46878. * @param onSuccess a callback with the scene when import succeeds
  46879. * @param onProgress a callback with a progress event for each file being loaded
  46880. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46881. * @param pluginExtension the extension used to determine the plugin
  46882. * @returns The loaded plugin
  46883. */
  46884. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46885. /**
  46886. * Load a scene into an asset container
  46887. * @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)
  46888. * @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)
  46889. * @param scene is the instance of Scene to append to
  46890. * @param onProgress a callback with a progress event for each file being loaded
  46891. * @param pluginExtension the extension used to determine the plugin
  46892. * @returns The loaded asset container
  46893. */
  46894. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46895. /**
  46896. * Import animations from a file into a scene
  46897. * @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)
  46898. * @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)
  46899. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46900. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46901. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46902. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46903. * @param onSuccess a callback with the scene when import succeeds
  46904. * @param onProgress a callback with a progress event for each file being loaded
  46905. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46906. */
  46907. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  46908. /**
  46909. * Import animations from a file into a scene
  46910. * @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)
  46911. * @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)
  46912. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46913. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46914. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46915. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46916. * @param onSuccess a callback with the scene when import succeeds
  46917. * @param onProgress a callback with a progress event for each file being loaded
  46918. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46919. * @returns the updated scene with imported animations
  46920. */
  46921. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  46922. }
  46923. }
  46924. declare module BABYLON {
  46925. /**
  46926. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46927. */
  46928. export type MotionControllerHandedness = "none" | "left" | "right";
  46929. /**
  46930. * The type of components available in motion controllers.
  46931. * This is not the name of the component.
  46932. */
  46933. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46934. /**
  46935. * The state of a controller component
  46936. */
  46937. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46938. /**
  46939. * The schema of motion controller layout.
  46940. * No object will be initialized using this interface
  46941. * This is used just to define the profile.
  46942. */
  46943. export interface IMotionControllerLayout {
  46944. /**
  46945. * Path to load the assets. Usually relative to the base path
  46946. */
  46947. assetPath: string;
  46948. /**
  46949. * Available components (unsorted)
  46950. */
  46951. components: {
  46952. /**
  46953. * A map of component Ids
  46954. */
  46955. [componentId: string]: {
  46956. /**
  46957. * The type of input the component outputs
  46958. */
  46959. type: MotionControllerComponentType;
  46960. /**
  46961. * The indices of this component in the gamepad object
  46962. */
  46963. gamepadIndices: {
  46964. /**
  46965. * Index of button
  46966. */
  46967. button?: number;
  46968. /**
  46969. * If available, index of x-axis
  46970. */
  46971. xAxis?: number;
  46972. /**
  46973. * If available, index of y-axis
  46974. */
  46975. yAxis?: number;
  46976. };
  46977. /**
  46978. * The mesh's root node name
  46979. */
  46980. rootNodeName: string;
  46981. /**
  46982. * Animation definitions for this model
  46983. */
  46984. visualResponses: {
  46985. [stateKey: string]: {
  46986. /**
  46987. * What property will be animated
  46988. */
  46989. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46990. /**
  46991. * What states influence this visual response
  46992. */
  46993. states: MotionControllerComponentStateType[];
  46994. /**
  46995. * Type of animation - movement or visibility
  46996. */
  46997. valueNodeProperty: "transform" | "visibility";
  46998. /**
  46999. * Base node name to move. Its position will be calculated according to the min and max nodes
  47000. */
  47001. valueNodeName?: string;
  47002. /**
  47003. * Minimum movement node
  47004. */
  47005. minNodeName?: string;
  47006. /**
  47007. * Max movement node
  47008. */
  47009. maxNodeName?: string;
  47010. };
  47011. };
  47012. /**
  47013. * If touch enabled, what is the name of node to display user feedback
  47014. */
  47015. touchPointNodeName?: string;
  47016. };
  47017. };
  47018. /**
  47019. * Is it xr standard mapping or not
  47020. */
  47021. gamepadMapping: "" | "xr-standard";
  47022. /**
  47023. * Base root node of this entire model
  47024. */
  47025. rootNodeName: string;
  47026. /**
  47027. * Defines the main button component id
  47028. */
  47029. selectComponentId: string;
  47030. }
  47031. /**
  47032. * A definition for the layout map in the input profile
  47033. */
  47034. export interface IMotionControllerLayoutMap {
  47035. /**
  47036. * Layouts with handedness type as a key
  47037. */
  47038. [handedness: string]: IMotionControllerLayout;
  47039. }
  47040. /**
  47041. * The XR Input profile schema
  47042. * Profiles can be found here:
  47043. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47044. */
  47045. export interface IMotionControllerProfile {
  47046. /**
  47047. * fallback profiles for this profileId
  47048. */
  47049. fallbackProfileIds: string[];
  47050. /**
  47051. * The layout map, with handedness as key
  47052. */
  47053. layouts: IMotionControllerLayoutMap;
  47054. /**
  47055. * The id of this profile
  47056. * correlates to the profile(s) in the xrInput.profiles array
  47057. */
  47058. profileId: string;
  47059. }
  47060. /**
  47061. * A helper-interface for the 3 meshes needed for controller button animation
  47062. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47063. */
  47064. export interface IMotionControllerButtonMeshMap {
  47065. /**
  47066. * the mesh that defines the pressed value mesh position.
  47067. * This is used to find the max-position of this button
  47068. */
  47069. pressedMesh: AbstractMesh;
  47070. /**
  47071. * the mesh that defines the unpressed value mesh position.
  47072. * This is used to find the min (or initial) position of this button
  47073. */
  47074. unpressedMesh: AbstractMesh;
  47075. /**
  47076. * The mesh that will be changed when value changes
  47077. */
  47078. valueMesh: AbstractMesh;
  47079. }
  47080. /**
  47081. * A helper-interface for the 3 meshes needed for controller axis animation.
  47082. * This will be expanded when touchpad animations are fully supported
  47083. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47084. */
  47085. export interface IMotionControllerMeshMap {
  47086. /**
  47087. * the mesh that defines the maximum value mesh position.
  47088. */
  47089. maxMesh?: AbstractMesh;
  47090. /**
  47091. * the mesh that defines the minimum value mesh position.
  47092. */
  47093. minMesh?: AbstractMesh;
  47094. /**
  47095. * The mesh that will be changed when axis value changes
  47096. */
  47097. valueMesh: AbstractMesh;
  47098. }
  47099. /**
  47100. * The elements needed for change-detection of the gamepad objects in motion controllers
  47101. */
  47102. export interface IMinimalMotionControllerObject {
  47103. /**
  47104. * Available axes of this controller
  47105. */
  47106. axes: number[];
  47107. /**
  47108. * An array of available buttons
  47109. */
  47110. buttons: Array<{
  47111. /**
  47112. * Value of the button/trigger
  47113. */
  47114. value: number;
  47115. /**
  47116. * If the button/trigger is currently touched
  47117. */
  47118. touched: boolean;
  47119. /**
  47120. * If the button/trigger is currently pressed
  47121. */
  47122. pressed: boolean;
  47123. }>;
  47124. /**
  47125. * EXPERIMENTAL haptic support.
  47126. */
  47127. hapticActuators?: Array<{
  47128. pulse: (value: number, duration: number) => Promise<boolean>;
  47129. }>;
  47130. }
  47131. /**
  47132. * An Abstract Motion controller
  47133. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47134. * Each component has an observable to check for changes in value and state
  47135. */
  47136. export abstract class WebXRAbstractMotionController implements IDisposable {
  47137. protected scene: Scene;
  47138. protected layout: IMotionControllerLayout;
  47139. /**
  47140. * The gamepad object correlating to this controller
  47141. */
  47142. gamepadObject: IMinimalMotionControllerObject;
  47143. /**
  47144. * handedness (left/right/none) of this controller
  47145. */
  47146. handedness: MotionControllerHandedness;
  47147. private _initComponent;
  47148. private _modelReady;
  47149. /**
  47150. * A map of components (WebXRControllerComponent) in this motion controller
  47151. * Components have a ComponentType and can also have both button and axis definitions
  47152. */
  47153. readonly components: {
  47154. [id: string]: WebXRControllerComponent;
  47155. };
  47156. /**
  47157. * Disable the model's animation. Can be set at any time.
  47158. */
  47159. disableAnimation: boolean;
  47160. /**
  47161. * Observers registered here will be triggered when the model of this controller is done loading
  47162. */
  47163. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47164. /**
  47165. * The profile id of this motion controller
  47166. */
  47167. abstract profileId: string;
  47168. /**
  47169. * The root mesh of the model. It is null if the model was not yet initialized
  47170. */
  47171. rootMesh: Nullable<AbstractMesh>;
  47172. /**
  47173. * constructs a new abstract motion controller
  47174. * @param scene the scene to which the model of the controller will be added
  47175. * @param layout The profile layout to load
  47176. * @param gamepadObject The gamepad object correlating to this controller
  47177. * @param handedness handedness (left/right/none) of this controller
  47178. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47179. */
  47180. constructor(scene: Scene, layout: IMotionControllerLayout,
  47181. /**
  47182. * The gamepad object correlating to this controller
  47183. */
  47184. gamepadObject: IMinimalMotionControllerObject,
  47185. /**
  47186. * handedness (left/right/none) of this controller
  47187. */
  47188. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47189. /**
  47190. * Dispose this controller, the model mesh and all its components
  47191. */
  47192. dispose(): void;
  47193. /**
  47194. * Returns all components of specific type
  47195. * @param type the type to search for
  47196. * @return an array of components with this type
  47197. */
  47198. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47199. /**
  47200. * get a component based an its component id as defined in layout.components
  47201. * @param id the id of the component
  47202. * @returns the component correlates to the id or undefined if not found
  47203. */
  47204. getComponent(id: string): WebXRControllerComponent;
  47205. /**
  47206. * Get the list of components available in this motion controller
  47207. * @returns an array of strings correlating to available components
  47208. */
  47209. getComponentIds(): string[];
  47210. /**
  47211. * Get the first component of specific type
  47212. * @param type type of component to find
  47213. * @return a controller component or null if not found
  47214. */
  47215. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47216. /**
  47217. * Get the main (Select) component of this controller as defined in the layout
  47218. * @returns the main component of this controller
  47219. */
  47220. getMainComponent(): WebXRControllerComponent;
  47221. /**
  47222. * Loads the model correlating to this controller
  47223. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47224. * @returns A promise fulfilled with the result of the model loading
  47225. */
  47226. loadModel(): Promise<boolean>;
  47227. /**
  47228. * Update this model using the current XRFrame
  47229. * @param xrFrame the current xr frame to use and update the model
  47230. */
  47231. updateFromXRFrame(xrFrame: XRFrame): void;
  47232. /**
  47233. * Backwards compatibility due to a deeply-integrated typo
  47234. */
  47235. get handness(): XREye;
  47236. /**
  47237. * Pulse (vibrate) this controller
  47238. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47239. * Consecutive calls to this function will cancel the last pulse call
  47240. *
  47241. * @param value the strength of the pulse in 0.0...1.0 range
  47242. * @param duration Duration of the pulse in milliseconds
  47243. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47244. * @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
  47245. */
  47246. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47247. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47248. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47249. /**
  47250. * Moves the axis on the controller mesh based on its current state
  47251. * @param axis the index of the axis
  47252. * @param axisValue the value of the axis which determines the meshes new position
  47253. * @hidden
  47254. */
  47255. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47256. /**
  47257. * Update the model itself with the current frame data
  47258. * @param xrFrame the frame to use for updating the model mesh
  47259. */
  47260. protected updateModel(xrFrame: XRFrame): void;
  47261. /**
  47262. * Get the filename and path for this controller's model
  47263. * @returns a map of filename and path
  47264. */
  47265. protected abstract _getFilenameAndPath(): {
  47266. filename: string;
  47267. path: string;
  47268. };
  47269. /**
  47270. * This function is called before the mesh is loaded. It checks for loading constraints.
  47271. * For example, this function can check if the GLB loader is available
  47272. * If this function returns false, the generic controller will be loaded instead
  47273. * @returns Is the client ready to load the mesh
  47274. */
  47275. protected abstract _getModelLoadingConstraints(): boolean;
  47276. /**
  47277. * This function will be called after the model was successfully loaded and can be used
  47278. * for mesh transformations before it is available for the user
  47279. * @param meshes the loaded meshes
  47280. */
  47281. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47282. /**
  47283. * Set the root mesh for this controller. Important for the WebXR controller class
  47284. * @param meshes the loaded meshes
  47285. */
  47286. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47287. /**
  47288. * A function executed each frame that updates the mesh (if needed)
  47289. * @param xrFrame the current xrFrame
  47290. */
  47291. protected abstract _updateModel(xrFrame: XRFrame): void;
  47292. private _getGenericFilenameAndPath;
  47293. private _getGenericParentMesh;
  47294. }
  47295. }
  47296. declare module BABYLON {
  47297. /**
  47298. * A generic trigger-only motion controller for WebXR
  47299. */
  47300. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47301. /**
  47302. * Static version of the profile id of this controller
  47303. */
  47304. static ProfileId: string;
  47305. profileId: string;
  47306. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47307. protected _getFilenameAndPath(): {
  47308. filename: string;
  47309. path: string;
  47310. };
  47311. protected _getModelLoadingConstraints(): boolean;
  47312. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47313. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47314. protected _updateModel(): void;
  47315. }
  47316. }
  47317. declare module BABYLON {
  47318. /**
  47319. * Class containing static functions to help procedurally build meshes
  47320. */
  47321. export class SphereBuilder {
  47322. /**
  47323. * Creates a sphere mesh
  47324. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47325. * * 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`)
  47326. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47327. * * 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
  47328. * * 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)
  47329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47330. * * 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
  47331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47332. * @param name defines the name of the mesh
  47333. * @param options defines the options used to create the mesh
  47334. * @param scene defines the hosting scene
  47335. * @returns the sphere mesh
  47336. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47337. */
  47338. static CreateSphere(name: string, options: {
  47339. segments?: number;
  47340. diameter?: number;
  47341. diameterX?: number;
  47342. diameterY?: number;
  47343. diameterZ?: number;
  47344. arc?: number;
  47345. slice?: number;
  47346. sideOrientation?: number;
  47347. frontUVs?: Vector4;
  47348. backUVs?: Vector4;
  47349. updatable?: boolean;
  47350. }, scene?: Nullable<Scene>): Mesh;
  47351. }
  47352. }
  47353. declare module BABYLON {
  47354. /**
  47355. * A profiled motion controller has its profile loaded from an online repository.
  47356. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47357. */
  47358. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47359. private _repositoryUrl;
  47360. private _buttonMeshMapping;
  47361. private _touchDots;
  47362. /**
  47363. * The profile ID of this controller. Will be populated when the controller initializes.
  47364. */
  47365. profileId: string;
  47366. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47367. dispose(): void;
  47368. protected _getFilenameAndPath(): {
  47369. filename: string;
  47370. path: string;
  47371. };
  47372. protected _getModelLoadingConstraints(): boolean;
  47373. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47374. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47375. protected _updateModel(_xrFrame: XRFrame): void;
  47376. }
  47377. }
  47378. declare module BABYLON {
  47379. /**
  47380. * A construction function type to create a new controller based on an xrInput object
  47381. */
  47382. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47383. /**
  47384. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47385. *
  47386. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47387. * it should be replaced with auto-loaded controllers.
  47388. *
  47389. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47390. */
  47391. export class WebXRMotionControllerManager {
  47392. private static _AvailableControllers;
  47393. private static _Fallbacks;
  47394. private static _ProfileLoadingPromises;
  47395. private static _ProfilesList;
  47396. /**
  47397. * The base URL of the online controller repository. Can be changed at any time.
  47398. */
  47399. static BaseRepositoryUrl: string;
  47400. /**
  47401. * Which repository gets priority - local or online
  47402. */
  47403. static PrioritizeOnlineRepository: boolean;
  47404. /**
  47405. * Use the online repository, or use only locally-defined controllers
  47406. */
  47407. static UseOnlineRepository: boolean;
  47408. /**
  47409. * Clear the cache used for profile loading and reload when requested again
  47410. */
  47411. static ClearProfilesCache(): void;
  47412. /**
  47413. * Register the default fallbacks.
  47414. * This function is called automatically when this file is imported.
  47415. */
  47416. static DefaultFallbacks(): void;
  47417. /**
  47418. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47419. * @param profileId the profile to which a fallback needs to be found
  47420. * @return an array with corresponding fallback profiles
  47421. */
  47422. static FindFallbackWithProfileId(profileId: string): string[];
  47423. /**
  47424. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47425. * The order of search:
  47426. *
  47427. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47428. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47429. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47430. * 4) return the generic trigger controller if none were found
  47431. *
  47432. * @param xrInput the xrInput to which a new controller is initialized
  47433. * @param scene the scene to which the model will be added
  47434. * @param forceProfile force a certain profile for this controller
  47435. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47436. */
  47437. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47438. /**
  47439. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47440. *
  47441. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47442. *
  47443. * @param type the profile type to register
  47444. * @param constructFunction the function to be called when loading this profile
  47445. */
  47446. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47447. /**
  47448. * Register a fallback to a specific profile.
  47449. * @param profileId the profileId that will receive the fallbacks
  47450. * @param fallbacks A list of fallback profiles
  47451. */
  47452. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47453. /**
  47454. * Will update the list of profiles available in the repository
  47455. * @return a promise that resolves to a map of profiles available online
  47456. */
  47457. static UpdateProfilesList(): Promise<{
  47458. [profile: string]: string;
  47459. }>;
  47460. private static _LoadProfileFromRepository;
  47461. private static _LoadProfilesFromAvailableControllers;
  47462. }
  47463. }
  47464. declare module BABYLON {
  47465. /**
  47466. * Configuration options for the WebXR controller creation
  47467. */
  47468. export interface IWebXRControllerOptions {
  47469. /**
  47470. * Should the controller mesh be animated when a user interacts with it
  47471. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47472. */
  47473. disableMotionControllerAnimation?: boolean;
  47474. /**
  47475. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47476. */
  47477. doNotLoadControllerMesh?: boolean;
  47478. /**
  47479. * Force a specific controller type for this controller.
  47480. * This can be used when creating your own profile or when testing different controllers
  47481. */
  47482. forceControllerProfile?: string;
  47483. /**
  47484. * Defines a rendering group ID for meshes that will be loaded.
  47485. * This is for the default controllers only.
  47486. */
  47487. renderingGroupId?: number;
  47488. }
  47489. /**
  47490. * Represents an XR controller
  47491. */
  47492. export class WebXRInputSource {
  47493. private _scene;
  47494. /** The underlying input source for the controller */
  47495. inputSource: XRInputSource;
  47496. private _options;
  47497. private _tmpVector;
  47498. private _uniqueId;
  47499. /**
  47500. * 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
  47501. */
  47502. grip?: AbstractMesh;
  47503. /**
  47504. * If available, this is the gamepad object related to this controller.
  47505. * Using this object it is possible to get click events and trackpad changes of the
  47506. * webxr controller that is currently being used.
  47507. */
  47508. motionController?: WebXRAbstractMotionController;
  47509. /**
  47510. * Event that fires when the controller is removed/disposed.
  47511. * The object provided as event data is this controller, after associated assets were disposed.
  47512. * uniqueId is still available.
  47513. */
  47514. onDisposeObservable: Observable<WebXRInputSource>;
  47515. /**
  47516. * Will be triggered when the mesh associated with the motion controller is done loading.
  47517. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47518. * A shortened version of controller -> motion controller -> on mesh loaded.
  47519. */
  47520. onMeshLoadedObservable: Observable<AbstractMesh>;
  47521. /**
  47522. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47523. */
  47524. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47525. /**
  47526. * Pointer which can be used to select objects or attach a visible laser to
  47527. */
  47528. pointer: AbstractMesh;
  47529. /**
  47530. * Creates the controller
  47531. * @see https://doc.babylonjs.com/how_to/webxr
  47532. * @param _scene the scene which the controller should be associated to
  47533. * @param inputSource the underlying input source for the controller
  47534. * @param _options options for this controller creation
  47535. */
  47536. constructor(_scene: Scene,
  47537. /** The underlying input source for the controller */
  47538. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47539. /**
  47540. * Get this controllers unique id
  47541. */
  47542. get uniqueId(): string;
  47543. /**
  47544. * Disposes of the object
  47545. */
  47546. dispose(): void;
  47547. /**
  47548. * Gets a world space ray coming from the pointer or grip
  47549. * @param result the resulting ray
  47550. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47551. */
  47552. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47553. /**
  47554. * Updates the controller pose based on the given XRFrame
  47555. * @param xrFrame xr frame to update the pose with
  47556. * @param referenceSpace reference space to use
  47557. */
  47558. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47559. }
  47560. }
  47561. declare module BABYLON {
  47562. /**
  47563. * The schema for initialization options of the XR Input class
  47564. */
  47565. export interface IWebXRInputOptions {
  47566. /**
  47567. * If set to true no model will be automatically loaded
  47568. */
  47569. doNotLoadControllerMeshes?: boolean;
  47570. /**
  47571. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47572. * If not found, the xr input profile data will be used.
  47573. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47574. */
  47575. forceInputProfile?: string;
  47576. /**
  47577. * Do not send a request to the controller repository to load the profile.
  47578. *
  47579. * Instead, use the controllers available in babylon itself.
  47580. */
  47581. disableOnlineControllerRepository?: boolean;
  47582. /**
  47583. * A custom URL for the controllers repository
  47584. */
  47585. customControllersRepositoryURL?: string;
  47586. /**
  47587. * Should the controller model's components not move according to the user input
  47588. */
  47589. disableControllerAnimation?: boolean;
  47590. /**
  47591. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47592. */
  47593. controllerOptions?: IWebXRControllerOptions;
  47594. }
  47595. /**
  47596. * XR input used to track XR inputs such as controllers/rays
  47597. */
  47598. export class WebXRInput implements IDisposable {
  47599. /**
  47600. * the xr session manager for this session
  47601. */
  47602. xrSessionManager: WebXRSessionManager;
  47603. /**
  47604. * the WebXR camera for this session. Mainly used for teleportation
  47605. */
  47606. xrCamera: WebXRCamera;
  47607. private readonly options;
  47608. /**
  47609. * XR controllers being tracked
  47610. */
  47611. controllers: Array<WebXRInputSource>;
  47612. private _frameObserver;
  47613. private _sessionEndedObserver;
  47614. private _sessionInitObserver;
  47615. /**
  47616. * Event when a controller has been connected/added
  47617. */
  47618. onControllerAddedObservable: Observable<WebXRInputSource>;
  47619. /**
  47620. * Event when a controller has been removed/disconnected
  47621. */
  47622. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47623. /**
  47624. * Initializes the WebXRInput
  47625. * @param xrSessionManager the xr session manager for this session
  47626. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47627. * @param options = initialization options for this xr input
  47628. */
  47629. constructor(
  47630. /**
  47631. * the xr session manager for this session
  47632. */
  47633. xrSessionManager: WebXRSessionManager,
  47634. /**
  47635. * the WebXR camera for this session. Mainly used for teleportation
  47636. */
  47637. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47638. private _onInputSourcesChange;
  47639. private _addAndRemoveControllers;
  47640. /**
  47641. * Disposes of the object
  47642. */
  47643. dispose(): void;
  47644. }
  47645. }
  47646. declare module BABYLON {
  47647. /**
  47648. * This is the base class for all WebXR features.
  47649. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47650. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47651. */
  47652. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47653. protected _xrSessionManager: WebXRSessionManager;
  47654. private _attached;
  47655. private _removeOnDetach;
  47656. /**
  47657. * Should auto-attach be disabled?
  47658. */
  47659. disableAutoAttach: boolean;
  47660. /**
  47661. * Construct a new (abstract) WebXR feature
  47662. * @param _xrSessionManager the xr session manager for this feature
  47663. */
  47664. constructor(_xrSessionManager: WebXRSessionManager);
  47665. /**
  47666. * Is this feature attached
  47667. */
  47668. get attached(): boolean;
  47669. /**
  47670. * attach this feature
  47671. *
  47672. * @param force should attachment be forced (even when already attached)
  47673. * @returns true if successful, false is failed or already attached
  47674. */
  47675. attach(force?: boolean): boolean;
  47676. /**
  47677. * detach this feature.
  47678. *
  47679. * @returns true if successful, false if failed or already detached
  47680. */
  47681. detach(): boolean;
  47682. /**
  47683. * Dispose this feature and all of the resources attached
  47684. */
  47685. dispose(): void;
  47686. /**
  47687. * This is used to register callbacks that will automatically be removed when detach is called.
  47688. * @param observable the observable to which the observer will be attached
  47689. * @param callback the callback to register
  47690. */
  47691. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47692. /**
  47693. * Code in this function will be executed on each xrFrame received from the browser.
  47694. * This function will not execute after the feature is detached.
  47695. * @param _xrFrame the current frame
  47696. */
  47697. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47698. }
  47699. }
  47700. declare module BABYLON {
  47701. /**
  47702. * Renders a layer on top of an existing scene
  47703. */
  47704. export class UtilityLayerRenderer implements IDisposable {
  47705. /** the original scene that will be rendered on top of */
  47706. originalScene: Scene;
  47707. private _pointerCaptures;
  47708. private _lastPointerEvents;
  47709. private static _DefaultUtilityLayer;
  47710. private static _DefaultKeepDepthUtilityLayer;
  47711. private _sharedGizmoLight;
  47712. private _renderCamera;
  47713. /**
  47714. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47715. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47716. * @returns the camera that is used when rendering the utility layer
  47717. */
  47718. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47719. /**
  47720. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47721. * @param cam the camera that should be used when rendering the utility layer
  47722. */
  47723. setRenderCamera(cam: Nullable<Camera>): void;
  47724. /**
  47725. * @hidden
  47726. * Light which used by gizmos to get light shading
  47727. */
  47728. _getSharedGizmoLight(): HemisphericLight;
  47729. /**
  47730. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47731. */
  47732. pickUtilitySceneFirst: boolean;
  47733. /**
  47734. * 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)
  47735. */
  47736. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47737. /**
  47738. * 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)
  47739. */
  47740. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47741. /**
  47742. * The scene that is rendered on top of the original scene
  47743. */
  47744. utilityLayerScene: Scene;
  47745. /**
  47746. * If the utility layer should automatically be rendered on top of existing scene
  47747. */
  47748. shouldRender: boolean;
  47749. /**
  47750. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47751. */
  47752. onlyCheckPointerDownEvents: boolean;
  47753. /**
  47754. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47755. */
  47756. processAllEvents: boolean;
  47757. /**
  47758. * Observable raised when the pointer move from the utility layer scene to the main scene
  47759. */
  47760. onPointerOutObservable: Observable<number>;
  47761. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47762. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47763. private _afterRenderObserver;
  47764. private _sceneDisposeObserver;
  47765. private _originalPointerObserver;
  47766. /**
  47767. * Instantiates a UtilityLayerRenderer
  47768. * @param originalScene the original scene that will be rendered on top of
  47769. * @param handleEvents boolean indicating if the utility layer should handle events
  47770. */
  47771. constructor(
  47772. /** the original scene that will be rendered on top of */
  47773. originalScene: Scene, handleEvents?: boolean);
  47774. private _notifyObservers;
  47775. /**
  47776. * Renders the utility layers scene on top of the original scene
  47777. */
  47778. render(): void;
  47779. /**
  47780. * Disposes of the renderer
  47781. */
  47782. dispose(): void;
  47783. private _updateCamera;
  47784. }
  47785. }
  47786. declare module BABYLON {
  47787. /**
  47788. * Options interface for the pointer selection module
  47789. */
  47790. export interface IWebXRControllerPointerSelectionOptions {
  47791. /**
  47792. * if provided, this scene will be used to render meshes.
  47793. */
  47794. customUtilityLayerScene?: Scene;
  47795. /**
  47796. * 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)
  47797. * If not disabled, the last picked point will be used to execute a pointer up event
  47798. * If disabled, pointer up event will be triggered right after the pointer down event.
  47799. * Used in screen and gaze target ray mode only
  47800. */
  47801. disablePointerUpOnTouchOut: boolean;
  47802. /**
  47803. * For gaze mode (time to select instead of press)
  47804. */
  47805. forceGazeMode: boolean;
  47806. /**
  47807. * 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
  47808. * to start a new countdown to the pointer down event.
  47809. * Defaults to 1.
  47810. */
  47811. gazeModePointerMovedFactor?: number;
  47812. /**
  47813. * Different button type to use instead of the main component
  47814. */
  47815. overrideButtonId?: string;
  47816. /**
  47817. * use this rendering group id for the meshes (optional)
  47818. */
  47819. renderingGroupId?: number;
  47820. /**
  47821. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47822. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47823. * 3000 means 3 seconds between pointing at something and selecting it
  47824. */
  47825. timeToSelect?: number;
  47826. /**
  47827. * Should meshes created here be added to a utility layer or the main scene
  47828. */
  47829. useUtilityLayer?: boolean;
  47830. /**
  47831. * the xr input to use with this pointer selection
  47832. */
  47833. xrInput: WebXRInput;
  47834. }
  47835. /**
  47836. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47837. */
  47838. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47839. private readonly _options;
  47840. private static _idCounter;
  47841. private _attachController;
  47842. private _controllers;
  47843. private _scene;
  47844. private _tmpVectorForPickCompare;
  47845. /**
  47846. * The module's name
  47847. */
  47848. static readonly Name: string;
  47849. /**
  47850. * The (Babylon) version of this module.
  47851. * This is an integer representing the implementation version.
  47852. * This number does not correspond to the WebXR specs version
  47853. */
  47854. static readonly Version: number;
  47855. /**
  47856. * Disable lighting on the laser pointer (so it will always be visible)
  47857. */
  47858. disablePointerLighting: boolean;
  47859. /**
  47860. * Disable lighting on the selection mesh (so it will always be visible)
  47861. */
  47862. disableSelectionMeshLighting: boolean;
  47863. /**
  47864. * Should the laser pointer be displayed
  47865. */
  47866. displayLaserPointer: boolean;
  47867. /**
  47868. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47869. */
  47870. displaySelectionMesh: boolean;
  47871. /**
  47872. * This color will be set to the laser pointer when selection is triggered
  47873. */
  47874. laserPointerPickedColor: Color3;
  47875. /**
  47876. * Default color of the laser pointer
  47877. */
  47878. laserPointerDefaultColor: Color3;
  47879. /**
  47880. * default color of the selection ring
  47881. */
  47882. selectionMeshDefaultColor: Color3;
  47883. /**
  47884. * This color will be applied to the selection ring when selection is triggered
  47885. */
  47886. selectionMeshPickedColor: Color3;
  47887. /**
  47888. * Optional filter to be used for ray selection. This predicate shares behavior with
  47889. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47890. */
  47891. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47892. /**
  47893. * constructs a new background remover module
  47894. * @param _xrSessionManager the session manager for this module
  47895. * @param _options read-only options to be used in this module
  47896. */
  47897. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47898. /**
  47899. * attach this feature
  47900. * Will usually be called by the features manager
  47901. *
  47902. * @returns true if successful.
  47903. */
  47904. attach(): boolean;
  47905. /**
  47906. * detach this feature.
  47907. * Will usually be called by the features manager
  47908. *
  47909. * @returns true if successful.
  47910. */
  47911. detach(): boolean;
  47912. /**
  47913. * Will get the mesh under a specific pointer.
  47914. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47915. * @param controllerId the controllerId to check
  47916. * @returns The mesh under pointer or null if no mesh is under the pointer
  47917. */
  47918. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47919. /**
  47920. * Get the xr controller that correlates to the pointer id in the pointer event
  47921. *
  47922. * @param id the pointer id to search for
  47923. * @returns the controller that correlates to this id or null if not found
  47924. */
  47925. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47926. protected _onXRFrame(_xrFrame: XRFrame): void;
  47927. private _attachGazeMode;
  47928. private _attachScreenRayMode;
  47929. private _attachTrackedPointerRayMode;
  47930. private _convertNormalToDirectionOfRay;
  47931. private _detachController;
  47932. private _generateNewMeshPair;
  47933. private _pickingMoved;
  47934. private _updatePointerDistance;
  47935. /** @hidden */
  47936. get lasterPointerDefaultColor(): Color3;
  47937. }
  47938. }
  47939. declare module BABYLON {
  47940. /**
  47941. * Button which can be used to enter a different mode of XR
  47942. */
  47943. export class WebXREnterExitUIButton {
  47944. /** button element */
  47945. element: HTMLElement;
  47946. /** XR initialization options for the button */
  47947. sessionMode: XRSessionMode;
  47948. /** Reference space type */
  47949. referenceSpaceType: XRReferenceSpaceType;
  47950. /**
  47951. * Creates a WebXREnterExitUIButton
  47952. * @param element button element
  47953. * @param sessionMode XR initialization session mode
  47954. * @param referenceSpaceType the type of reference space to be used
  47955. */
  47956. constructor(
  47957. /** button element */
  47958. element: HTMLElement,
  47959. /** XR initialization options for the button */
  47960. sessionMode: XRSessionMode,
  47961. /** Reference space type */
  47962. referenceSpaceType: XRReferenceSpaceType);
  47963. /**
  47964. * Extendable function which can be used to update the button's visuals when the state changes
  47965. * @param activeButton the current active button in the UI
  47966. */
  47967. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47968. }
  47969. /**
  47970. * Options to create the webXR UI
  47971. */
  47972. export class WebXREnterExitUIOptions {
  47973. /**
  47974. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47975. */
  47976. customButtons?: Array<WebXREnterExitUIButton>;
  47977. /**
  47978. * A reference space type to use when creating the default button.
  47979. * Default is local-floor
  47980. */
  47981. referenceSpaceType?: XRReferenceSpaceType;
  47982. /**
  47983. * Context to enter xr with
  47984. */
  47985. renderTarget?: Nullable<WebXRRenderTarget>;
  47986. /**
  47987. * A session mode to use when creating the default button.
  47988. * Default is immersive-vr
  47989. */
  47990. sessionMode?: XRSessionMode;
  47991. /**
  47992. * A list of optional features to init the session with
  47993. */
  47994. optionalFeatures?: string[];
  47995. }
  47996. /**
  47997. * UI to allow the user to enter/exit XR mode
  47998. */
  47999. export class WebXREnterExitUI implements IDisposable {
  48000. private scene;
  48001. /** version of the options passed to this UI */
  48002. options: WebXREnterExitUIOptions;
  48003. private _activeButton;
  48004. private _buttons;
  48005. private _overlay;
  48006. /**
  48007. * Fired every time the active button is changed.
  48008. *
  48009. * When xr is entered via a button that launches xr that button will be the callback parameter
  48010. *
  48011. * When exiting xr the callback parameter will be null)
  48012. */
  48013. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48014. /**
  48015. *
  48016. * @param scene babylon scene object to use
  48017. * @param options (read-only) version of the options passed to this UI
  48018. */
  48019. private constructor();
  48020. /**
  48021. * Creates UI to allow the user to enter/exit XR mode
  48022. * @param scene the scene to add the ui to
  48023. * @param helper the xr experience helper to enter/exit xr with
  48024. * @param options options to configure the UI
  48025. * @returns the created ui
  48026. */
  48027. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48028. /**
  48029. * Disposes of the XR UI component
  48030. */
  48031. dispose(): void;
  48032. private _updateButtons;
  48033. }
  48034. }
  48035. declare module BABYLON {
  48036. /**
  48037. * Class containing static functions to help procedurally build meshes
  48038. */
  48039. export class LinesBuilder {
  48040. /**
  48041. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48042. * * 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
  48043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48044. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48045. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48046. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48047. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48048. * * 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
  48049. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48052. * @param name defines the name of the new line system
  48053. * @param options defines the options used to create the line system
  48054. * @param scene defines the hosting scene
  48055. * @returns a new line system mesh
  48056. */
  48057. static CreateLineSystem(name: string, options: {
  48058. lines: Vector3[][];
  48059. updatable?: boolean;
  48060. instance?: Nullable<LinesMesh>;
  48061. colors?: Nullable<Color4[][]>;
  48062. useVertexAlpha?: boolean;
  48063. }, scene: Nullable<Scene>): LinesMesh;
  48064. /**
  48065. * Creates a line mesh
  48066. * 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
  48067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48068. * * The parameter `points` is an array successive Vector3
  48069. * * 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
  48070. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48071. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48072. * * When updating an instance, remember that only point positions can change, not the number of points
  48073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48075. * @param name defines the name of the new line system
  48076. * @param options defines the options used to create the line system
  48077. * @param scene defines the hosting scene
  48078. * @returns a new line mesh
  48079. */
  48080. static CreateLines(name: string, options: {
  48081. points: Vector3[];
  48082. updatable?: boolean;
  48083. instance?: Nullable<LinesMesh>;
  48084. colors?: Color4[];
  48085. useVertexAlpha?: boolean;
  48086. }, scene?: Nullable<Scene>): LinesMesh;
  48087. /**
  48088. * Creates a dashed line mesh
  48089. * * 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
  48090. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48091. * * The parameter `points` is an array successive Vector3
  48092. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48093. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48094. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48095. * * 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
  48096. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48097. * * When updating an instance, remember that only point positions can change, not the number of points
  48098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48099. * @param name defines the name of the mesh
  48100. * @param options defines the options used to create the mesh
  48101. * @param scene defines the hosting scene
  48102. * @returns the dashed line mesh
  48103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48104. */
  48105. static CreateDashedLines(name: string, options: {
  48106. points: Vector3[];
  48107. dashSize?: number;
  48108. gapSize?: number;
  48109. dashNb?: number;
  48110. updatable?: boolean;
  48111. instance?: LinesMesh;
  48112. useVertexAlpha?: boolean;
  48113. }, scene?: Nullable<Scene>): LinesMesh;
  48114. }
  48115. }
  48116. declare module BABYLON {
  48117. /**
  48118. * Construction options for a timer
  48119. */
  48120. export interface ITimerOptions<T> {
  48121. /**
  48122. * Time-to-end
  48123. */
  48124. timeout: number;
  48125. /**
  48126. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48127. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48128. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48129. */
  48130. contextObservable: Observable<T>;
  48131. /**
  48132. * Optional parameters when adding an observer to the observable
  48133. */
  48134. observableParameters?: {
  48135. mask?: number;
  48136. insertFirst?: boolean;
  48137. scope?: any;
  48138. };
  48139. /**
  48140. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48141. */
  48142. breakCondition?: (data?: ITimerData<T>) => boolean;
  48143. /**
  48144. * Will be triggered when the time condition has met
  48145. */
  48146. onEnded?: (data: ITimerData<any>) => void;
  48147. /**
  48148. * Will be triggered when the break condition has met (prematurely ended)
  48149. */
  48150. onAborted?: (data: ITimerData<any>) => void;
  48151. /**
  48152. * Optional function to execute on each tick (or count)
  48153. */
  48154. onTick?: (data: ITimerData<any>) => void;
  48155. }
  48156. /**
  48157. * An interface defining the data sent by the timer
  48158. */
  48159. export interface ITimerData<T> {
  48160. /**
  48161. * When did it start
  48162. */
  48163. startTime: number;
  48164. /**
  48165. * Time now
  48166. */
  48167. currentTime: number;
  48168. /**
  48169. * Time passed since started
  48170. */
  48171. deltaTime: number;
  48172. /**
  48173. * How much is completed, in [0.0...1.0].
  48174. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48175. */
  48176. completeRate: number;
  48177. /**
  48178. * What the registered observable sent in the last count
  48179. */
  48180. payload: T;
  48181. }
  48182. /**
  48183. * The current state of the timer
  48184. */
  48185. export enum TimerState {
  48186. /**
  48187. * Timer initialized, not yet started
  48188. */
  48189. INIT = 0,
  48190. /**
  48191. * Timer started and counting
  48192. */
  48193. STARTED = 1,
  48194. /**
  48195. * Timer ended (whether aborted or time reached)
  48196. */
  48197. ENDED = 2
  48198. }
  48199. /**
  48200. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48201. *
  48202. * @param options options with which to initialize this timer
  48203. */
  48204. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48205. /**
  48206. * An advanced implementation of a timer class
  48207. */
  48208. export class AdvancedTimer<T = any> implements IDisposable {
  48209. /**
  48210. * Will notify each time the timer calculates the remaining time
  48211. */
  48212. onEachCountObservable: Observable<ITimerData<T>>;
  48213. /**
  48214. * Will trigger when the timer was aborted due to the break condition
  48215. */
  48216. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48217. /**
  48218. * Will trigger when the timer ended successfully
  48219. */
  48220. onTimerEndedObservable: Observable<ITimerData<T>>;
  48221. /**
  48222. * Will trigger when the timer state has changed
  48223. */
  48224. onStateChangedObservable: Observable<TimerState>;
  48225. private _observer;
  48226. private _contextObservable;
  48227. private _observableParameters;
  48228. private _startTime;
  48229. private _timer;
  48230. private _state;
  48231. private _breakCondition;
  48232. private _timeToEnd;
  48233. private _breakOnNextTick;
  48234. /**
  48235. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48236. * @param options construction options for this advanced timer
  48237. */
  48238. constructor(options: ITimerOptions<T>);
  48239. /**
  48240. * set a breaking condition for this timer. Default is to never break during count
  48241. * @param predicate the new break condition. Returns true to break, false otherwise
  48242. */
  48243. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48244. /**
  48245. * Reset ALL associated observables in this advanced timer
  48246. */
  48247. clearObservables(): void;
  48248. /**
  48249. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48250. *
  48251. * @param timeToEnd how much time to measure until timer ended
  48252. */
  48253. start(timeToEnd?: number): void;
  48254. /**
  48255. * Will force a stop on the next tick.
  48256. */
  48257. stop(): void;
  48258. /**
  48259. * Dispose this timer, clearing all resources
  48260. */
  48261. dispose(): void;
  48262. private _setState;
  48263. private _tick;
  48264. private _stop;
  48265. }
  48266. }
  48267. declare module BABYLON {
  48268. /**
  48269. * The options container for the teleportation module
  48270. */
  48271. export interface IWebXRTeleportationOptions {
  48272. /**
  48273. * if provided, this scene will be used to render meshes.
  48274. */
  48275. customUtilityLayerScene?: Scene;
  48276. /**
  48277. * Values to configure the default target mesh
  48278. */
  48279. defaultTargetMeshOptions?: {
  48280. /**
  48281. * Fill color of the teleportation area
  48282. */
  48283. teleportationFillColor?: string;
  48284. /**
  48285. * Border color for the teleportation area
  48286. */
  48287. teleportationBorderColor?: string;
  48288. /**
  48289. * Disable the mesh's animation sequence
  48290. */
  48291. disableAnimation?: boolean;
  48292. /**
  48293. * Disable lighting on the material or the ring and arrow
  48294. */
  48295. disableLighting?: boolean;
  48296. /**
  48297. * Override the default material of the torus and arrow
  48298. */
  48299. torusArrowMaterial?: Material;
  48300. };
  48301. /**
  48302. * A list of meshes to use as floor meshes.
  48303. * Meshes can be added and removed after initializing the feature using the
  48304. * addFloorMesh and removeFloorMesh functions
  48305. * If empty, rotation will still work
  48306. */
  48307. floorMeshes?: AbstractMesh[];
  48308. /**
  48309. * use this rendering group id for the meshes (optional)
  48310. */
  48311. renderingGroupId?: number;
  48312. /**
  48313. * Should teleportation move only to snap points
  48314. */
  48315. snapPointsOnly?: boolean;
  48316. /**
  48317. * An array of points to which the teleportation will snap to.
  48318. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48319. */
  48320. snapPositions?: Vector3[];
  48321. /**
  48322. * How close should the teleportation ray be in order to snap to position.
  48323. * Default to 0.8 units (meters)
  48324. */
  48325. snapToPositionRadius?: number;
  48326. /**
  48327. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48328. * If you want to support rotation, make sure your mesh has a direction indicator.
  48329. *
  48330. * When left untouched, the default mesh will be initialized.
  48331. */
  48332. teleportationTargetMesh?: AbstractMesh;
  48333. /**
  48334. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48335. */
  48336. timeToTeleport?: number;
  48337. /**
  48338. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48339. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48340. */
  48341. useMainComponentOnly?: boolean;
  48342. /**
  48343. * Should meshes created here be added to a utility layer or the main scene
  48344. */
  48345. useUtilityLayer?: boolean;
  48346. /**
  48347. * Babylon XR Input class for controller
  48348. */
  48349. xrInput: WebXRInput;
  48350. }
  48351. /**
  48352. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48353. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48354. * the input of the attached controllers.
  48355. */
  48356. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48357. private _options;
  48358. private _controllers;
  48359. private _currentTeleportationControllerId;
  48360. private _floorMeshes;
  48361. private _quadraticBezierCurve;
  48362. private _selectionFeature;
  48363. private _snapToPositions;
  48364. private _snappedToPoint;
  48365. private _teleportationRingMaterial?;
  48366. private _tmpRay;
  48367. private _tmpVector;
  48368. /**
  48369. * The module's name
  48370. */
  48371. static readonly Name: string;
  48372. /**
  48373. * The (Babylon) version of this module.
  48374. * This is an integer representing the implementation version.
  48375. * This number does not correspond to the webxr specs version
  48376. */
  48377. static readonly Version: number;
  48378. /**
  48379. * Is movement backwards enabled
  48380. */
  48381. backwardsMovementEnabled: boolean;
  48382. /**
  48383. * Distance to travel when moving backwards
  48384. */
  48385. backwardsTeleportationDistance: number;
  48386. /**
  48387. * The distance from the user to the inspection point in the direction of the controller
  48388. * A higher number will allow the user to move further
  48389. * defaults to 5 (meters, in xr units)
  48390. */
  48391. parabolicCheckRadius: number;
  48392. /**
  48393. * Should the module support parabolic ray on top of direct ray
  48394. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48395. * Very helpful when moving between floors / different heights
  48396. */
  48397. parabolicRayEnabled: boolean;
  48398. /**
  48399. * How much rotation should be applied when rotating right and left
  48400. */
  48401. rotationAngle: number;
  48402. /**
  48403. * Is rotation enabled when moving forward?
  48404. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48405. */
  48406. rotationEnabled: boolean;
  48407. /**
  48408. * constructs a new anchor system
  48409. * @param _xrSessionManager an instance of WebXRSessionManager
  48410. * @param _options configuration object for this feature
  48411. */
  48412. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48413. /**
  48414. * Get the snapPointsOnly flag
  48415. */
  48416. get snapPointsOnly(): boolean;
  48417. /**
  48418. * Sets the snapPointsOnly flag
  48419. * @param snapToPoints should teleportation be exclusively to snap points
  48420. */
  48421. set snapPointsOnly(snapToPoints: boolean);
  48422. /**
  48423. * Add a new mesh to the floor meshes array
  48424. * @param mesh the mesh to use as floor mesh
  48425. */
  48426. addFloorMesh(mesh: AbstractMesh): void;
  48427. /**
  48428. * Add a new snap-to point to fix teleportation to this position
  48429. * @param newSnapPoint The new Snap-To point
  48430. */
  48431. addSnapPoint(newSnapPoint: Vector3): void;
  48432. attach(): boolean;
  48433. detach(): boolean;
  48434. dispose(): void;
  48435. /**
  48436. * Remove a mesh from the floor meshes array
  48437. * @param mesh the mesh to remove
  48438. */
  48439. removeFloorMesh(mesh: AbstractMesh): void;
  48440. /**
  48441. * Remove a mesh from the floor meshes array using its name
  48442. * @param name the mesh name to remove
  48443. */
  48444. removeFloorMeshByName(name: string): void;
  48445. /**
  48446. * 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
  48447. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48448. * @returns was the point found and removed or not
  48449. */
  48450. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48451. /**
  48452. * This function sets a selection feature that will be disabled when
  48453. * the forward ray is shown and will be reattached when hidden.
  48454. * This is used to remove the selection rays when moving.
  48455. * @param selectionFeature the feature to disable when forward movement is enabled
  48456. */
  48457. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48458. protected _onXRFrame(_xrFrame: XRFrame): void;
  48459. private _attachController;
  48460. private _createDefaultTargetMesh;
  48461. private _detachController;
  48462. private _findClosestSnapPointWithRadius;
  48463. private _setTargetMeshPosition;
  48464. private _setTargetMeshVisibility;
  48465. private _showParabolicPath;
  48466. private _teleportForward;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * Options for the default xr helper
  48472. */
  48473. export class WebXRDefaultExperienceOptions {
  48474. /**
  48475. * Enable or disable default UI to enter XR
  48476. */
  48477. disableDefaultUI?: boolean;
  48478. /**
  48479. * Should teleportation not initialize. defaults to false.
  48480. */
  48481. disableTeleportation?: boolean;
  48482. /**
  48483. * Floor meshes that will be used for teleport
  48484. */
  48485. floorMeshes?: Array<AbstractMesh>;
  48486. /**
  48487. * If set to true, the first frame will not be used to reset position
  48488. * The first frame is mainly used when copying transformation from the old camera
  48489. * Mainly used in AR
  48490. */
  48491. ignoreNativeCameraTransformation?: boolean;
  48492. /**
  48493. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48494. */
  48495. inputOptions?: IWebXRInputOptions;
  48496. /**
  48497. * optional configuration for the output canvas
  48498. */
  48499. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48500. /**
  48501. * optional UI options. This can be used among other to change session mode and reference space type
  48502. */
  48503. uiOptions?: WebXREnterExitUIOptions;
  48504. /**
  48505. * When loading teleportation and pointer select, use stable versions instead of latest.
  48506. */
  48507. useStablePlugins?: boolean;
  48508. /**
  48509. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48510. */
  48511. renderingGroupId?: number;
  48512. /**
  48513. * A list of optional features to init the session with
  48514. * If set to true, all features we support will be added
  48515. */
  48516. optionalFeatures?: boolean | string[];
  48517. }
  48518. /**
  48519. * Default experience which provides a similar setup to the previous webVRExperience
  48520. */
  48521. export class WebXRDefaultExperience {
  48522. /**
  48523. * Base experience
  48524. */
  48525. baseExperience: WebXRExperienceHelper;
  48526. /**
  48527. * Enables ui for entering/exiting xr
  48528. */
  48529. enterExitUI: WebXREnterExitUI;
  48530. /**
  48531. * Input experience extension
  48532. */
  48533. input: WebXRInput;
  48534. /**
  48535. * Enables laser pointer and selection
  48536. */
  48537. pointerSelection: WebXRControllerPointerSelection;
  48538. /**
  48539. * Default target xr should render to
  48540. */
  48541. renderTarget: WebXRRenderTarget;
  48542. /**
  48543. * Enables teleportation
  48544. */
  48545. teleportation: WebXRMotionControllerTeleportation;
  48546. private constructor();
  48547. /**
  48548. * Creates the default xr experience
  48549. * @param scene scene
  48550. * @param options options for basic configuration
  48551. * @returns resulting WebXRDefaultExperience
  48552. */
  48553. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48554. /**
  48555. * DIsposes of the experience helper
  48556. */
  48557. dispose(): void;
  48558. }
  48559. }
  48560. declare module BABYLON {
  48561. /**
  48562. * Options to modify the vr teleportation behavior.
  48563. */
  48564. export interface VRTeleportationOptions {
  48565. /**
  48566. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48567. */
  48568. floorMeshName?: string;
  48569. /**
  48570. * A list of meshes to be used as the teleportation floor. (default: empty)
  48571. */
  48572. floorMeshes?: Mesh[];
  48573. /**
  48574. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48575. */
  48576. teleportationMode?: number;
  48577. /**
  48578. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48579. */
  48580. teleportationTime?: number;
  48581. /**
  48582. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48583. */
  48584. teleportationSpeed?: number;
  48585. /**
  48586. * The easing function used in the animation or null for Linear. (default CircleEase)
  48587. */
  48588. easingFunction?: EasingFunction;
  48589. }
  48590. /**
  48591. * Options to modify the vr experience helper's behavior.
  48592. */
  48593. export interface VRExperienceHelperOptions extends WebVROptions {
  48594. /**
  48595. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48596. */
  48597. createDeviceOrientationCamera?: boolean;
  48598. /**
  48599. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48600. */
  48601. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48602. /**
  48603. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48604. */
  48605. laserToggle?: boolean;
  48606. /**
  48607. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48608. */
  48609. floorMeshes?: Mesh[];
  48610. /**
  48611. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48612. */
  48613. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48614. /**
  48615. * Defines if WebXR should be used instead of WebVR (if available)
  48616. */
  48617. useXR?: boolean;
  48618. }
  48619. /**
  48620. * Event containing information after VR has been entered
  48621. */
  48622. export class OnAfterEnteringVRObservableEvent {
  48623. /**
  48624. * If entering vr was successful
  48625. */
  48626. success: boolean;
  48627. }
  48628. /**
  48629. * Helps to quickly add VR support to an existing scene.
  48630. * See http://doc.babylonjs.com/how_to/webvr_helper
  48631. */
  48632. export class VRExperienceHelper {
  48633. /** Options to modify the vr experience helper's behavior. */
  48634. webVROptions: VRExperienceHelperOptions;
  48635. private _scene;
  48636. private _position;
  48637. private _btnVR;
  48638. private _btnVRDisplayed;
  48639. private _webVRsupported;
  48640. private _webVRready;
  48641. private _webVRrequesting;
  48642. private _webVRpresenting;
  48643. private _hasEnteredVR;
  48644. private _fullscreenVRpresenting;
  48645. private _inputElement;
  48646. private _webVRCamera;
  48647. private _vrDeviceOrientationCamera;
  48648. private _deviceOrientationCamera;
  48649. private _existingCamera;
  48650. private _onKeyDown;
  48651. private _onVrDisplayPresentChange;
  48652. private _onVRDisplayChanged;
  48653. private _onVRRequestPresentStart;
  48654. private _onVRRequestPresentComplete;
  48655. /**
  48656. * 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)
  48657. */
  48658. enableGazeEvenWhenNoPointerLock: boolean;
  48659. /**
  48660. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48661. */
  48662. exitVROnDoubleTap: boolean;
  48663. /**
  48664. * Observable raised right before entering VR.
  48665. */
  48666. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48667. /**
  48668. * Observable raised when entering VR has completed.
  48669. */
  48670. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48671. /**
  48672. * Observable raised when exiting VR.
  48673. */
  48674. onExitingVRObservable: Observable<VRExperienceHelper>;
  48675. /**
  48676. * Observable raised when controller mesh is loaded.
  48677. */
  48678. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48679. /** Return this.onEnteringVRObservable
  48680. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48681. */
  48682. get onEnteringVR(): Observable<VRExperienceHelper>;
  48683. /** Return this.onExitingVRObservable
  48684. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48685. */
  48686. get onExitingVR(): Observable<VRExperienceHelper>;
  48687. /** Return this.onControllerMeshLoadedObservable
  48688. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48689. */
  48690. get onControllerMeshLoaded(): Observable<WebVRController>;
  48691. private _rayLength;
  48692. private _useCustomVRButton;
  48693. private _teleportationRequested;
  48694. private _teleportActive;
  48695. private _floorMeshName;
  48696. private _floorMeshesCollection;
  48697. private _teleportationMode;
  48698. private _teleportationTime;
  48699. private _teleportationSpeed;
  48700. private _teleportationEasing;
  48701. private _rotationAllowed;
  48702. private _teleportBackwardsVector;
  48703. private _teleportationTarget;
  48704. private _isDefaultTeleportationTarget;
  48705. private _postProcessMove;
  48706. private _teleportationFillColor;
  48707. private _teleportationBorderColor;
  48708. private _rotationAngle;
  48709. private _haloCenter;
  48710. private _cameraGazer;
  48711. private _padSensibilityUp;
  48712. private _padSensibilityDown;
  48713. private _leftController;
  48714. private _rightController;
  48715. private _gazeColor;
  48716. private _laserColor;
  48717. private _pickedLaserColor;
  48718. private _pickedGazeColor;
  48719. /**
  48720. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48721. */
  48722. onNewMeshSelected: Observable<AbstractMesh>;
  48723. /**
  48724. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48725. * This observable will provide the mesh and the controller used to select the mesh
  48726. */
  48727. onMeshSelectedWithController: Observable<{
  48728. mesh: AbstractMesh;
  48729. controller: WebVRController;
  48730. }>;
  48731. /**
  48732. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48733. */
  48734. onNewMeshPicked: Observable<PickingInfo>;
  48735. private _circleEase;
  48736. /**
  48737. * Observable raised before camera teleportation
  48738. */
  48739. onBeforeCameraTeleport: Observable<Vector3>;
  48740. /**
  48741. * Observable raised after camera teleportation
  48742. */
  48743. onAfterCameraTeleport: Observable<Vector3>;
  48744. /**
  48745. * Observable raised when current selected mesh gets unselected
  48746. */
  48747. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48748. private _raySelectionPredicate;
  48749. /**
  48750. * To be optionaly changed by user to define custom ray selection
  48751. */
  48752. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48753. /**
  48754. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48755. */
  48756. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48757. /**
  48758. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48759. */
  48760. teleportationEnabled: boolean;
  48761. private _defaultHeight;
  48762. private _teleportationInitialized;
  48763. private _interactionsEnabled;
  48764. private _interactionsRequested;
  48765. private _displayGaze;
  48766. private _displayLaserPointer;
  48767. /**
  48768. * The mesh used to display where the user is going to teleport.
  48769. */
  48770. get teleportationTarget(): Mesh;
  48771. /**
  48772. * Sets the mesh to be used to display where the user is going to teleport.
  48773. */
  48774. set teleportationTarget(value: Mesh);
  48775. /**
  48776. * 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
  48777. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48778. * See http://doc.babylonjs.com/resources/baking_transformations
  48779. */
  48780. get gazeTrackerMesh(): Mesh;
  48781. set gazeTrackerMesh(value: Mesh);
  48782. /**
  48783. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48784. */
  48785. updateGazeTrackerScale: boolean;
  48786. /**
  48787. * If the gaze trackers color should be updated when selecting meshes
  48788. */
  48789. updateGazeTrackerColor: boolean;
  48790. /**
  48791. * If the controller laser color should be updated when selecting meshes
  48792. */
  48793. updateControllerLaserColor: boolean;
  48794. /**
  48795. * The gaze tracking mesh corresponding to the left controller
  48796. */
  48797. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48798. /**
  48799. * The gaze tracking mesh corresponding to the right controller
  48800. */
  48801. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48802. /**
  48803. * If the ray of the gaze should be displayed.
  48804. */
  48805. get displayGaze(): boolean;
  48806. /**
  48807. * Sets if the ray of the gaze should be displayed.
  48808. */
  48809. set displayGaze(value: boolean);
  48810. /**
  48811. * If the ray of the LaserPointer should be displayed.
  48812. */
  48813. get displayLaserPointer(): boolean;
  48814. /**
  48815. * Sets if the ray of the LaserPointer should be displayed.
  48816. */
  48817. set displayLaserPointer(value: boolean);
  48818. /**
  48819. * The deviceOrientationCamera used as the camera when not in VR.
  48820. */
  48821. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48822. /**
  48823. * Based on the current WebVR support, returns the current VR camera used.
  48824. */
  48825. get currentVRCamera(): Nullable<Camera>;
  48826. /**
  48827. * The webVRCamera which is used when in VR.
  48828. */
  48829. get webVRCamera(): WebVRFreeCamera;
  48830. /**
  48831. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48832. */
  48833. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48834. /**
  48835. * The html button that is used to trigger entering into VR.
  48836. */
  48837. get vrButton(): Nullable<HTMLButtonElement>;
  48838. private get _teleportationRequestInitiated();
  48839. /**
  48840. * Defines whether or not Pointer lock should be requested when switching to
  48841. * full screen.
  48842. */
  48843. requestPointerLockOnFullScreen: boolean;
  48844. /**
  48845. * If asking to force XR, this will be populated with the default xr experience
  48846. */
  48847. xr: WebXRDefaultExperience;
  48848. /**
  48849. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48850. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48851. */
  48852. xrTestDone: boolean;
  48853. /**
  48854. * Instantiates a VRExperienceHelper.
  48855. * Helps to quickly add VR support to an existing scene.
  48856. * @param scene The scene the VRExperienceHelper belongs to.
  48857. * @param webVROptions Options to modify the vr experience helper's behavior.
  48858. */
  48859. constructor(scene: Scene,
  48860. /** Options to modify the vr experience helper's behavior. */
  48861. webVROptions?: VRExperienceHelperOptions);
  48862. private completeVRInit;
  48863. private _onDefaultMeshLoaded;
  48864. private _onResize;
  48865. private _onFullscreenChange;
  48866. /**
  48867. * Gets a value indicating if we are currently in VR mode.
  48868. */
  48869. get isInVRMode(): boolean;
  48870. private onVrDisplayPresentChange;
  48871. private onVRDisplayChanged;
  48872. private moveButtonToBottomRight;
  48873. private displayVRButton;
  48874. private updateButtonVisibility;
  48875. private _cachedAngularSensibility;
  48876. /**
  48877. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48878. * Otherwise, will use the fullscreen API.
  48879. */
  48880. enterVR(): void;
  48881. /**
  48882. * Attempt to exit VR, or fullscreen.
  48883. */
  48884. exitVR(): void;
  48885. /**
  48886. * The position of the vr experience helper.
  48887. */
  48888. get position(): Vector3;
  48889. /**
  48890. * Sets the position of the vr experience helper.
  48891. */
  48892. set position(value: Vector3);
  48893. /**
  48894. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48895. */
  48896. enableInteractions(): void;
  48897. private get _noControllerIsActive();
  48898. private beforeRender;
  48899. private _isTeleportationFloor;
  48900. /**
  48901. * Adds a floor mesh to be used for teleportation.
  48902. * @param floorMesh the mesh to be used for teleportation.
  48903. */
  48904. addFloorMesh(floorMesh: Mesh): void;
  48905. /**
  48906. * Removes a floor mesh from being used for teleportation.
  48907. * @param floorMesh the mesh to be removed.
  48908. */
  48909. removeFloorMesh(floorMesh: Mesh): void;
  48910. /**
  48911. * Enables interactions and teleportation using the VR controllers and gaze.
  48912. * @param vrTeleportationOptions options to modify teleportation behavior.
  48913. */
  48914. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48915. private _onNewGamepadConnected;
  48916. private _tryEnableInteractionOnController;
  48917. private _onNewGamepadDisconnected;
  48918. private _enableInteractionOnController;
  48919. private _checkTeleportWithRay;
  48920. private _checkRotate;
  48921. private _checkTeleportBackwards;
  48922. private _enableTeleportationOnController;
  48923. private _createTeleportationCircles;
  48924. private _displayTeleportationTarget;
  48925. private _hideTeleportationTarget;
  48926. private _rotateCamera;
  48927. private _moveTeleportationSelectorTo;
  48928. private _workingVector;
  48929. private _workingQuaternion;
  48930. private _workingMatrix;
  48931. /**
  48932. * Time Constant Teleportation Mode
  48933. */
  48934. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48935. /**
  48936. * Speed Constant Teleportation Mode
  48937. */
  48938. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48939. /**
  48940. * Teleports the users feet to the desired location
  48941. * @param location The location where the user's feet should be placed
  48942. */
  48943. teleportCamera(location: Vector3): void;
  48944. private _convertNormalToDirectionOfRay;
  48945. private _castRayAndSelectObject;
  48946. private _notifySelectedMeshUnselected;
  48947. /**
  48948. * Permanently set new colors for the laser pointer
  48949. * @param color the new laser color
  48950. * @param pickedColor the new laser color when picked mesh detected
  48951. */
  48952. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48953. /**
  48954. * Set lighting enabled / disabled on the laser pointer of both controllers
  48955. * @param enabled should the lighting be enabled on the laser pointer
  48956. */
  48957. setLaserLightingState(enabled?: boolean): void;
  48958. /**
  48959. * Permanently set new colors for the gaze pointer
  48960. * @param color the new gaze color
  48961. * @param pickedColor the new gaze color when picked mesh detected
  48962. */
  48963. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48964. /**
  48965. * Sets the color of the laser ray from the vr controllers.
  48966. * @param color new color for the ray.
  48967. */
  48968. changeLaserColor(color: Color3): void;
  48969. /**
  48970. * Sets the color of the ray from the vr headsets gaze.
  48971. * @param color new color for the ray.
  48972. */
  48973. changeGazeColor(color: Color3): void;
  48974. /**
  48975. * Exits VR and disposes of the vr experience helper
  48976. */
  48977. dispose(): void;
  48978. /**
  48979. * Gets the name of the VRExperienceHelper class
  48980. * @returns "VRExperienceHelper"
  48981. */
  48982. getClassName(): string;
  48983. }
  48984. }
  48985. declare module BABYLON {
  48986. /**
  48987. * Contains an array of blocks representing the octree
  48988. */
  48989. export interface IOctreeContainer<T> {
  48990. /**
  48991. * Blocks within the octree
  48992. */
  48993. blocks: Array<OctreeBlock<T>>;
  48994. }
  48995. /**
  48996. * Class used to store a cell in an octree
  48997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48998. */
  48999. export class OctreeBlock<T> {
  49000. /**
  49001. * Gets the content of the current block
  49002. */
  49003. entries: T[];
  49004. /**
  49005. * Gets the list of block children
  49006. */
  49007. blocks: Array<OctreeBlock<T>>;
  49008. private _depth;
  49009. private _maxDepth;
  49010. private _capacity;
  49011. private _minPoint;
  49012. private _maxPoint;
  49013. private _boundingVectors;
  49014. private _creationFunc;
  49015. /**
  49016. * Creates a new block
  49017. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49018. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49019. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49020. * @param depth defines the current depth of this block in the octree
  49021. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49022. * @param creationFunc defines a callback to call when an element is added to the block
  49023. */
  49024. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49025. /**
  49026. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49027. */
  49028. get capacity(): number;
  49029. /**
  49030. * Gets the minimum vector (in world space) of the block's bounding box
  49031. */
  49032. get minPoint(): Vector3;
  49033. /**
  49034. * Gets the maximum vector (in world space) of the block's bounding box
  49035. */
  49036. get maxPoint(): Vector3;
  49037. /**
  49038. * Add a new element to this block
  49039. * @param entry defines the element to add
  49040. */
  49041. addEntry(entry: T): void;
  49042. /**
  49043. * Remove an element from this block
  49044. * @param entry defines the element to remove
  49045. */
  49046. removeEntry(entry: T): void;
  49047. /**
  49048. * Add an array of elements to this block
  49049. * @param entries defines the array of elements to add
  49050. */
  49051. addEntries(entries: T[]): void;
  49052. /**
  49053. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49054. * @param frustumPlanes defines the frustum planes to test
  49055. * @param selection defines the array to store current content if selection is positive
  49056. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49057. */
  49058. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49059. /**
  49060. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49061. * @param sphereCenter defines the bounding sphere center
  49062. * @param sphereRadius defines the bounding sphere radius
  49063. * @param selection defines the array to store current content if selection is positive
  49064. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49065. */
  49066. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49067. /**
  49068. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49069. * @param ray defines the ray to test with
  49070. * @param selection defines the array to store current content if selection is positive
  49071. */
  49072. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49073. /**
  49074. * Subdivide the content into child blocks (this block will then be empty)
  49075. */
  49076. createInnerBlocks(): void;
  49077. /**
  49078. * @hidden
  49079. */
  49080. 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;
  49081. }
  49082. }
  49083. declare module BABYLON {
  49084. /**
  49085. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49086. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49087. */
  49088. export class Octree<T> {
  49089. /** 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.) */
  49090. maxDepth: number;
  49091. /**
  49092. * Blocks within the octree containing objects
  49093. */
  49094. blocks: Array<OctreeBlock<T>>;
  49095. /**
  49096. * Content stored in the octree
  49097. */
  49098. dynamicContent: T[];
  49099. private _maxBlockCapacity;
  49100. private _selectionContent;
  49101. private _creationFunc;
  49102. /**
  49103. * Creates a octree
  49104. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49105. * @param creationFunc function to be used to instatiate the octree
  49106. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49107. * @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.)
  49108. */
  49109. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49110. /** 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.) */
  49111. maxDepth?: number);
  49112. /**
  49113. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49114. * @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);
  49115. * @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);
  49116. * @param entries meshes to be added to the octree blocks
  49117. */
  49118. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49119. /**
  49120. * Adds a mesh to the octree
  49121. * @param entry Mesh to add to the octree
  49122. */
  49123. addMesh(entry: T): void;
  49124. /**
  49125. * Remove an element from the octree
  49126. * @param entry defines the element to remove
  49127. */
  49128. removeMesh(entry: T): void;
  49129. /**
  49130. * Selects an array of meshes within the frustum
  49131. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49132. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49133. * @returns array of meshes within the frustum
  49134. */
  49135. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49136. /**
  49137. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49138. * @param sphereCenter defines the bounding sphere center
  49139. * @param sphereRadius defines the bounding sphere radius
  49140. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49141. * @returns an array of objects that intersect the sphere
  49142. */
  49143. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49144. /**
  49145. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49146. * @param ray defines the ray to test with
  49147. * @returns array of intersected objects
  49148. */
  49149. intersectsRay(ray: Ray): SmartArray<T>;
  49150. /**
  49151. * Adds a mesh into the octree block if it intersects the block
  49152. */
  49153. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49154. /**
  49155. * Adds a submesh into the octree block if it intersects the block
  49156. */
  49157. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49158. }
  49159. }
  49160. declare module BABYLON {
  49161. interface Scene {
  49162. /**
  49163. * @hidden
  49164. * Backing Filed
  49165. */
  49166. _selectionOctree: Octree<AbstractMesh>;
  49167. /**
  49168. * Gets the octree used to boost mesh selection (picking)
  49169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49170. */
  49171. selectionOctree: Octree<AbstractMesh>;
  49172. /**
  49173. * Creates or updates the octree used to boost selection (picking)
  49174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49175. * @param maxCapacity defines the maximum capacity per leaf
  49176. * @param maxDepth defines the maximum depth of the octree
  49177. * @returns an octree of AbstractMesh
  49178. */
  49179. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49180. }
  49181. interface AbstractMesh {
  49182. /**
  49183. * @hidden
  49184. * Backing Field
  49185. */
  49186. _submeshesOctree: Octree<SubMesh>;
  49187. /**
  49188. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49189. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49190. * @param maxCapacity defines the maximum size of each block (64 by default)
  49191. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49192. * @returns the new octree
  49193. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49195. */
  49196. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49197. }
  49198. /**
  49199. * Defines the octree scene component responsible to manage any octrees
  49200. * in a given scene.
  49201. */
  49202. export class OctreeSceneComponent {
  49203. /**
  49204. * The component name help to identify the component in the list of scene components.
  49205. */
  49206. readonly name: string;
  49207. /**
  49208. * The scene the component belongs to.
  49209. */
  49210. scene: Scene;
  49211. /**
  49212. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49213. */
  49214. readonly checksIsEnabled: boolean;
  49215. /**
  49216. * Creates a new instance of the component for the given scene
  49217. * @param scene Defines the scene to register the component in
  49218. */
  49219. constructor(scene: Scene);
  49220. /**
  49221. * Registers the component in a given scene
  49222. */
  49223. register(): void;
  49224. /**
  49225. * Return the list of active meshes
  49226. * @returns the list of active meshes
  49227. */
  49228. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49229. /**
  49230. * Return the list of active sub meshes
  49231. * @param mesh The mesh to get the candidates sub meshes from
  49232. * @returns the list of active sub meshes
  49233. */
  49234. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49235. private _tempRay;
  49236. /**
  49237. * Return the list of sub meshes intersecting with a given local ray
  49238. * @param mesh defines the mesh to find the submesh for
  49239. * @param localRay defines the ray in local space
  49240. * @returns the list of intersecting sub meshes
  49241. */
  49242. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49243. /**
  49244. * Return the list of sub meshes colliding with a collider
  49245. * @param mesh defines the mesh to find the submesh for
  49246. * @param collider defines the collider to evaluate the collision against
  49247. * @returns the list of colliding sub meshes
  49248. */
  49249. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49250. /**
  49251. * Rebuilds the elements related to this component in case of
  49252. * context lost for instance.
  49253. */
  49254. rebuild(): void;
  49255. /**
  49256. * Disposes the component and the associated ressources.
  49257. */
  49258. dispose(): void;
  49259. }
  49260. }
  49261. declare module BABYLON {
  49262. /**
  49263. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49264. */
  49265. export class Gizmo implements IDisposable {
  49266. /** The utility layer the gizmo will be added to */
  49267. gizmoLayer: UtilityLayerRenderer;
  49268. /**
  49269. * The root mesh of the gizmo
  49270. */
  49271. _rootMesh: Mesh;
  49272. private _attachedMesh;
  49273. /**
  49274. * Ratio for the scale of the gizmo (Default: 1)
  49275. */
  49276. scaleRatio: number;
  49277. /**
  49278. * If a custom mesh has been set (Default: false)
  49279. */
  49280. protected _customMeshSet: boolean;
  49281. /**
  49282. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49283. * * When set, interactions will be enabled
  49284. */
  49285. get attachedMesh(): Nullable<AbstractMesh>;
  49286. set attachedMesh(value: Nullable<AbstractMesh>);
  49287. /**
  49288. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49289. * @param mesh The mesh to replace the default mesh of the gizmo
  49290. */
  49291. setCustomMesh(mesh: Mesh): void;
  49292. /**
  49293. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49294. */
  49295. updateGizmoRotationToMatchAttachedMesh: boolean;
  49296. /**
  49297. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49298. */
  49299. updateGizmoPositionToMatchAttachedMesh: boolean;
  49300. /**
  49301. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49302. */
  49303. updateScale: boolean;
  49304. protected _interactionsEnabled: boolean;
  49305. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49306. private _beforeRenderObserver;
  49307. private _tempVector;
  49308. /**
  49309. * Creates a gizmo
  49310. * @param gizmoLayer The utility layer the gizmo will be added to
  49311. */
  49312. constructor(
  49313. /** The utility layer the gizmo will be added to */
  49314. gizmoLayer?: UtilityLayerRenderer);
  49315. /**
  49316. * Updates the gizmo to match the attached mesh's position/rotation
  49317. */
  49318. protected _update(): void;
  49319. /**
  49320. * Disposes of the gizmo
  49321. */
  49322. dispose(): void;
  49323. }
  49324. }
  49325. declare module BABYLON {
  49326. /**
  49327. * Single plane drag gizmo
  49328. */
  49329. export class PlaneDragGizmo extends Gizmo {
  49330. /**
  49331. * Drag behavior responsible for the gizmos dragging interactions
  49332. */
  49333. dragBehavior: PointerDragBehavior;
  49334. private _pointerObserver;
  49335. /**
  49336. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49337. */
  49338. snapDistance: number;
  49339. /**
  49340. * Event that fires each time the gizmo snaps to a new location.
  49341. * * snapDistance is the the change in distance
  49342. */
  49343. onSnapObservable: Observable<{
  49344. snapDistance: number;
  49345. }>;
  49346. private _plane;
  49347. private _coloredMaterial;
  49348. private _hoverMaterial;
  49349. private _isEnabled;
  49350. private _parent;
  49351. /** @hidden */
  49352. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49353. /** @hidden */
  49354. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49355. /**
  49356. * Creates a PlaneDragGizmo
  49357. * @param gizmoLayer The utility layer the gizmo will be added to
  49358. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49359. * @param color The color of the gizmo
  49360. */
  49361. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49362. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49363. /**
  49364. * If the gizmo is enabled
  49365. */
  49366. set isEnabled(value: boolean);
  49367. get isEnabled(): boolean;
  49368. /**
  49369. * Disposes of the gizmo
  49370. */
  49371. dispose(): void;
  49372. }
  49373. }
  49374. declare module BABYLON {
  49375. /**
  49376. * Gizmo that enables dragging a mesh along 3 axis
  49377. */
  49378. export class PositionGizmo extends Gizmo {
  49379. /**
  49380. * Internal gizmo used for interactions on the x axis
  49381. */
  49382. xGizmo: AxisDragGizmo;
  49383. /**
  49384. * Internal gizmo used for interactions on the y axis
  49385. */
  49386. yGizmo: AxisDragGizmo;
  49387. /**
  49388. * Internal gizmo used for interactions on the z axis
  49389. */
  49390. zGizmo: AxisDragGizmo;
  49391. /**
  49392. * Internal gizmo used for interactions on the yz plane
  49393. */
  49394. xPlaneGizmo: PlaneDragGizmo;
  49395. /**
  49396. * Internal gizmo used for interactions on the xz plane
  49397. */
  49398. yPlaneGizmo: PlaneDragGizmo;
  49399. /**
  49400. * Internal gizmo used for interactions on the xy plane
  49401. */
  49402. zPlaneGizmo: PlaneDragGizmo;
  49403. /**
  49404. * private variables
  49405. */
  49406. private _meshAttached;
  49407. private _updateGizmoRotationToMatchAttachedMesh;
  49408. private _snapDistance;
  49409. private _scaleRatio;
  49410. /** Fires an event when any of it's sub gizmos are dragged */
  49411. onDragStartObservable: Observable<unknown>;
  49412. /** Fires an event when any of it's sub gizmos are released from dragging */
  49413. onDragEndObservable: Observable<unknown>;
  49414. /**
  49415. * If set to true, planar drag is enabled
  49416. */
  49417. private _planarGizmoEnabled;
  49418. get attachedMesh(): Nullable<AbstractMesh>;
  49419. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49420. /**
  49421. * Creates a PositionGizmo
  49422. * @param gizmoLayer The utility layer the gizmo will be added to
  49423. */
  49424. constructor(gizmoLayer?: UtilityLayerRenderer);
  49425. /**
  49426. * If the planar drag gizmo is enabled
  49427. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49428. */
  49429. set planarGizmoEnabled(value: boolean);
  49430. get planarGizmoEnabled(): boolean;
  49431. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49432. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49433. /**
  49434. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49435. */
  49436. set snapDistance(value: number);
  49437. get snapDistance(): number;
  49438. /**
  49439. * Ratio for the scale of the gizmo (Default: 1)
  49440. */
  49441. set scaleRatio(value: number);
  49442. get scaleRatio(): number;
  49443. /**
  49444. * Disposes of the gizmo
  49445. */
  49446. dispose(): void;
  49447. /**
  49448. * CustomMeshes are not supported by this gizmo
  49449. * @param mesh The mesh to replace the default mesh of the gizmo
  49450. */
  49451. setCustomMesh(mesh: Mesh): void;
  49452. }
  49453. }
  49454. declare module BABYLON {
  49455. /**
  49456. * Single axis drag gizmo
  49457. */
  49458. export class AxisDragGizmo extends Gizmo {
  49459. /**
  49460. * Drag behavior responsible for the gizmos dragging interactions
  49461. */
  49462. dragBehavior: PointerDragBehavior;
  49463. private _pointerObserver;
  49464. /**
  49465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49466. */
  49467. snapDistance: number;
  49468. /**
  49469. * Event that fires each time the gizmo snaps to a new location.
  49470. * * snapDistance is the the change in distance
  49471. */
  49472. onSnapObservable: Observable<{
  49473. snapDistance: number;
  49474. }>;
  49475. private _isEnabled;
  49476. private _parent;
  49477. private _arrow;
  49478. private _coloredMaterial;
  49479. private _hoverMaterial;
  49480. /** @hidden */
  49481. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49482. /** @hidden */
  49483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49484. /**
  49485. * Creates an AxisDragGizmo
  49486. * @param gizmoLayer The utility layer the gizmo will be added to
  49487. * @param dragAxis The axis which the gizmo will be able to drag on
  49488. * @param color The color of the gizmo
  49489. */
  49490. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49492. /**
  49493. * If the gizmo is enabled
  49494. */
  49495. set isEnabled(value: boolean);
  49496. get isEnabled(): boolean;
  49497. /**
  49498. * Disposes of the gizmo
  49499. */
  49500. dispose(): void;
  49501. }
  49502. }
  49503. declare module BABYLON.Debug {
  49504. /**
  49505. * The Axes viewer will show 3 axes in a specific point in space
  49506. */
  49507. export class AxesViewer {
  49508. private _xAxis;
  49509. private _yAxis;
  49510. private _zAxis;
  49511. private _scaleLinesFactor;
  49512. private _instanced;
  49513. /**
  49514. * Gets the hosting scene
  49515. */
  49516. scene: Scene;
  49517. /**
  49518. * Gets or sets a number used to scale line length
  49519. */
  49520. scaleLines: number;
  49521. /** Gets the node hierarchy used to render x-axis */
  49522. get xAxis(): TransformNode;
  49523. /** Gets the node hierarchy used to render y-axis */
  49524. get yAxis(): TransformNode;
  49525. /** Gets the node hierarchy used to render z-axis */
  49526. get zAxis(): TransformNode;
  49527. /**
  49528. * Creates a new AxesViewer
  49529. * @param scene defines the hosting scene
  49530. * @param scaleLines defines a number used to scale line length (1 by default)
  49531. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49532. * @param xAxis defines the node hierarchy used to render the x-axis
  49533. * @param yAxis defines the node hierarchy used to render the y-axis
  49534. * @param zAxis defines the node hierarchy used to render the z-axis
  49535. */
  49536. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49537. /**
  49538. * Force the viewer to update
  49539. * @param position defines the position of the viewer
  49540. * @param xaxis defines the x axis of the viewer
  49541. * @param yaxis defines the y axis of the viewer
  49542. * @param zaxis defines the z axis of the viewer
  49543. */
  49544. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49545. /**
  49546. * Creates an instance of this axes viewer.
  49547. * @returns a new axes viewer with instanced meshes
  49548. */
  49549. createInstance(): AxesViewer;
  49550. /** Releases resources */
  49551. dispose(): void;
  49552. private static _SetRenderingGroupId;
  49553. }
  49554. }
  49555. declare module BABYLON.Debug {
  49556. /**
  49557. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49558. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49559. */
  49560. export class BoneAxesViewer extends AxesViewer {
  49561. /**
  49562. * Gets or sets the target mesh where to display the axes viewer
  49563. */
  49564. mesh: Nullable<Mesh>;
  49565. /**
  49566. * Gets or sets the target bone where to display the axes viewer
  49567. */
  49568. bone: Nullable<Bone>;
  49569. /** Gets current position */
  49570. pos: Vector3;
  49571. /** Gets direction of X axis */
  49572. xaxis: Vector3;
  49573. /** Gets direction of Y axis */
  49574. yaxis: Vector3;
  49575. /** Gets direction of Z axis */
  49576. zaxis: Vector3;
  49577. /**
  49578. * Creates a new BoneAxesViewer
  49579. * @param scene defines the hosting scene
  49580. * @param bone defines the target bone
  49581. * @param mesh defines the target mesh
  49582. * @param scaleLines defines a scaling factor for line length (1 by default)
  49583. */
  49584. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49585. /**
  49586. * Force the viewer to update
  49587. */
  49588. update(): void;
  49589. /** Releases resources */
  49590. dispose(): void;
  49591. }
  49592. }
  49593. declare module BABYLON {
  49594. /**
  49595. * Interface used to define scene explorer extensibility option
  49596. */
  49597. export interface IExplorerExtensibilityOption {
  49598. /**
  49599. * Define the option label
  49600. */
  49601. label: string;
  49602. /**
  49603. * Defines the action to execute on click
  49604. */
  49605. action: (entity: any) => void;
  49606. }
  49607. /**
  49608. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49609. */
  49610. export interface IExplorerExtensibilityGroup {
  49611. /**
  49612. * Defines a predicate to test if a given type mut be extended
  49613. */
  49614. predicate: (entity: any) => boolean;
  49615. /**
  49616. * Gets the list of options added to a type
  49617. */
  49618. entries: IExplorerExtensibilityOption[];
  49619. }
  49620. /**
  49621. * Interface used to define the options to use to create the Inspector
  49622. */
  49623. export interface IInspectorOptions {
  49624. /**
  49625. * Display in overlay mode (default: false)
  49626. */
  49627. overlay?: boolean;
  49628. /**
  49629. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49630. */
  49631. globalRoot?: HTMLElement;
  49632. /**
  49633. * Display the Scene explorer
  49634. */
  49635. showExplorer?: boolean;
  49636. /**
  49637. * Display the property inspector
  49638. */
  49639. showInspector?: boolean;
  49640. /**
  49641. * Display in embed mode (both panes on the right)
  49642. */
  49643. embedMode?: boolean;
  49644. /**
  49645. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49646. */
  49647. handleResize?: boolean;
  49648. /**
  49649. * Allow the panes to popup (default: true)
  49650. */
  49651. enablePopup?: boolean;
  49652. /**
  49653. * Allow the panes to be closed by users (default: true)
  49654. */
  49655. enableClose?: boolean;
  49656. /**
  49657. * Optional list of extensibility entries
  49658. */
  49659. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49660. /**
  49661. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49662. */
  49663. inspectorURL?: string;
  49664. /**
  49665. * Optional initial tab (default to DebugLayerTab.Properties)
  49666. */
  49667. initialTab?: DebugLayerTab;
  49668. }
  49669. interface Scene {
  49670. /**
  49671. * @hidden
  49672. * Backing field
  49673. */
  49674. _debugLayer: DebugLayer;
  49675. /**
  49676. * Gets the debug layer (aka Inspector) associated with the scene
  49677. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49678. */
  49679. debugLayer: DebugLayer;
  49680. }
  49681. /**
  49682. * Enum of inspector action tab
  49683. */
  49684. export enum DebugLayerTab {
  49685. /**
  49686. * Properties tag (default)
  49687. */
  49688. Properties = 0,
  49689. /**
  49690. * Debug tab
  49691. */
  49692. Debug = 1,
  49693. /**
  49694. * Statistics tab
  49695. */
  49696. Statistics = 2,
  49697. /**
  49698. * Tools tab
  49699. */
  49700. Tools = 3,
  49701. /**
  49702. * Settings tab
  49703. */
  49704. Settings = 4
  49705. }
  49706. /**
  49707. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49708. * what is happening in your scene
  49709. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49710. */
  49711. export class DebugLayer {
  49712. /**
  49713. * Define the url to get the inspector script from.
  49714. * By default it uses the babylonjs CDN.
  49715. * @ignoreNaming
  49716. */
  49717. static InspectorURL: string;
  49718. private _scene;
  49719. private BJSINSPECTOR;
  49720. private _onPropertyChangedObservable?;
  49721. /**
  49722. * Observable triggered when a property is changed through the inspector.
  49723. */
  49724. get onPropertyChangedObservable(): any;
  49725. /**
  49726. * Instantiates a new debug layer.
  49727. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49728. * what is happening in your scene
  49729. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49730. * @param scene Defines the scene to inspect
  49731. */
  49732. constructor(scene: Scene);
  49733. /** Creates the inspector window. */
  49734. private _createInspector;
  49735. /**
  49736. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49737. * @param entity defines the entity to select
  49738. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49739. */
  49740. select(entity: any, lineContainerTitles?: string | string[]): void;
  49741. /** Get the inspector from bundle or global */
  49742. private _getGlobalInspector;
  49743. /**
  49744. * Get if the inspector is visible or not.
  49745. * @returns true if visible otherwise, false
  49746. */
  49747. isVisible(): boolean;
  49748. /**
  49749. * Hide the inspector and close its window.
  49750. */
  49751. hide(): void;
  49752. /**
  49753. * Update the scene in the inspector
  49754. */
  49755. setAsActiveScene(): void;
  49756. /**
  49757. * Launch the debugLayer.
  49758. * @param config Define the configuration of the inspector
  49759. * @return a promise fulfilled when the debug layer is visible
  49760. */
  49761. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49762. }
  49763. }
  49764. declare module BABYLON {
  49765. /**
  49766. * Class containing static functions to help procedurally build meshes
  49767. */
  49768. export class BoxBuilder {
  49769. /**
  49770. * Creates a box mesh
  49771. * * The parameter `size` sets the size (float) of each box side (default 1)
  49772. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49773. * * 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)
  49774. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49776. * * 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
  49777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49778. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49779. * @param name defines the name of the mesh
  49780. * @param options defines the options used to create the mesh
  49781. * @param scene defines the hosting scene
  49782. * @returns the box mesh
  49783. */
  49784. static CreateBox(name: string, options: {
  49785. size?: number;
  49786. width?: number;
  49787. height?: number;
  49788. depth?: number;
  49789. faceUV?: Vector4[];
  49790. faceColors?: Color4[];
  49791. sideOrientation?: number;
  49792. frontUVs?: Vector4;
  49793. backUVs?: Vector4;
  49794. wrap?: boolean;
  49795. topBaseAt?: number;
  49796. bottomBaseAt?: number;
  49797. updatable?: boolean;
  49798. }, scene?: Nullable<Scene>): Mesh;
  49799. }
  49800. }
  49801. declare module BABYLON.Debug {
  49802. /**
  49803. * Used to show the physics impostor around the specific mesh
  49804. */
  49805. export class PhysicsViewer {
  49806. /** @hidden */
  49807. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49808. /** @hidden */
  49809. protected _meshes: Array<Nullable<AbstractMesh>>;
  49810. /** @hidden */
  49811. protected _scene: Nullable<Scene>;
  49812. /** @hidden */
  49813. protected _numMeshes: number;
  49814. /** @hidden */
  49815. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49816. private _renderFunction;
  49817. private _utilityLayer;
  49818. private _debugBoxMesh;
  49819. private _debugSphereMesh;
  49820. private _debugCylinderMesh;
  49821. private _debugMaterial;
  49822. private _debugMeshMeshes;
  49823. /**
  49824. * Creates a new PhysicsViewer
  49825. * @param scene defines the hosting scene
  49826. */
  49827. constructor(scene: Scene);
  49828. /** @hidden */
  49829. protected _updateDebugMeshes(): void;
  49830. /**
  49831. * Renders a specified physic impostor
  49832. * @param impostor defines the impostor to render
  49833. * @param targetMesh defines the mesh represented by the impostor
  49834. * @returns the new debug mesh used to render the impostor
  49835. */
  49836. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49837. /**
  49838. * Hides a specified physic impostor
  49839. * @param impostor defines the impostor to hide
  49840. */
  49841. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49842. private _getDebugMaterial;
  49843. private _getDebugBoxMesh;
  49844. private _getDebugSphereMesh;
  49845. private _getDebugCylinderMesh;
  49846. private _getDebugMeshMesh;
  49847. private _getDebugMesh;
  49848. /** Releases all resources */
  49849. dispose(): void;
  49850. }
  49851. }
  49852. declare module BABYLON {
  49853. /**
  49854. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49855. * in order to better appreciate the issue one might have.
  49856. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49857. */
  49858. export class RayHelper {
  49859. /**
  49860. * Defines the ray we are currently tryin to visualize.
  49861. */
  49862. ray: Nullable<Ray>;
  49863. private _renderPoints;
  49864. private _renderLine;
  49865. private _renderFunction;
  49866. private _scene;
  49867. private _updateToMeshFunction;
  49868. private _attachedToMesh;
  49869. private _meshSpaceDirection;
  49870. private _meshSpaceOrigin;
  49871. /**
  49872. * Helper function to create a colored helper in a scene in one line.
  49873. * @param ray Defines the ray we are currently tryin to visualize
  49874. * @param scene Defines the scene the ray is used in
  49875. * @param color Defines the color we want to see the ray in
  49876. * @returns The newly created ray helper.
  49877. */
  49878. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49879. /**
  49880. * Instantiate a new ray helper.
  49881. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49882. * in order to better appreciate the issue one might have.
  49883. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49884. * @param ray Defines the ray we are currently tryin to visualize
  49885. */
  49886. constructor(ray: Ray);
  49887. /**
  49888. * Shows the ray we are willing to debug.
  49889. * @param scene Defines the scene the ray needs to be rendered in
  49890. * @param color Defines the color the ray needs to be rendered in
  49891. */
  49892. show(scene: Scene, color?: Color3): void;
  49893. /**
  49894. * Hides the ray we are debugging.
  49895. */
  49896. hide(): void;
  49897. private _render;
  49898. /**
  49899. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49900. * @param mesh Defines the mesh we want the helper attached to
  49901. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49902. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49903. * @param length Defines the length of the ray
  49904. */
  49905. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49906. /**
  49907. * Detach the ray helper from the mesh it has previously been attached to.
  49908. */
  49909. detachFromMesh(): void;
  49910. private _updateToMesh;
  49911. /**
  49912. * Dispose the helper and release its associated resources.
  49913. */
  49914. dispose(): void;
  49915. }
  49916. }
  49917. declare module BABYLON.Debug {
  49918. /**
  49919. * Class used to render a debug view of a given skeleton
  49920. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49921. */
  49922. export class SkeletonViewer {
  49923. /** defines the skeleton to render */
  49924. skeleton: Skeleton;
  49925. /** defines the mesh attached to the skeleton */
  49926. mesh: AbstractMesh;
  49927. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49928. autoUpdateBonesMatrices: boolean;
  49929. /** defines the rendering group id to use with the viewer */
  49930. renderingGroupId: number;
  49931. /** Gets or sets the color used to render the skeleton */
  49932. color: Color3;
  49933. private _scene;
  49934. private _debugLines;
  49935. private _debugMesh;
  49936. private _isEnabled;
  49937. private _renderFunction;
  49938. private _utilityLayer;
  49939. /**
  49940. * Returns the mesh used to render the bones
  49941. */
  49942. get debugMesh(): Nullable<LinesMesh>;
  49943. /**
  49944. * Creates a new SkeletonViewer
  49945. * @param skeleton defines the skeleton to render
  49946. * @param mesh defines the mesh attached to the skeleton
  49947. * @param scene defines the hosting scene
  49948. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49949. * @param renderingGroupId defines the rendering group id to use with the viewer
  49950. */
  49951. constructor(
  49952. /** defines the skeleton to render */
  49953. skeleton: Skeleton,
  49954. /** defines the mesh attached to the skeleton */
  49955. mesh: AbstractMesh, scene: Scene,
  49956. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49957. autoUpdateBonesMatrices?: boolean,
  49958. /** defines the rendering group id to use with the viewer */
  49959. renderingGroupId?: number);
  49960. /** Gets or sets a boolean indicating if the viewer is enabled */
  49961. set isEnabled(value: boolean);
  49962. get isEnabled(): boolean;
  49963. private _getBonePosition;
  49964. private _getLinesForBonesWithLength;
  49965. private _getLinesForBonesNoLength;
  49966. /** Update the viewer to sync with current skeleton state */
  49967. update(): void;
  49968. /** Release associated resources */
  49969. dispose(): void;
  49970. }
  49971. }
  49972. declare module BABYLON {
  49973. /**
  49974. * Enum for Device Types
  49975. */
  49976. export enum DeviceType {
  49977. /** Generic */
  49978. Generic = 0,
  49979. /** Keyboard */
  49980. Keyboard = 1,
  49981. /** Mouse */
  49982. Mouse = 2,
  49983. /** Touch Pointers */
  49984. Touch = 3,
  49985. /** PS4 Dual Shock */
  49986. DualShock = 4,
  49987. /** Xbox */
  49988. Xbox = 5,
  49989. /** Switch Controller */
  49990. Switch = 6
  49991. }
  49992. /**
  49993. * Enum for All Pointers (Touch/Mouse)
  49994. */
  49995. export enum PointerInput {
  49996. /** Horizontal Axis */
  49997. Horizontal = 0,
  49998. /** Vertical Axis */
  49999. Vertical = 1,
  50000. /** Left Click or Touch */
  50001. LeftClick = 2,
  50002. /** Middle Click */
  50003. MiddleClick = 3,
  50004. /** Right Click */
  50005. RightClick = 4,
  50006. /** Browser Back */
  50007. BrowserBack = 5,
  50008. /** Browser Forward */
  50009. BrowserForward = 6
  50010. }
  50011. /**
  50012. * Enum for Dual Shock Gamepad
  50013. */
  50014. export enum DualShockInput {
  50015. /** Cross */
  50016. Cross = 0,
  50017. /** Circle */
  50018. Circle = 1,
  50019. /** Square */
  50020. Square = 2,
  50021. /** Triangle */
  50022. Triangle = 3,
  50023. /** L1 */
  50024. L1 = 4,
  50025. /** R1 */
  50026. R1 = 5,
  50027. /** L2 */
  50028. L2 = 6,
  50029. /** R2 */
  50030. R2 = 7,
  50031. /** Share */
  50032. Share = 8,
  50033. /** Options */
  50034. Options = 9,
  50035. /** L3 */
  50036. L3 = 10,
  50037. /** R3 */
  50038. R3 = 11,
  50039. /** DPadUp */
  50040. DPadUp = 12,
  50041. /** DPadDown */
  50042. DPadDown = 13,
  50043. /** DPadLeft */
  50044. DPadLeft = 14,
  50045. /** DRight */
  50046. DPadRight = 15,
  50047. /** Home */
  50048. Home = 16,
  50049. /** TouchPad */
  50050. TouchPad = 17,
  50051. /** LStickXAxis */
  50052. LStickXAxis = 18,
  50053. /** LStickYAxis */
  50054. LStickYAxis = 19,
  50055. /** RStickXAxis */
  50056. RStickXAxis = 20,
  50057. /** RStickYAxis */
  50058. RStickYAxis = 21
  50059. }
  50060. /**
  50061. * Enum for Xbox Gamepad
  50062. */
  50063. export enum XboxInput {
  50064. /** A */
  50065. A = 0,
  50066. /** B */
  50067. B = 1,
  50068. /** X */
  50069. X = 2,
  50070. /** Y */
  50071. Y = 3,
  50072. /** LB */
  50073. LB = 4,
  50074. /** RB */
  50075. RB = 5,
  50076. /** LT */
  50077. LT = 6,
  50078. /** RT */
  50079. RT = 7,
  50080. /** Back */
  50081. Back = 8,
  50082. /** Start */
  50083. Start = 9,
  50084. /** LS */
  50085. LS = 10,
  50086. /** RS */
  50087. RS = 11,
  50088. /** DPadUp */
  50089. DPadUp = 12,
  50090. /** DPadDown */
  50091. DPadDown = 13,
  50092. /** DPadLeft */
  50093. DPadLeft = 14,
  50094. /** DRight */
  50095. DPadRight = 15,
  50096. /** Home */
  50097. Home = 16,
  50098. /** LStickXAxis */
  50099. LStickXAxis = 17,
  50100. /** LStickYAxis */
  50101. LStickYAxis = 18,
  50102. /** RStickXAxis */
  50103. RStickXAxis = 19,
  50104. /** RStickYAxis */
  50105. RStickYAxis = 20
  50106. }
  50107. /**
  50108. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50109. */
  50110. export enum SwitchInput {
  50111. /** B */
  50112. B = 0,
  50113. /** A */
  50114. A = 1,
  50115. /** Y */
  50116. Y = 2,
  50117. /** X */
  50118. X = 3,
  50119. /** L */
  50120. L = 4,
  50121. /** R */
  50122. R = 5,
  50123. /** ZL */
  50124. ZL = 6,
  50125. /** ZR */
  50126. ZR = 7,
  50127. /** Minus */
  50128. Minus = 8,
  50129. /** Plus */
  50130. Plus = 9,
  50131. /** LS */
  50132. LS = 10,
  50133. /** RS */
  50134. RS = 11,
  50135. /** DPadUp */
  50136. DPadUp = 12,
  50137. /** DPadDown */
  50138. DPadDown = 13,
  50139. /** DPadLeft */
  50140. DPadLeft = 14,
  50141. /** DRight */
  50142. DPadRight = 15,
  50143. /** Home */
  50144. Home = 16,
  50145. /** Capture */
  50146. Capture = 17,
  50147. /** LStickXAxis */
  50148. LStickXAxis = 18,
  50149. /** LStickYAxis */
  50150. LStickYAxis = 19,
  50151. /** RStickXAxis */
  50152. RStickXAxis = 20,
  50153. /** RStickYAxis */
  50154. RStickYAxis = 21
  50155. }
  50156. }
  50157. declare module BABYLON {
  50158. /**
  50159. * This class will take all inputs from Keyboard, Pointer, and
  50160. * any Gamepads and provide a polling system that all devices
  50161. * will use. This class assumes that there will only be one
  50162. * pointer device and one keyboard.
  50163. */
  50164. export class DeviceInputSystem implements IDisposable {
  50165. /**
  50166. * Callback to be triggered when a device is connected
  50167. */
  50168. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50169. /**
  50170. * Callback to be triggered when a device is disconnected
  50171. */
  50172. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50173. /**
  50174. * Callback to be triggered when event driven input is updated
  50175. */
  50176. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50177. private _inputs;
  50178. private _gamepads;
  50179. private _keyboardActive;
  50180. private _pointerActive;
  50181. private _elementToAttachTo;
  50182. private _keyboardDownEvent;
  50183. private _keyboardUpEvent;
  50184. private _pointerMoveEvent;
  50185. private _pointerDownEvent;
  50186. private _pointerUpEvent;
  50187. private _gamepadConnectedEvent;
  50188. private _gamepadDisconnectedEvent;
  50189. private static _MAX_KEYCODES;
  50190. private static _MAX_POINTER_INPUTS;
  50191. private constructor();
  50192. /**
  50193. * Creates a new DeviceInputSystem instance
  50194. * @param engine Engine to pull input element from
  50195. * @returns The new instance
  50196. */
  50197. static Create(engine: Engine): DeviceInputSystem;
  50198. /**
  50199. * Checks for current device input value, given an id and input index
  50200. * @param deviceName Id of connected device
  50201. * @param inputIndex Index of device input
  50202. * @returns Current value of input
  50203. */
  50204. /**
  50205. * Checks for current device input value, given an id and input index
  50206. * @param deviceType Enum specifiying device type
  50207. * @param deviceSlot "Slot" or index that device is referenced in
  50208. * @param inputIndex Id of input to be checked
  50209. * @returns Current value of input
  50210. */
  50211. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50212. /**
  50213. * Dispose of all the eventlisteners
  50214. */
  50215. dispose(): void;
  50216. /**
  50217. * Add device and inputs to device array
  50218. * @param deviceType Enum specifiying device type
  50219. * @param deviceSlot "Slot" or index that device is referenced in
  50220. * @param numberOfInputs Number of input entries to create for given device
  50221. */
  50222. private _registerDevice;
  50223. /**
  50224. * Given a specific device name, remove that device from the device map
  50225. * @param deviceType Enum specifiying device type
  50226. * @param deviceSlot "Slot" or index that device is referenced in
  50227. */
  50228. private _unregisterDevice;
  50229. /**
  50230. * Handle all actions that come from keyboard interaction
  50231. */
  50232. private _handleKeyActions;
  50233. /**
  50234. * Handle all actions that come from pointer interaction
  50235. */
  50236. private _handlePointerActions;
  50237. /**
  50238. * Handle all actions that come from gamepad interaction
  50239. */
  50240. private _handleGamepadActions;
  50241. /**
  50242. * Update all non-event based devices with each frame
  50243. * @param deviceType Enum specifiying device type
  50244. * @param deviceSlot "Slot" or index that device is referenced in
  50245. * @param inputIndex Id of input to be checked
  50246. */
  50247. private _updateDevice;
  50248. /**
  50249. * Gets DeviceType from the device name
  50250. * @param deviceName Name of Device from DeviceInputSystem
  50251. * @returns DeviceType enum value
  50252. */
  50253. private _getGamepadDeviceType;
  50254. }
  50255. }
  50256. declare module BABYLON {
  50257. /**
  50258. * Type to handle enforcement of inputs
  50259. */
  50260. 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;
  50261. }
  50262. declare module BABYLON {
  50263. /**
  50264. * Class that handles all input for a specific device
  50265. */
  50266. export class DeviceSource<T extends DeviceType> {
  50267. /** Type of device */
  50268. readonly deviceType: DeviceType;
  50269. /** "Slot" or index that device is referenced in */
  50270. readonly deviceSlot: number;
  50271. /**
  50272. * Observable to handle device input changes per device
  50273. */
  50274. readonly onInputChangedObservable: Observable<{
  50275. inputIndex: DeviceInput<T>;
  50276. previousState: Nullable<number>;
  50277. currentState: Nullable<number>;
  50278. }>;
  50279. private readonly _deviceInputSystem;
  50280. /**
  50281. * Default Constructor
  50282. * @param deviceInputSystem Reference to DeviceInputSystem
  50283. * @param deviceType Type of device
  50284. * @param deviceSlot "Slot" or index that device is referenced in
  50285. */
  50286. constructor(deviceInputSystem: DeviceInputSystem,
  50287. /** Type of device */
  50288. deviceType: DeviceType,
  50289. /** "Slot" or index that device is referenced in */
  50290. deviceSlot?: number);
  50291. /**
  50292. * Get input for specific input
  50293. * @param inputIndex index of specific input on device
  50294. * @returns Input value from DeviceInputSystem
  50295. */
  50296. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50297. }
  50298. /**
  50299. * Class to keep track of devices
  50300. */
  50301. export class DeviceSourceManager implements IDisposable {
  50302. /**
  50303. * Observable to be triggered when before a device is connected
  50304. */
  50305. readonly onBeforeDeviceConnectedObservable: Observable<{
  50306. deviceType: DeviceType;
  50307. deviceSlot: number;
  50308. }>;
  50309. /**
  50310. * Observable to be triggered when before a device is disconnected
  50311. */
  50312. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50313. deviceType: DeviceType;
  50314. deviceSlot: number;
  50315. }>;
  50316. /**
  50317. * Observable to be triggered when after a device is connected
  50318. */
  50319. readonly onAfterDeviceConnectedObservable: Observable<{
  50320. deviceType: DeviceType;
  50321. deviceSlot: number;
  50322. }>;
  50323. /**
  50324. * Observable to be triggered when after a device is disconnected
  50325. */
  50326. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50327. deviceType: DeviceType;
  50328. deviceSlot: number;
  50329. }>;
  50330. private readonly _devices;
  50331. private readonly _firstDevice;
  50332. private readonly _deviceInputSystem;
  50333. /**
  50334. * Default Constructor
  50335. * @param engine engine to pull input element from
  50336. */
  50337. constructor(engine: Engine);
  50338. /**
  50339. * Gets a DeviceSource, given a type and slot
  50340. * @param deviceType Enum specifying device type
  50341. * @param deviceSlot "Slot" or index that device is referenced in
  50342. * @returns DeviceSource object
  50343. */
  50344. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50345. /**
  50346. * Gets an array of DeviceSource objects for a given device type
  50347. * @param deviceType Enum specifying device type
  50348. * @returns Array of DeviceSource objects
  50349. */
  50350. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50351. /**
  50352. * Dispose of DeviceInputSystem and other parts
  50353. */
  50354. dispose(): void;
  50355. /**
  50356. * Function to add device name to device list
  50357. * @param deviceType Enum specifying device type
  50358. * @param deviceSlot "Slot" or index that device is referenced in
  50359. */
  50360. private _addDevice;
  50361. /**
  50362. * Function to remove device name to device list
  50363. * @param deviceType Enum specifying device type
  50364. * @param deviceSlot "Slot" or index that device is referenced in
  50365. */
  50366. private _removeDevice;
  50367. /**
  50368. * Updates array storing first connected device of each type
  50369. * @param type Type of Device
  50370. */
  50371. private _updateFirstDevices;
  50372. }
  50373. }
  50374. declare module BABYLON {
  50375. /**
  50376. * Options to create the null engine
  50377. */
  50378. export class NullEngineOptions {
  50379. /**
  50380. * Render width (Default: 512)
  50381. */
  50382. renderWidth: number;
  50383. /**
  50384. * Render height (Default: 256)
  50385. */
  50386. renderHeight: number;
  50387. /**
  50388. * Texture size (Default: 512)
  50389. */
  50390. textureSize: number;
  50391. /**
  50392. * If delta time between frames should be constant
  50393. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50394. */
  50395. deterministicLockstep: boolean;
  50396. /**
  50397. * Maximum about of steps between frames (Default: 4)
  50398. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50399. */
  50400. lockstepMaxSteps: number;
  50401. }
  50402. /**
  50403. * The null engine class provides support for headless version of babylon.js.
  50404. * This can be used in server side scenario or for testing purposes
  50405. */
  50406. export class NullEngine extends Engine {
  50407. private _options;
  50408. /**
  50409. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50410. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50411. * @returns true if engine is in deterministic lock step mode
  50412. */
  50413. isDeterministicLockStep(): boolean;
  50414. /**
  50415. * Gets the max steps when engine is running in deterministic lock step
  50416. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50417. * @returns the max steps
  50418. */
  50419. getLockstepMaxSteps(): number;
  50420. /**
  50421. * Gets the current hardware scaling level.
  50422. * By default the hardware scaling level is computed from the window device ratio.
  50423. * 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.
  50424. * @returns a number indicating the current hardware scaling level
  50425. */
  50426. getHardwareScalingLevel(): number;
  50427. constructor(options?: NullEngineOptions);
  50428. /**
  50429. * Creates a vertex buffer
  50430. * @param vertices the data for the vertex buffer
  50431. * @returns the new WebGL static buffer
  50432. */
  50433. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50434. /**
  50435. * Creates a new index buffer
  50436. * @param indices defines the content of the index buffer
  50437. * @param updatable defines if the index buffer must be updatable
  50438. * @returns a new webGL buffer
  50439. */
  50440. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50441. /**
  50442. * Clear the current render buffer or the current render target (if any is set up)
  50443. * @param color defines the color to use
  50444. * @param backBuffer defines if the back buffer must be cleared
  50445. * @param depth defines if the depth buffer must be cleared
  50446. * @param stencil defines if the stencil buffer must be cleared
  50447. */
  50448. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50449. /**
  50450. * Gets the current render width
  50451. * @param useScreen defines if screen size must be used (or the current render target if any)
  50452. * @returns a number defining the current render width
  50453. */
  50454. getRenderWidth(useScreen?: boolean): number;
  50455. /**
  50456. * Gets the current render height
  50457. * @param useScreen defines if screen size must be used (or the current render target if any)
  50458. * @returns a number defining the current render height
  50459. */
  50460. getRenderHeight(useScreen?: boolean): number;
  50461. /**
  50462. * Set the WebGL's viewport
  50463. * @param viewport defines the viewport element to be used
  50464. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50465. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50466. */
  50467. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50468. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50469. /**
  50470. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50471. * @param pipelineContext defines the pipeline context to use
  50472. * @param uniformsNames defines the list of uniform names
  50473. * @returns an array of webGL uniform locations
  50474. */
  50475. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50476. /**
  50477. * Gets the lsit of active attributes for a given webGL program
  50478. * @param pipelineContext defines the pipeline context to use
  50479. * @param attributesNames defines the list of attribute names to get
  50480. * @returns an array of indices indicating the offset of each attribute
  50481. */
  50482. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50483. /**
  50484. * Binds an effect to the webGL context
  50485. * @param effect defines the effect to bind
  50486. */
  50487. bindSamplers(effect: Effect): void;
  50488. /**
  50489. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50490. * @param effect defines the effect to activate
  50491. */
  50492. enableEffect(effect: Effect): void;
  50493. /**
  50494. * Set various states to the webGL context
  50495. * @param culling defines backface culling state
  50496. * @param zOffset defines the value to apply to zOffset (0 by default)
  50497. * @param force defines if states must be applied even if cache is up to date
  50498. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50499. */
  50500. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50501. /**
  50502. * Set the value of an uniform to an array of int32
  50503. * @param uniform defines the webGL uniform location where to store the value
  50504. * @param array defines the array of int32 to store
  50505. */
  50506. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50507. /**
  50508. * Set the value of an uniform to an array of int32 (stored as vec2)
  50509. * @param uniform defines the webGL uniform location where to store the value
  50510. * @param array defines the array of int32 to store
  50511. */
  50512. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50513. /**
  50514. * Set the value of an uniform to an array of int32 (stored as vec3)
  50515. * @param uniform defines the webGL uniform location where to store the value
  50516. * @param array defines the array of int32 to store
  50517. */
  50518. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50519. /**
  50520. * Set the value of an uniform to an array of int32 (stored as vec4)
  50521. * @param uniform defines the webGL uniform location where to store the value
  50522. * @param array defines the array of int32 to store
  50523. */
  50524. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50525. /**
  50526. * Set the value of an uniform to an array of float32
  50527. * @param uniform defines the webGL uniform location where to store the value
  50528. * @param array defines the array of float32 to store
  50529. */
  50530. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50531. /**
  50532. * Set the value of an uniform to an array of float32 (stored as vec2)
  50533. * @param uniform defines the webGL uniform location where to store the value
  50534. * @param array defines the array of float32 to store
  50535. */
  50536. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50537. /**
  50538. * Set the value of an uniform to an array of float32 (stored as vec3)
  50539. * @param uniform defines the webGL uniform location where to store the value
  50540. * @param array defines the array of float32 to store
  50541. */
  50542. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50543. /**
  50544. * Set the value of an uniform to an array of float32 (stored as vec4)
  50545. * @param uniform defines the webGL uniform location where to store the value
  50546. * @param array defines the array of float32 to store
  50547. */
  50548. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50549. /**
  50550. * Set the value of an uniform to an array of number
  50551. * @param uniform defines the webGL uniform location where to store the value
  50552. * @param array defines the array of number to store
  50553. */
  50554. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50555. /**
  50556. * Set the value of an uniform to an array of number (stored as vec2)
  50557. * @param uniform defines the webGL uniform location where to store the value
  50558. * @param array defines the array of number to store
  50559. */
  50560. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50561. /**
  50562. * Set the value of an uniform to an array of number (stored as vec3)
  50563. * @param uniform defines the webGL uniform location where to store the value
  50564. * @param array defines the array of number to store
  50565. */
  50566. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50567. /**
  50568. * Set the value of an uniform to an array of number (stored as vec4)
  50569. * @param uniform defines the webGL uniform location where to store the value
  50570. * @param array defines the array of number to store
  50571. */
  50572. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50573. /**
  50574. * Set the value of an uniform to an array of float32 (stored as matrices)
  50575. * @param uniform defines the webGL uniform location where to store the value
  50576. * @param matrices defines the array of float32 to store
  50577. */
  50578. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50579. /**
  50580. * Set the value of an uniform to a matrix (3x3)
  50581. * @param uniform defines the webGL uniform location where to store the value
  50582. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50583. */
  50584. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50585. /**
  50586. * Set the value of an uniform to a matrix (2x2)
  50587. * @param uniform defines the webGL uniform location where to store the value
  50588. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50589. */
  50590. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50591. /**
  50592. * Set the value of an uniform to a number (float)
  50593. * @param uniform defines the webGL uniform location where to store the value
  50594. * @param value defines the float number to store
  50595. */
  50596. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50597. /**
  50598. * Set the value of an uniform to a vec2
  50599. * @param uniform defines the webGL uniform location where to store the value
  50600. * @param x defines the 1st component of the value
  50601. * @param y defines the 2nd component of the value
  50602. */
  50603. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50604. /**
  50605. * Set the value of an uniform to a vec3
  50606. * @param uniform defines the webGL uniform location where to store the value
  50607. * @param x defines the 1st component of the value
  50608. * @param y defines the 2nd component of the value
  50609. * @param z defines the 3rd component of the value
  50610. */
  50611. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50612. /**
  50613. * Set the value of an uniform to a boolean
  50614. * @param uniform defines the webGL uniform location where to store the value
  50615. * @param bool defines the boolean to store
  50616. */
  50617. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50618. /**
  50619. * Set the value of an uniform to a vec4
  50620. * @param uniform defines the webGL uniform location where to store the value
  50621. * @param x defines the 1st component of the value
  50622. * @param y defines the 2nd component of the value
  50623. * @param z defines the 3rd component of the value
  50624. * @param w defines the 4th component of the value
  50625. */
  50626. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50627. /**
  50628. * Sets the current alpha mode
  50629. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50630. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50631. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50632. */
  50633. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50634. /**
  50635. * Bind webGl buffers directly to the webGL context
  50636. * @param vertexBuffers defines the vertex buffer to bind
  50637. * @param indexBuffer defines the index buffer to bind
  50638. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50639. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50640. * @param effect defines the effect associated with the vertex buffer
  50641. */
  50642. bindBuffers(vertexBuffers: {
  50643. [key: string]: VertexBuffer;
  50644. }, indexBuffer: DataBuffer, effect: Effect): void;
  50645. /**
  50646. * Force the entire cache to be cleared
  50647. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50648. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50649. */
  50650. wipeCaches(bruteForce?: boolean): void;
  50651. /**
  50652. * Send a draw order
  50653. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50654. * @param indexStart defines the starting index
  50655. * @param indexCount defines the number of index to draw
  50656. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50657. */
  50658. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50659. /**
  50660. * Draw a list of indexed primitives
  50661. * @param fillMode defines the primitive to use
  50662. * @param indexStart defines the starting index
  50663. * @param indexCount defines the number of index to draw
  50664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50665. */
  50666. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50667. /**
  50668. * Draw a list of unindexed primitives
  50669. * @param fillMode defines the primitive to use
  50670. * @param verticesStart defines the index of first vertex to draw
  50671. * @param verticesCount defines the count of vertices to draw
  50672. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50673. */
  50674. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50675. /** @hidden */
  50676. _createTexture(): WebGLTexture;
  50677. /** @hidden */
  50678. _releaseTexture(texture: InternalTexture): void;
  50679. /**
  50680. * Usually called from Texture.ts.
  50681. * Passed information to create a WebGLTexture
  50682. * @param urlArg defines a value which contains one of the following:
  50683. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50684. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50685. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50687. * @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)
  50688. * @param scene needed for loading to the correct scene
  50689. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50690. * @param onLoad optional callback to be called upon successful completion
  50691. * @param onError optional callback to be called upon failure
  50692. * @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
  50693. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50694. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50695. * @param forcedExtension defines the extension to use to pick the right loader
  50696. * @param mimeType defines an optional mime type
  50697. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50698. */
  50699. 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;
  50700. /**
  50701. * Creates a new render target texture
  50702. * @param size defines the size of the texture
  50703. * @param options defines the options used to create the texture
  50704. * @returns a new render target texture stored in an InternalTexture
  50705. */
  50706. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50707. /**
  50708. * Update the sampling mode of a given texture
  50709. * @param samplingMode defines the required sampling mode
  50710. * @param texture defines the texture to update
  50711. */
  50712. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50713. /**
  50714. * Binds the frame buffer to the specified texture.
  50715. * @param texture The texture to render to or null for the default canvas
  50716. * @param faceIndex The face of the texture to render to in case of cube texture
  50717. * @param requiredWidth The width of the target to render to
  50718. * @param requiredHeight The height of the target to render to
  50719. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50720. * @param lodLevel defines le lod level to bind to the frame buffer
  50721. */
  50722. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50723. /**
  50724. * Unbind the current render target texture from the webGL context
  50725. * @param texture defines the render target texture to unbind
  50726. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50727. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50728. */
  50729. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50730. /**
  50731. * Creates a dynamic vertex buffer
  50732. * @param vertices the data for the dynamic vertex buffer
  50733. * @returns the new WebGL dynamic buffer
  50734. */
  50735. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50736. /**
  50737. * Update the content of a dynamic texture
  50738. * @param texture defines the texture to update
  50739. * @param canvas defines the canvas containing the source
  50740. * @param invertY defines if data must be stored with Y axis inverted
  50741. * @param premulAlpha defines if alpha is stored as premultiplied
  50742. * @param format defines the format of the data
  50743. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50744. */
  50745. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50746. /**
  50747. * Gets a boolean indicating if all created effects are ready
  50748. * @returns true if all effects are ready
  50749. */
  50750. areAllEffectsReady(): boolean;
  50751. /**
  50752. * @hidden
  50753. * Get the current error code of the webGL context
  50754. * @returns the error code
  50755. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50756. */
  50757. getError(): number;
  50758. /** @hidden */
  50759. _getUnpackAlignement(): number;
  50760. /** @hidden */
  50761. _unpackFlipY(value: boolean): void;
  50762. /**
  50763. * Update a dynamic index buffer
  50764. * @param indexBuffer defines the target index buffer
  50765. * @param indices defines the data to update
  50766. * @param offset defines the offset in the target index buffer where update should start
  50767. */
  50768. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50769. /**
  50770. * Updates a dynamic vertex buffer.
  50771. * @param vertexBuffer the vertex buffer to update
  50772. * @param vertices the data used to update the vertex buffer
  50773. * @param byteOffset the byte offset of the data (optional)
  50774. * @param byteLength the byte length of the data (optional)
  50775. */
  50776. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50777. /** @hidden */
  50778. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50779. /** @hidden */
  50780. _bindTexture(channel: number, texture: InternalTexture): void;
  50781. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50782. /**
  50783. * 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
  50784. */
  50785. releaseEffects(): void;
  50786. displayLoadingUI(): void;
  50787. hideLoadingUI(): void;
  50788. /** @hidden */
  50789. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50790. /** @hidden */
  50791. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50792. /** @hidden */
  50793. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50794. /** @hidden */
  50795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50796. }
  50797. }
  50798. declare module BABYLON {
  50799. /**
  50800. * @hidden
  50801. **/
  50802. export class _TimeToken {
  50803. _startTimeQuery: Nullable<WebGLQuery>;
  50804. _endTimeQuery: Nullable<WebGLQuery>;
  50805. _timeElapsedQuery: Nullable<WebGLQuery>;
  50806. _timeElapsedQueryEnded: boolean;
  50807. }
  50808. }
  50809. declare module BABYLON {
  50810. /** @hidden */
  50811. export class _OcclusionDataStorage {
  50812. /** @hidden */
  50813. occlusionInternalRetryCounter: number;
  50814. /** @hidden */
  50815. isOcclusionQueryInProgress: boolean;
  50816. /** @hidden */
  50817. isOccluded: boolean;
  50818. /** @hidden */
  50819. occlusionRetryCount: number;
  50820. /** @hidden */
  50821. occlusionType: number;
  50822. /** @hidden */
  50823. occlusionQueryAlgorithmType: number;
  50824. }
  50825. interface Engine {
  50826. /**
  50827. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50828. * @return the new query
  50829. */
  50830. createQuery(): WebGLQuery;
  50831. /**
  50832. * Delete and release a webGL query
  50833. * @param query defines the query to delete
  50834. * @return the current engine
  50835. */
  50836. deleteQuery(query: WebGLQuery): Engine;
  50837. /**
  50838. * Check if a given query has resolved and got its value
  50839. * @param query defines the query to check
  50840. * @returns true if the query got its value
  50841. */
  50842. isQueryResultAvailable(query: WebGLQuery): boolean;
  50843. /**
  50844. * Gets the value of a given query
  50845. * @param query defines the query to check
  50846. * @returns the value of the query
  50847. */
  50848. getQueryResult(query: WebGLQuery): number;
  50849. /**
  50850. * Initiates an occlusion query
  50851. * @param algorithmType defines the algorithm to use
  50852. * @param query defines the query to use
  50853. * @returns the current engine
  50854. * @see http://doc.babylonjs.com/features/occlusionquery
  50855. */
  50856. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50857. /**
  50858. * Ends an occlusion query
  50859. * @see http://doc.babylonjs.com/features/occlusionquery
  50860. * @param algorithmType defines the algorithm to use
  50861. * @returns the current engine
  50862. */
  50863. endOcclusionQuery(algorithmType: number): Engine;
  50864. /**
  50865. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50866. * Please note that only one query can be issued at a time
  50867. * @returns a time token used to track the time span
  50868. */
  50869. startTimeQuery(): Nullable<_TimeToken>;
  50870. /**
  50871. * Ends a time query
  50872. * @param token defines the token used to measure the time span
  50873. * @returns the time spent (in ns)
  50874. */
  50875. endTimeQuery(token: _TimeToken): int;
  50876. /** @hidden */
  50877. _currentNonTimestampToken: Nullable<_TimeToken>;
  50878. /** @hidden */
  50879. _createTimeQuery(): WebGLQuery;
  50880. /** @hidden */
  50881. _deleteTimeQuery(query: WebGLQuery): void;
  50882. /** @hidden */
  50883. _getGlAlgorithmType(algorithmType: number): number;
  50884. /** @hidden */
  50885. _getTimeQueryResult(query: WebGLQuery): any;
  50886. /** @hidden */
  50887. _getTimeQueryAvailability(query: WebGLQuery): any;
  50888. }
  50889. interface AbstractMesh {
  50890. /**
  50891. * Backing filed
  50892. * @hidden
  50893. */
  50894. __occlusionDataStorage: _OcclusionDataStorage;
  50895. /**
  50896. * Access property
  50897. * @hidden
  50898. */
  50899. _occlusionDataStorage: _OcclusionDataStorage;
  50900. /**
  50901. * 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.
  50902. * The default value is -1 which means don't break the query and wait till the result
  50903. * @see http://doc.babylonjs.com/features/occlusionquery
  50904. */
  50905. occlusionRetryCount: number;
  50906. /**
  50907. * 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:
  50908. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50909. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50910. * * 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.
  50911. * @see http://doc.babylonjs.com/features/occlusionquery
  50912. */
  50913. occlusionType: number;
  50914. /**
  50915. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50916. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50917. * * 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.
  50918. * @see http://doc.babylonjs.com/features/occlusionquery
  50919. */
  50920. occlusionQueryAlgorithmType: number;
  50921. /**
  50922. * 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
  50923. * @see http://doc.babylonjs.com/features/occlusionquery
  50924. */
  50925. isOccluded: boolean;
  50926. /**
  50927. * Flag to check the progress status of the query
  50928. * @see http://doc.babylonjs.com/features/occlusionquery
  50929. */
  50930. isOcclusionQueryInProgress: boolean;
  50931. }
  50932. }
  50933. declare module BABYLON {
  50934. /** @hidden */
  50935. export var _forceTransformFeedbackToBundle: boolean;
  50936. interface Engine {
  50937. /**
  50938. * Creates a webGL transform feedback object
  50939. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50940. * @returns the webGL transform feedback object
  50941. */
  50942. createTransformFeedback(): WebGLTransformFeedback;
  50943. /**
  50944. * Delete a webGL transform feedback object
  50945. * @param value defines the webGL transform feedback object to delete
  50946. */
  50947. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50948. /**
  50949. * Bind a webGL transform feedback object to the webgl context
  50950. * @param value defines the webGL transform feedback object to bind
  50951. */
  50952. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50953. /**
  50954. * Begins a transform feedback operation
  50955. * @param usePoints defines if points or triangles must be used
  50956. */
  50957. beginTransformFeedback(usePoints: boolean): void;
  50958. /**
  50959. * Ends a transform feedback operation
  50960. */
  50961. endTransformFeedback(): void;
  50962. /**
  50963. * Specify the varyings to use with transform feedback
  50964. * @param program defines the associated webGL program
  50965. * @param value defines the list of strings representing the varying names
  50966. */
  50967. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50968. /**
  50969. * Bind a webGL buffer for a transform feedback operation
  50970. * @param value defines the webGL buffer to bind
  50971. */
  50972. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50973. }
  50974. }
  50975. declare module BABYLON {
  50976. /**
  50977. * Creation options of the multi render target texture.
  50978. */
  50979. export interface IMultiRenderTargetOptions {
  50980. /**
  50981. * Define if the texture needs to create mip maps after render.
  50982. */
  50983. generateMipMaps?: boolean;
  50984. /**
  50985. * Define the types of all the draw buffers we want to create
  50986. */
  50987. types?: number[];
  50988. /**
  50989. * Define the sampling modes of all the draw buffers we want to create
  50990. */
  50991. samplingModes?: number[];
  50992. /**
  50993. * Define if a depth buffer is required
  50994. */
  50995. generateDepthBuffer?: boolean;
  50996. /**
  50997. * Define if a stencil buffer is required
  50998. */
  50999. generateStencilBuffer?: boolean;
  51000. /**
  51001. * Define if a depth texture is required instead of a depth buffer
  51002. */
  51003. generateDepthTexture?: boolean;
  51004. /**
  51005. * Define the number of desired draw buffers
  51006. */
  51007. textureCount?: number;
  51008. /**
  51009. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51010. */
  51011. doNotChangeAspectRatio?: boolean;
  51012. /**
  51013. * Define the default type of the buffers we are creating
  51014. */
  51015. defaultType?: number;
  51016. }
  51017. /**
  51018. * A multi render target, like a render target provides the ability to render to a texture.
  51019. * Unlike the render target, it can render to several draw buffers in one draw.
  51020. * This is specially interesting in deferred rendering or for any effects requiring more than
  51021. * just one color from a single pass.
  51022. */
  51023. export class MultiRenderTarget extends RenderTargetTexture {
  51024. private _internalTextures;
  51025. private _textures;
  51026. private _multiRenderTargetOptions;
  51027. /**
  51028. * Get if draw buffers are currently supported by the used hardware and browser.
  51029. */
  51030. get isSupported(): boolean;
  51031. /**
  51032. * Get the list of textures generated by the multi render target.
  51033. */
  51034. get textures(): Texture[];
  51035. /**
  51036. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51037. */
  51038. get depthTexture(): Texture;
  51039. /**
  51040. * Set the wrapping mode on U of all the textures we are rendering to.
  51041. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51042. */
  51043. set wrapU(wrap: number);
  51044. /**
  51045. * Set the wrapping mode on V of all the textures we are rendering to.
  51046. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51047. */
  51048. set wrapV(wrap: number);
  51049. /**
  51050. * Instantiate a new multi render target texture.
  51051. * A multi render target, like a render target provides the ability to render to a texture.
  51052. * Unlike the render target, it can render to several draw buffers in one draw.
  51053. * This is specially interesting in deferred rendering or for any effects requiring more than
  51054. * just one color from a single pass.
  51055. * @param name Define the name of the texture
  51056. * @param size Define the size of the buffers to render to
  51057. * @param count Define the number of target we are rendering into
  51058. * @param scene Define the scene the texture belongs to
  51059. * @param options Define the options used to create the multi render target
  51060. */
  51061. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51062. /** @hidden */
  51063. _rebuild(): void;
  51064. private _createInternalTextures;
  51065. private _createTextures;
  51066. /**
  51067. * Define the number of samples used if MSAA is enabled.
  51068. */
  51069. get samples(): number;
  51070. set samples(value: number);
  51071. /**
  51072. * Resize all the textures in the multi render target.
  51073. * Be carrefull as it will recreate all the data in the new texture.
  51074. * @param size Define the new size
  51075. */
  51076. resize(size: any): void;
  51077. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51078. /**
  51079. * Dispose the render targets and their associated resources
  51080. */
  51081. dispose(): void;
  51082. /**
  51083. * Release all the underlying texture used as draw buffers.
  51084. */
  51085. releaseInternalTextures(): void;
  51086. }
  51087. }
  51088. declare module BABYLON {
  51089. interface ThinEngine {
  51090. /**
  51091. * Unbind a list of render target textures from the webGL context
  51092. * This is used only when drawBuffer extension or webGL2 are active
  51093. * @param textures defines the render target textures to unbind
  51094. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51095. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51096. */
  51097. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51098. /**
  51099. * Create a multi render target texture
  51100. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  51101. * @param size defines the size of the texture
  51102. * @param options defines the creation options
  51103. * @returns the cube texture as an InternalTexture
  51104. */
  51105. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51106. /**
  51107. * Update the sample count for a given multiple render target texture
  51108. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51109. * @param textures defines the textures to update
  51110. * @param samples defines the sample count to set
  51111. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51112. */
  51113. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51114. }
  51115. }
  51116. declare module BABYLON {
  51117. /**
  51118. * Class used to define an additional view for the engine
  51119. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51120. */
  51121. export class EngineView {
  51122. /** Defines the canvas where to render the view */
  51123. target: HTMLCanvasElement;
  51124. /** Defines an optional camera used to render the view (will use active camera else) */
  51125. camera?: Camera;
  51126. }
  51127. interface Engine {
  51128. /**
  51129. * Gets or sets the HTML element to use for attaching events
  51130. */
  51131. inputElement: Nullable<HTMLElement>;
  51132. /**
  51133. * Gets the current engine view
  51134. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51135. */
  51136. activeView: Nullable<EngineView>;
  51137. /** Gets or sets the list of views */
  51138. views: EngineView[];
  51139. /**
  51140. * Register a new child canvas
  51141. * @param canvas defines the canvas to register
  51142. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51143. * @returns the associated view
  51144. */
  51145. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51146. /**
  51147. * Remove a registered child canvas
  51148. * @param canvas defines the canvas to remove
  51149. * @returns the current engine
  51150. */
  51151. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51152. }
  51153. }
  51154. declare module BABYLON {
  51155. interface Engine {
  51156. /** @hidden */
  51157. _excludedCompressedTextures: string[];
  51158. /** @hidden */
  51159. _textureFormatInUse: string;
  51160. /**
  51161. * Gets the list of texture formats supported
  51162. */
  51163. readonly texturesSupported: Array<string>;
  51164. /**
  51165. * Gets the texture format in use
  51166. */
  51167. readonly textureFormatInUse: Nullable<string>;
  51168. /**
  51169. * Set the compressed texture extensions or file names to skip.
  51170. *
  51171. * @param skippedFiles defines the list of those texture files you want to skip
  51172. * Example: [".dds", ".env", "myfile.png"]
  51173. */
  51174. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51175. /**
  51176. * Set the compressed texture format to use, based on the formats you have, and the formats
  51177. * supported by the hardware / browser.
  51178. *
  51179. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51180. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51181. * to API arguments needed to compressed textures. This puts the burden on the container
  51182. * generator to house the arcane code for determining these for current & future formats.
  51183. *
  51184. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51185. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51186. *
  51187. * Note: The result of this call is not taken into account when a texture is base64.
  51188. *
  51189. * @param formatsAvailable defines the list of those format families you have created
  51190. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51191. *
  51192. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51193. * @returns The extension selected.
  51194. */
  51195. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51196. }
  51197. }
  51198. declare module BABYLON {
  51199. /**
  51200. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51201. */
  51202. export interface CubeMapInfo {
  51203. /**
  51204. * The pixel array for the front face.
  51205. * This is stored in format, left to right, up to down format.
  51206. */
  51207. front: Nullable<ArrayBufferView>;
  51208. /**
  51209. * The pixel array for the back face.
  51210. * This is stored in format, left to right, up to down format.
  51211. */
  51212. back: Nullable<ArrayBufferView>;
  51213. /**
  51214. * The pixel array for the left face.
  51215. * This is stored in format, left to right, up to down format.
  51216. */
  51217. left: Nullable<ArrayBufferView>;
  51218. /**
  51219. * The pixel array for the right face.
  51220. * This is stored in format, left to right, up to down format.
  51221. */
  51222. right: Nullable<ArrayBufferView>;
  51223. /**
  51224. * The pixel array for the up face.
  51225. * This is stored in format, left to right, up to down format.
  51226. */
  51227. up: Nullable<ArrayBufferView>;
  51228. /**
  51229. * The pixel array for the down face.
  51230. * This is stored in format, left to right, up to down format.
  51231. */
  51232. down: Nullable<ArrayBufferView>;
  51233. /**
  51234. * The size of the cubemap stored.
  51235. *
  51236. * Each faces will be size * size pixels.
  51237. */
  51238. size: number;
  51239. /**
  51240. * The format of the texture.
  51241. *
  51242. * RGBA, RGB.
  51243. */
  51244. format: number;
  51245. /**
  51246. * The type of the texture data.
  51247. *
  51248. * UNSIGNED_INT, FLOAT.
  51249. */
  51250. type: number;
  51251. /**
  51252. * Specifies whether the texture is in gamma space.
  51253. */
  51254. gammaSpace: boolean;
  51255. }
  51256. /**
  51257. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51258. */
  51259. export class PanoramaToCubeMapTools {
  51260. private static FACE_LEFT;
  51261. private static FACE_RIGHT;
  51262. private static FACE_FRONT;
  51263. private static FACE_BACK;
  51264. private static FACE_DOWN;
  51265. private static FACE_UP;
  51266. /**
  51267. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51268. *
  51269. * @param float32Array The source data.
  51270. * @param inputWidth The width of the input panorama.
  51271. * @param inputHeight The height of the input panorama.
  51272. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51273. * @return The cubemap data
  51274. */
  51275. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51276. private static CreateCubemapTexture;
  51277. private static CalcProjectionSpherical;
  51278. }
  51279. }
  51280. declare module BABYLON {
  51281. /**
  51282. * Helper class dealing with the extraction of spherical polynomial dataArray
  51283. * from a cube map.
  51284. */
  51285. export class CubeMapToSphericalPolynomialTools {
  51286. private static FileFaces;
  51287. /**
  51288. * Converts a texture to the according Spherical Polynomial data.
  51289. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51290. *
  51291. * @param texture The texture to extract the information from.
  51292. * @return The Spherical Polynomial data.
  51293. */
  51294. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51295. /**
  51296. * Converts a cubemap to the according Spherical Polynomial data.
  51297. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51298. *
  51299. * @param cubeInfo The Cube map to extract the information from.
  51300. * @return The Spherical Polynomial data.
  51301. */
  51302. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51303. }
  51304. }
  51305. declare module BABYLON {
  51306. interface BaseTexture {
  51307. /**
  51308. * Get the polynomial representation of the texture data.
  51309. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51310. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51311. */
  51312. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51313. }
  51314. }
  51315. declare module BABYLON {
  51316. /** @hidden */
  51317. export var rgbdEncodePixelShader: {
  51318. name: string;
  51319. shader: string;
  51320. };
  51321. }
  51322. declare module BABYLON {
  51323. /** @hidden */
  51324. export var rgbdDecodePixelShader: {
  51325. name: string;
  51326. shader: string;
  51327. };
  51328. }
  51329. declare module BABYLON {
  51330. /**
  51331. * Raw texture data and descriptor sufficient for WebGL texture upload
  51332. */
  51333. export interface EnvironmentTextureInfo {
  51334. /**
  51335. * Version of the environment map
  51336. */
  51337. version: number;
  51338. /**
  51339. * Width of image
  51340. */
  51341. width: number;
  51342. /**
  51343. * Irradiance information stored in the file.
  51344. */
  51345. irradiance: any;
  51346. /**
  51347. * Specular information stored in the file.
  51348. */
  51349. specular: any;
  51350. }
  51351. /**
  51352. * Defines One Image in the file. It requires only the position in the file
  51353. * as well as the length.
  51354. */
  51355. interface BufferImageData {
  51356. /**
  51357. * Length of the image data.
  51358. */
  51359. length: number;
  51360. /**
  51361. * Position of the data from the null terminator delimiting the end of the JSON.
  51362. */
  51363. position: number;
  51364. }
  51365. /**
  51366. * Defines the specular data enclosed in the file.
  51367. * This corresponds to the version 1 of the data.
  51368. */
  51369. export interface EnvironmentTextureSpecularInfoV1 {
  51370. /**
  51371. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51372. */
  51373. specularDataPosition?: number;
  51374. /**
  51375. * This contains all the images data needed to reconstruct the cubemap.
  51376. */
  51377. mipmaps: Array<BufferImageData>;
  51378. /**
  51379. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51380. */
  51381. lodGenerationScale: number;
  51382. }
  51383. /**
  51384. * Sets of helpers addressing the serialization and deserialization of environment texture
  51385. * stored in a BabylonJS env file.
  51386. * Those files are usually stored as .env files.
  51387. */
  51388. export class EnvironmentTextureTools {
  51389. /**
  51390. * Magic number identifying the env file.
  51391. */
  51392. private static _MagicBytes;
  51393. /**
  51394. * Gets the environment info from an env file.
  51395. * @param data The array buffer containing the .env bytes.
  51396. * @returns the environment file info (the json header) if successfully parsed.
  51397. */
  51398. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51399. /**
  51400. * Creates an environment texture from a loaded cube texture.
  51401. * @param texture defines the cube texture to convert in env file
  51402. * @return a promise containing the environment data if succesfull.
  51403. */
  51404. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51405. /**
  51406. * Creates a JSON representation of the spherical data.
  51407. * @param texture defines the texture containing the polynomials
  51408. * @return the JSON representation of the spherical info
  51409. */
  51410. private static _CreateEnvTextureIrradiance;
  51411. /**
  51412. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51413. * @param data the image data
  51414. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51415. * @return the views described by info providing access to the underlying buffer
  51416. */
  51417. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51418. /**
  51419. * Uploads the texture info contained in the env file to the GPU.
  51420. * @param texture defines the internal texture to upload to
  51421. * @param data defines the data to load
  51422. * @param info defines the texture info retrieved through the GetEnvInfo method
  51423. * @returns a promise
  51424. */
  51425. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51426. private static _OnImageReadyAsync;
  51427. /**
  51428. * Uploads the levels of image data to the GPU.
  51429. * @param texture defines the internal texture to upload to
  51430. * @param imageData defines the array buffer views of image data [mipmap][face]
  51431. * @returns a promise
  51432. */
  51433. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51434. /**
  51435. * Uploads spherical polynomials information to the texture.
  51436. * @param texture defines the texture we are trying to upload the information to
  51437. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51438. */
  51439. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51440. /** @hidden */
  51441. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51442. }
  51443. }
  51444. declare module BABYLON {
  51445. /** @hidden */
  51446. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51447. private _genericAttributeLocation;
  51448. private _varyingLocationCount;
  51449. private _varyingLocationMap;
  51450. private _replacements;
  51451. private _textureCount;
  51452. private _uniforms;
  51453. lineProcessor(line: string): string;
  51454. attributeProcessor(attribute: string): string;
  51455. varyingProcessor(varying: string, isFragment: boolean): string;
  51456. uniformProcessor(uniform: string): string;
  51457. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51458. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51459. }
  51460. }
  51461. declare module BABYLON {
  51462. /**
  51463. * Class used to inline functions in shader code
  51464. */
  51465. export class ShaderCodeInliner {
  51466. private static readonly _RegexpFindFunctionNameAndType;
  51467. private _sourceCode;
  51468. private _functionDescr;
  51469. private _numMaxIterations;
  51470. /** Gets or sets the token used to mark the functions to inline */
  51471. inlineToken: string;
  51472. /** Gets or sets the debug mode */
  51473. debug: boolean;
  51474. /** Gets the code after the inlining process */
  51475. get code(): string;
  51476. /**
  51477. * Initializes the inliner
  51478. * @param sourceCode shader code source to inline
  51479. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51480. */
  51481. constructor(sourceCode: string, numMaxIterations?: number);
  51482. /**
  51483. * Start the processing of the shader code
  51484. */
  51485. processCode(): void;
  51486. private _collectFunctions;
  51487. private _processInlining;
  51488. private _extractBetweenMarkers;
  51489. private _skipWhitespaces;
  51490. private _removeComments;
  51491. private _replaceFunctionCallsByCode;
  51492. private _findBackward;
  51493. private _escapeRegExp;
  51494. private _replaceNames;
  51495. }
  51496. }
  51497. declare module BABYLON {
  51498. /**
  51499. * Container for accessors for natively-stored mesh data buffers.
  51500. */
  51501. class NativeDataBuffer extends DataBuffer {
  51502. /**
  51503. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51504. */
  51505. nativeIndexBuffer?: any;
  51506. /**
  51507. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51508. */
  51509. nativeVertexBuffer?: any;
  51510. }
  51511. /** @hidden */
  51512. class NativeTexture extends InternalTexture {
  51513. getInternalTexture(): InternalTexture;
  51514. getViewCount(): number;
  51515. }
  51516. /** @hidden */
  51517. export class NativeEngine extends Engine {
  51518. private readonly _native;
  51519. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51520. private readonly INVALID_HANDLE;
  51521. getHardwareScalingLevel(): number;
  51522. constructor();
  51523. dispose(): void;
  51524. /**
  51525. * Can be used to override the current requestAnimationFrame requester.
  51526. * @hidden
  51527. */
  51528. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51529. /**
  51530. * Override default engine behavior.
  51531. * @param color
  51532. * @param backBuffer
  51533. * @param depth
  51534. * @param stencil
  51535. */
  51536. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51537. /**
  51538. * Gets host document
  51539. * @returns the host document object
  51540. */
  51541. getHostDocument(): Nullable<Document>;
  51542. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51543. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51544. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51545. recordVertexArrayObject(vertexBuffers: {
  51546. [key: string]: VertexBuffer;
  51547. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51548. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51549. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51550. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51551. /**
  51552. * Draw a list of indexed primitives
  51553. * @param fillMode defines the primitive to use
  51554. * @param indexStart defines the starting index
  51555. * @param indexCount defines the number of index to draw
  51556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51557. */
  51558. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51559. /**
  51560. * Draw a list of unindexed primitives
  51561. * @param fillMode defines the primitive to use
  51562. * @param verticesStart defines the index of first vertex to draw
  51563. * @param verticesCount defines the count of vertices to draw
  51564. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51565. */
  51566. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51567. createPipelineContext(): IPipelineContext;
  51568. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51569. /** @hidden */
  51570. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51571. /** @hidden */
  51572. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51573. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51574. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51575. protected _setProgram(program: WebGLProgram): void;
  51576. _releaseEffect(effect: Effect): void;
  51577. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51578. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51579. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51580. bindSamplers(effect: Effect): void;
  51581. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51582. getRenderWidth(useScreen?: boolean): number;
  51583. getRenderHeight(useScreen?: boolean): number;
  51584. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51585. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51586. /**
  51587. * Set the z offset to apply to current rendering
  51588. * @param value defines the offset to apply
  51589. */
  51590. setZOffset(value: number): void;
  51591. /**
  51592. * Gets the current value of the zOffset
  51593. * @returns the current zOffset state
  51594. */
  51595. getZOffset(): number;
  51596. /**
  51597. * Enable or disable depth buffering
  51598. * @param enable defines the state to set
  51599. */
  51600. setDepthBuffer(enable: boolean): void;
  51601. /**
  51602. * Gets a boolean indicating if depth writing is enabled
  51603. * @returns the current depth writing state
  51604. */
  51605. getDepthWrite(): boolean;
  51606. /**
  51607. * Enable or disable depth writing
  51608. * @param enable defines the state to set
  51609. */
  51610. setDepthWrite(enable: boolean): void;
  51611. /**
  51612. * Enable or disable color writing
  51613. * @param enable defines the state to set
  51614. */
  51615. setColorWrite(enable: boolean): void;
  51616. /**
  51617. * Gets a boolean indicating if color writing is enabled
  51618. * @returns the current color writing state
  51619. */
  51620. getColorWrite(): boolean;
  51621. /**
  51622. * Sets alpha constants used by some alpha blending modes
  51623. * @param r defines the red component
  51624. * @param g defines the green component
  51625. * @param b defines the blue component
  51626. * @param a defines the alpha component
  51627. */
  51628. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51629. /**
  51630. * Sets the current alpha mode
  51631. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51632. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51633. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51634. */
  51635. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51636. /**
  51637. * Gets the current alpha mode
  51638. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51639. * @returns the current alpha mode
  51640. */
  51641. getAlphaMode(): number;
  51642. setInt(uniform: WebGLUniformLocation, int: number): void;
  51643. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51644. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51645. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51646. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51647. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51648. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51649. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51650. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51651. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51652. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51653. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51654. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51655. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51656. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51657. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51658. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51659. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51660. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51661. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51662. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51663. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51664. wipeCaches(bruteForce?: boolean): void;
  51665. _createTexture(): WebGLTexture;
  51666. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51667. /**
  51668. * Usually called from Texture.ts.
  51669. * Passed information to create a WebGLTexture
  51670. * @param url defines a value which contains one of the following:
  51671. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51672. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51673. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51674. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51675. * @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)
  51676. * @param scene needed for loading to the correct scene
  51677. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51678. * @param onLoad optional callback to be called upon successful completion
  51679. * @param onError optional callback to be called upon failure
  51680. * @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
  51681. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51682. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51683. * @param forcedExtension defines the extension to use to pick the right loader
  51684. * @param mimeType defines an optional mime type
  51685. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51686. */
  51687. 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;
  51688. /**
  51689. * Creates a cube texture
  51690. * @param rootUrl defines the url where the files to load is located
  51691. * @param scene defines the current scene
  51692. * @param files defines the list of files to load (1 per face)
  51693. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51694. * @param onLoad defines an optional callback raised when the texture is loaded
  51695. * @param onError defines an optional callback raised if there is an issue to load the texture
  51696. * @param format defines the format of the data
  51697. * @param forcedExtension defines the extension to use to pick the right loader
  51698. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51699. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51700. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51701. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51702. * @returns the cube texture as an InternalTexture
  51703. */
  51704. 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;
  51705. private _getSamplingFilter;
  51706. private static _GetNativeTextureFormat;
  51707. createRenderTargetTexture(size: number | {
  51708. width: number;
  51709. height: number;
  51710. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51711. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51712. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51713. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51714. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51715. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51716. /**
  51717. * Updates a dynamic vertex buffer.
  51718. * @param vertexBuffer the vertex buffer to update
  51719. * @param data the data used to update the vertex buffer
  51720. * @param byteOffset the byte offset of the data (optional)
  51721. * @param byteLength the byte length of the data (optional)
  51722. */
  51723. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51724. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51725. private _updateAnisotropicLevel;
  51726. private _getAddressMode;
  51727. /** @hidden */
  51728. _bindTexture(channel: number, texture: InternalTexture): void;
  51729. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51730. releaseEffects(): void;
  51731. /** @hidden */
  51732. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51733. /** @hidden */
  51734. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51735. /** @hidden */
  51736. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51737. /** @hidden */
  51738. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51739. }
  51740. }
  51741. declare module BABYLON {
  51742. /**
  51743. * Gather the list of clipboard event types as constants.
  51744. */
  51745. export class ClipboardEventTypes {
  51746. /**
  51747. * The clipboard event is fired when a copy command is active (pressed).
  51748. */
  51749. static readonly COPY: number;
  51750. /**
  51751. * The clipboard event is fired when a cut command is active (pressed).
  51752. */
  51753. static readonly CUT: number;
  51754. /**
  51755. * The clipboard event is fired when a paste command is active (pressed).
  51756. */
  51757. static readonly PASTE: number;
  51758. }
  51759. /**
  51760. * This class is used to store clipboard related info for the onClipboardObservable event.
  51761. */
  51762. export class ClipboardInfo {
  51763. /**
  51764. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51765. */
  51766. type: number;
  51767. /**
  51768. * Defines the related dom event
  51769. */
  51770. event: ClipboardEvent;
  51771. /**
  51772. *Creates an instance of ClipboardInfo.
  51773. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51774. * @param event Defines the related dom event
  51775. */
  51776. constructor(
  51777. /**
  51778. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51779. */
  51780. type: number,
  51781. /**
  51782. * Defines the related dom event
  51783. */
  51784. event: ClipboardEvent);
  51785. /**
  51786. * Get the clipboard event's type from the keycode.
  51787. * @param keyCode Defines the keyCode for the current keyboard event.
  51788. * @return {number}
  51789. */
  51790. static GetTypeFromCharacter(keyCode: number): number;
  51791. }
  51792. }
  51793. declare module BABYLON {
  51794. /**
  51795. * Google Daydream controller
  51796. */
  51797. export class DaydreamController extends WebVRController {
  51798. /**
  51799. * Base Url for the controller model.
  51800. */
  51801. static MODEL_BASE_URL: string;
  51802. /**
  51803. * File name for the controller model.
  51804. */
  51805. static MODEL_FILENAME: string;
  51806. /**
  51807. * Gamepad Id prefix used to identify Daydream Controller.
  51808. */
  51809. static readonly GAMEPAD_ID_PREFIX: string;
  51810. /**
  51811. * Creates a new DaydreamController from a gamepad
  51812. * @param vrGamepad the gamepad that the controller should be created from
  51813. */
  51814. constructor(vrGamepad: any);
  51815. /**
  51816. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51817. * @param scene scene in which to add meshes
  51818. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51819. */
  51820. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51821. /**
  51822. * Called once for each button that changed state since the last frame
  51823. * @param buttonIdx Which button index changed
  51824. * @param state New state of the button
  51825. * @param changes Which properties on the state changed since last frame
  51826. */
  51827. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51828. }
  51829. }
  51830. declare module BABYLON {
  51831. /**
  51832. * Gear VR Controller
  51833. */
  51834. export class GearVRController extends WebVRController {
  51835. /**
  51836. * Base Url for the controller model.
  51837. */
  51838. static MODEL_BASE_URL: string;
  51839. /**
  51840. * File name for the controller model.
  51841. */
  51842. static MODEL_FILENAME: string;
  51843. /**
  51844. * Gamepad Id prefix used to identify this controller.
  51845. */
  51846. static readonly GAMEPAD_ID_PREFIX: string;
  51847. private readonly _buttonIndexToObservableNameMap;
  51848. /**
  51849. * Creates a new GearVRController from a gamepad
  51850. * @param vrGamepad the gamepad that the controller should be created from
  51851. */
  51852. constructor(vrGamepad: any);
  51853. /**
  51854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51855. * @param scene scene in which to add meshes
  51856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51857. */
  51858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51859. /**
  51860. * Called once for each button that changed state since the last frame
  51861. * @param buttonIdx Which button index changed
  51862. * @param state New state of the button
  51863. * @param changes Which properties on the state changed since last frame
  51864. */
  51865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51866. }
  51867. }
  51868. declare module BABYLON {
  51869. /**
  51870. * Generic Controller
  51871. */
  51872. export class GenericController extends WebVRController {
  51873. /**
  51874. * Base Url for the controller model.
  51875. */
  51876. static readonly MODEL_BASE_URL: string;
  51877. /**
  51878. * File name for the controller model.
  51879. */
  51880. static readonly MODEL_FILENAME: string;
  51881. /**
  51882. * Creates a new GenericController from a gamepad
  51883. * @param vrGamepad the gamepad that the controller should be created from
  51884. */
  51885. constructor(vrGamepad: any);
  51886. /**
  51887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51888. * @param scene scene in which to add meshes
  51889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51890. */
  51891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51892. /**
  51893. * Called once for each button that changed state since the last frame
  51894. * @param buttonIdx Which button index changed
  51895. * @param state New state of the button
  51896. * @param changes Which properties on the state changed since last frame
  51897. */
  51898. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51899. }
  51900. }
  51901. declare module BABYLON {
  51902. /**
  51903. * Oculus Touch Controller
  51904. */
  51905. export class OculusTouchController extends WebVRController {
  51906. /**
  51907. * Base Url for the controller model.
  51908. */
  51909. static MODEL_BASE_URL: string;
  51910. /**
  51911. * File name for the left controller model.
  51912. */
  51913. static MODEL_LEFT_FILENAME: string;
  51914. /**
  51915. * File name for the right controller model.
  51916. */
  51917. static MODEL_RIGHT_FILENAME: string;
  51918. /**
  51919. * Base Url for the Quest controller model.
  51920. */
  51921. static QUEST_MODEL_BASE_URL: string;
  51922. /**
  51923. * @hidden
  51924. * If the controllers are running on a device that needs the updated Quest controller models
  51925. */
  51926. static _IsQuest: boolean;
  51927. /**
  51928. * Fired when the secondary trigger on this controller is modified
  51929. */
  51930. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51931. /**
  51932. * Fired when the thumb rest on this controller is modified
  51933. */
  51934. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51935. /**
  51936. * Creates a new OculusTouchController from a gamepad
  51937. * @param vrGamepad the gamepad that the controller should be created from
  51938. */
  51939. constructor(vrGamepad: any);
  51940. /**
  51941. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51942. * @param scene scene in which to add meshes
  51943. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51944. */
  51945. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51946. /**
  51947. * Fired when the A button on this controller is modified
  51948. */
  51949. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51950. /**
  51951. * Fired when the B button on this controller is modified
  51952. */
  51953. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51954. /**
  51955. * Fired when the X button on this controller is modified
  51956. */
  51957. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51958. /**
  51959. * Fired when the Y button on this controller is modified
  51960. */
  51961. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51962. /**
  51963. * Called once for each button that changed state since the last frame
  51964. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51965. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51966. * 2) secondary trigger (same)
  51967. * 3) A (right) X (left), touch, pressed = value
  51968. * 4) B / Y
  51969. * 5) thumb rest
  51970. * @param buttonIdx Which button index changed
  51971. * @param state New state of the button
  51972. * @param changes Which properties on the state changed since last frame
  51973. */
  51974. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51975. }
  51976. }
  51977. declare module BABYLON {
  51978. /**
  51979. * Vive Controller
  51980. */
  51981. export class ViveController extends WebVRController {
  51982. /**
  51983. * Base Url for the controller model.
  51984. */
  51985. static MODEL_BASE_URL: string;
  51986. /**
  51987. * File name for the controller model.
  51988. */
  51989. static MODEL_FILENAME: string;
  51990. /**
  51991. * Creates a new ViveController from a gamepad
  51992. * @param vrGamepad the gamepad that the controller should be created from
  51993. */
  51994. constructor(vrGamepad: any);
  51995. /**
  51996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51997. * @param scene scene in which to add meshes
  51998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51999. */
  52000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52001. /**
  52002. * Fired when the left button on this controller is modified
  52003. */
  52004. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52005. /**
  52006. * Fired when the right button on this controller is modified
  52007. */
  52008. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52009. /**
  52010. * Fired when the menu button on this controller is modified
  52011. */
  52012. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52013. /**
  52014. * Called once for each button that changed state since the last frame
  52015. * Vive mapping:
  52016. * 0: touchpad
  52017. * 1: trigger
  52018. * 2: left AND right buttons
  52019. * 3: menu button
  52020. * @param buttonIdx Which button index changed
  52021. * @param state New state of the button
  52022. * @param changes Which properties on the state changed since last frame
  52023. */
  52024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52025. }
  52026. }
  52027. declare module BABYLON {
  52028. /**
  52029. * Defines the WindowsMotionController object that the state of the windows motion controller
  52030. */
  52031. export class WindowsMotionController extends WebVRController {
  52032. /**
  52033. * The base url used to load the left and right controller models
  52034. */
  52035. static MODEL_BASE_URL: string;
  52036. /**
  52037. * The name of the left controller model file
  52038. */
  52039. static MODEL_LEFT_FILENAME: string;
  52040. /**
  52041. * The name of the right controller model file
  52042. */
  52043. static MODEL_RIGHT_FILENAME: string;
  52044. /**
  52045. * The controller name prefix for this controller type
  52046. */
  52047. static readonly GAMEPAD_ID_PREFIX: string;
  52048. /**
  52049. * The controller id pattern for this controller type
  52050. */
  52051. private static readonly GAMEPAD_ID_PATTERN;
  52052. private _loadedMeshInfo;
  52053. protected readonly _mapping: {
  52054. buttons: string[];
  52055. buttonMeshNames: {
  52056. trigger: string;
  52057. menu: string;
  52058. grip: string;
  52059. thumbstick: string;
  52060. trackpad: string;
  52061. };
  52062. buttonObservableNames: {
  52063. trigger: string;
  52064. menu: string;
  52065. grip: string;
  52066. thumbstick: string;
  52067. trackpad: string;
  52068. };
  52069. axisMeshNames: string[];
  52070. pointingPoseMeshName: string;
  52071. };
  52072. /**
  52073. * Fired when the trackpad on this controller is clicked
  52074. */
  52075. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52076. /**
  52077. * Fired when the trackpad on this controller is modified
  52078. */
  52079. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52080. /**
  52081. * The current x and y values of this controller's trackpad
  52082. */
  52083. trackpad: StickValues;
  52084. /**
  52085. * Creates a new WindowsMotionController from a gamepad
  52086. * @param vrGamepad the gamepad that the controller should be created from
  52087. */
  52088. constructor(vrGamepad: any);
  52089. /**
  52090. * Fired when the trigger on this controller is modified
  52091. */
  52092. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52093. /**
  52094. * Fired when the menu button on this controller is modified
  52095. */
  52096. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52097. /**
  52098. * Fired when the grip button on this controller is modified
  52099. */
  52100. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52101. /**
  52102. * Fired when the thumbstick button on this controller is modified
  52103. */
  52104. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52105. /**
  52106. * Fired when the touchpad button on this controller is modified
  52107. */
  52108. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52109. /**
  52110. * Fired when the touchpad values on this controller are modified
  52111. */
  52112. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52113. protected _updateTrackpad(): void;
  52114. /**
  52115. * Called once per frame by the engine.
  52116. */
  52117. update(): void;
  52118. /**
  52119. * Called once for each button that changed state since the last frame
  52120. * @param buttonIdx Which button index changed
  52121. * @param state New state of the button
  52122. * @param changes Which properties on the state changed since last frame
  52123. */
  52124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52125. /**
  52126. * Moves the buttons on the controller mesh based on their current state
  52127. * @param buttonName the name of the button to move
  52128. * @param buttonValue the value of the button which determines the buttons new position
  52129. */
  52130. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52131. /**
  52132. * Moves the axis on the controller mesh based on its current state
  52133. * @param axis the index of the axis
  52134. * @param axisValue the value of the axis which determines the meshes new position
  52135. * @hidden
  52136. */
  52137. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52138. /**
  52139. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52140. * @param scene scene in which to add meshes
  52141. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52142. */
  52143. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52144. /**
  52145. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52146. * can be transformed by button presses and axes values, based on this._mapping.
  52147. *
  52148. * @param scene scene in which the meshes exist
  52149. * @param meshes list of meshes that make up the controller model to process
  52150. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52151. */
  52152. private processModel;
  52153. private createMeshInfo;
  52154. /**
  52155. * Gets the ray of the controller in the direction the controller is pointing
  52156. * @param length the length the resulting ray should be
  52157. * @returns a ray in the direction the controller is pointing
  52158. */
  52159. getForwardRay(length?: number): Ray;
  52160. /**
  52161. * Disposes of the controller
  52162. */
  52163. dispose(): void;
  52164. }
  52165. /**
  52166. * This class represents a new windows motion controller in XR.
  52167. */
  52168. export class XRWindowsMotionController extends WindowsMotionController {
  52169. /**
  52170. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52171. */
  52172. protected readonly _mapping: {
  52173. buttons: string[];
  52174. buttonMeshNames: {
  52175. trigger: string;
  52176. menu: string;
  52177. grip: string;
  52178. thumbstick: string;
  52179. trackpad: string;
  52180. };
  52181. buttonObservableNames: {
  52182. trigger: string;
  52183. menu: string;
  52184. grip: string;
  52185. thumbstick: string;
  52186. trackpad: string;
  52187. };
  52188. axisMeshNames: string[];
  52189. pointingPoseMeshName: string;
  52190. };
  52191. /**
  52192. * Construct a new XR-Based windows motion controller
  52193. *
  52194. * @param gamepadInfo the gamepad object from the browser
  52195. */
  52196. constructor(gamepadInfo: any);
  52197. /**
  52198. * holds the thumbstick values (X,Y)
  52199. */
  52200. thumbstickValues: StickValues;
  52201. /**
  52202. * Fired when the thumbstick on this controller is clicked
  52203. */
  52204. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52205. /**
  52206. * Fired when the thumbstick on this controller is modified
  52207. */
  52208. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52209. /**
  52210. * Fired when the touchpad button on this controller is modified
  52211. */
  52212. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52213. /**
  52214. * Fired when the touchpad values on this controller are modified
  52215. */
  52216. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52217. /**
  52218. * Fired when the thumbstick button on this controller is modified
  52219. * here to prevent breaking changes
  52220. */
  52221. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52222. /**
  52223. * updating the thumbstick(!) and not the trackpad.
  52224. * This is named this way due to the difference between WebVR and XR and to avoid
  52225. * changing the parent class.
  52226. */
  52227. protected _updateTrackpad(): void;
  52228. /**
  52229. * Disposes the class with joy
  52230. */
  52231. dispose(): void;
  52232. }
  52233. }
  52234. declare module BABYLON {
  52235. /**
  52236. * Class containing static functions to help procedurally build meshes
  52237. */
  52238. export class PolyhedronBuilder {
  52239. /**
  52240. * Creates a polyhedron mesh
  52241. * * 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
  52242. * * The parameter `size` (positive float, default 1) sets the polygon size
  52243. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52244. * * 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`
  52245. * * 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
  52246. * * 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)`)
  52247. * * 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
  52248. * * 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
  52249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52250. * * 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
  52251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52252. * @param name defines the name of the mesh
  52253. * @param options defines the options used to create the mesh
  52254. * @param scene defines the hosting scene
  52255. * @returns the polyhedron mesh
  52256. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52257. */
  52258. static CreatePolyhedron(name: string, options: {
  52259. type?: number;
  52260. size?: number;
  52261. sizeX?: number;
  52262. sizeY?: number;
  52263. sizeZ?: number;
  52264. custom?: any;
  52265. faceUV?: Vector4[];
  52266. faceColors?: Color4[];
  52267. flat?: boolean;
  52268. updatable?: boolean;
  52269. sideOrientation?: number;
  52270. frontUVs?: Vector4;
  52271. backUVs?: Vector4;
  52272. }, scene?: Nullable<Scene>): Mesh;
  52273. }
  52274. }
  52275. declare module BABYLON {
  52276. /**
  52277. * Gizmo that enables scaling a mesh along 3 axis
  52278. */
  52279. export class ScaleGizmo extends Gizmo {
  52280. /**
  52281. * Internal gizmo used for interactions on the x axis
  52282. */
  52283. xGizmo: AxisScaleGizmo;
  52284. /**
  52285. * Internal gizmo used for interactions on the y axis
  52286. */
  52287. yGizmo: AxisScaleGizmo;
  52288. /**
  52289. * Internal gizmo used for interactions on the z axis
  52290. */
  52291. zGizmo: AxisScaleGizmo;
  52292. /**
  52293. * Internal gizmo used to scale all axis equally
  52294. */
  52295. uniformScaleGizmo: AxisScaleGizmo;
  52296. private _meshAttached;
  52297. private _updateGizmoRotationToMatchAttachedMesh;
  52298. private _snapDistance;
  52299. private _scaleRatio;
  52300. private _uniformScalingMesh;
  52301. private _octahedron;
  52302. private _sensitivity;
  52303. /** Fires an event when any of it's sub gizmos are dragged */
  52304. onDragStartObservable: Observable<unknown>;
  52305. /** Fires an event when any of it's sub gizmos are released from dragging */
  52306. onDragEndObservable: Observable<unknown>;
  52307. get attachedMesh(): Nullable<AbstractMesh>;
  52308. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52309. /**
  52310. * Creates a ScaleGizmo
  52311. * @param gizmoLayer The utility layer the gizmo will be added to
  52312. */
  52313. constructor(gizmoLayer?: UtilityLayerRenderer);
  52314. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52315. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52316. /**
  52317. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52318. */
  52319. set snapDistance(value: number);
  52320. get snapDistance(): number;
  52321. /**
  52322. * Ratio for the scale of the gizmo (Default: 1)
  52323. */
  52324. set scaleRatio(value: number);
  52325. get scaleRatio(): number;
  52326. /**
  52327. * Sensitivity factor for dragging (Default: 1)
  52328. */
  52329. set sensitivity(value: number);
  52330. get sensitivity(): number;
  52331. /**
  52332. * Disposes of the gizmo
  52333. */
  52334. dispose(): void;
  52335. }
  52336. }
  52337. declare module BABYLON {
  52338. /**
  52339. * Single axis scale gizmo
  52340. */
  52341. export class AxisScaleGizmo extends Gizmo {
  52342. /**
  52343. * Drag behavior responsible for the gizmos dragging interactions
  52344. */
  52345. dragBehavior: PointerDragBehavior;
  52346. private _pointerObserver;
  52347. /**
  52348. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52349. */
  52350. snapDistance: number;
  52351. /**
  52352. * Event that fires each time the gizmo snaps to a new location.
  52353. * * snapDistance is the the change in distance
  52354. */
  52355. onSnapObservable: Observable<{
  52356. snapDistance: number;
  52357. }>;
  52358. /**
  52359. * If the scaling operation should be done on all axis (default: false)
  52360. */
  52361. uniformScaling: boolean;
  52362. /**
  52363. * Custom sensitivity value for the drag strength
  52364. */
  52365. sensitivity: number;
  52366. private _isEnabled;
  52367. private _parent;
  52368. private _arrow;
  52369. private _coloredMaterial;
  52370. private _hoverMaterial;
  52371. /**
  52372. * Creates an AxisScaleGizmo
  52373. * @param gizmoLayer The utility layer the gizmo will be added to
  52374. * @param dragAxis The axis which the gizmo will be able to scale on
  52375. * @param color The color of the gizmo
  52376. */
  52377. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52378. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52379. /**
  52380. * If the gizmo is enabled
  52381. */
  52382. set isEnabled(value: boolean);
  52383. get isEnabled(): boolean;
  52384. /**
  52385. * Disposes of the gizmo
  52386. */
  52387. dispose(): void;
  52388. /**
  52389. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52390. * @param mesh The mesh to replace the default mesh of the gizmo
  52391. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52392. */
  52393. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52394. }
  52395. }
  52396. declare module BABYLON {
  52397. /**
  52398. * Bounding box gizmo
  52399. */
  52400. export class BoundingBoxGizmo extends Gizmo {
  52401. private _lineBoundingBox;
  52402. private _rotateSpheresParent;
  52403. private _scaleBoxesParent;
  52404. private _boundingDimensions;
  52405. private _renderObserver;
  52406. private _pointerObserver;
  52407. private _scaleDragSpeed;
  52408. private _tmpQuaternion;
  52409. private _tmpVector;
  52410. private _tmpRotationMatrix;
  52411. /**
  52412. * 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)
  52413. */
  52414. ignoreChildren: boolean;
  52415. /**
  52416. * 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)
  52417. */
  52418. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52419. /**
  52420. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52421. */
  52422. rotationSphereSize: number;
  52423. /**
  52424. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52425. */
  52426. scaleBoxSize: number;
  52427. /**
  52428. * 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)
  52429. */
  52430. fixedDragMeshScreenSize: boolean;
  52431. /**
  52432. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52433. */
  52434. fixedDragMeshScreenSizeDistanceFactor: number;
  52435. /**
  52436. * Fired when a rotation sphere or scale box is dragged
  52437. */
  52438. onDragStartObservable: Observable<{}>;
  52439. /**
  52440. * Fired when a scale box is dragged
  52441. */
  52442. onScaleBoxDragObservable: Observable<{}>;
  52443. /**
  52444. * Fired when a scale box drag is ended
  52445. */
  52446. onScaleBoxDragEndObservable: Observable<{}>;
  52447. /**
  52448. * Fired when a rotation sphere is dragged
  52449. */
  52450. onRotationSphereDragObservable: Observable<{}>;
  52451. /**
  52452. * Fired when a rotation sphere drag is ended
  52453. */
  52454. onRotationSphereDragEndObservable: Observable<{}>;
  52455. /**
  52456. * 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)
  52457. */
  52458. scalePivot: Nullable<Vector3>;
  52459. /**
  52460. * Mesh used as a pivot to rotate the attached mesh
  52461. */
  52462. private _anchorMesh;
  52463. private _existingMeshScale;
  52464. private _dragMesh;
  52465. private pointerDragBehavior;
  52466. private coloredMaterial;
  52467. private hoverColoredMaterial;
  52468. /**
  52469. * Sets the color of the bounding box gizmo
  52470. * @param color the color to set
  52471. */
  52472. setColor(color: Color3): void;
  52473. /**
  52474. * Creates an BoundingBoxGizmo
  52475. * @param gizmoLayer The utility layer the gizmo will be added to
  52476. * @param color The color of the gizmo
  52477. */
  52478. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52479. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52480. private _selectNode;
  52481. /**
  52482. * Updates the bounding box information for the Gizmo
  52483. */
  52484. updateBoundingBox(): void;
  52485. private _updateRotationSpheres;
  52486. private _updateScaleBoxes;
  52487. /**
  52488. * Enables rotation on the specified axis and disables rotation on the others
  52489. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52490. */
  52491. setEnabledRotationAxis(axis: string): void;
  52492. /**
  52493. * Enables/disables scaling
  52494. * @param enable if scaling should be enabled
  52495. * @param homogeneousScaling defines if scaling should only be homogeneous
  52496. */
  52497. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52498. private _updateDummy;
  52499. /**
  52500. * Enables a pointer drag behavior on the bounding box of the gizmo
  52501. */
  52502. enableDragBehavior(): void;
  52503. /**
  52504. * Disposes of the gizmo
  52505. */
  52506. dispose(): void;
  52507. /**
  52508. * 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)
  52509. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52510. * @returns the bounding box mesh with the passed in mesh as a child
  52511. */
  52512. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52513. /**
  52514. * CustomMeshes are not supported by this gizmo
  52515. * @param mesh The mesh to replace the default mesh of the gizmo
  52516. */
  52517. setCustomMesh(mesh: Mesh): void;
  52518. }
  52519. }
  52520. declare module BABYLON {
  52521. /**
  52522. * Single plane rotation gizmo
  52523. */
  52524. export class PlaneRotationGizmo extends Gizmo {
  52525. /**
  52526. * Drag behavior responsible for the gizmos dragging interactions
  52527. */
  52528. dragBehavior: PointerDragBehavior;
  52529. private _pointerObserver;
  52530. /**
  52531. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52532. */
  52533. snapDistance: number;
  52534. /**
  52535. * Event that fires each time the gizmo snaps to a new location.
  52536. * * snapDistance is the the change in distance
  52537. */
  52538. onSnapObservable: Observable<{
  52539. snapDistance: number;
  52540. }>;
  52541. private _isEnabled;
  52542. private _parent;
  52543. /**
  52544. * Creates a PlaneRotationGizmo
  52545. * @param gizmoLayer The utility layer the gizmo will be added to
  52546. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52547. * @param color The color of the gizmo
  52548. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52549. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52550. */
  52551. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52552. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52553. /**
  52554. * If the gizmo is enabled
  52555. */
  52556. set isEnabled(value: boolean);
  52557. get isEnabled(): boolean;
  52558. /**
  52559. * Disposes of the gizmo
  52560. */
  52561. dispose(): void;
  52562. }
  52563. }
  52564. declare module BABYLON {
  52565. /**
  52566. * Gizmo that enables rotating a mesh along 3 axis
  52567. */
  52568. export class RotationGizmo extends Gizmo {
  52569. /**
  52570. * Internal gizmo used for interactions on the x axis
  52571. */
  52572. xGizmo: PlaneRotationGizmo;
  52573. /**
  52574. * Internal gizmo used for interactions on the y axis
  52575. */
  52576. yGizmo: PlaneRotationGizmo;
  52577. /**
  52578. * Internal gizmo used for interactions on the z axis
  52579. */
  52580. zGizmo: PlaneRotationGizmo;
  52581. /** Fires an event when any of it's sub gizmos are dragged */
  52582. onDragStartObservable: Observable<unknown>;
  52583. /** Fires an event when any of it's sub gizmos are released from dragging */
  52584. onDragEndObservable: Observable<unknown>;
  52585. private _meshAttached;
  52586. get attachedMesh(): Nullable<AbstractMesh>;
  52587. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52588. /**
  52589. * Creates a RotationGizmo
  52590. * @param gizmoLayer The utility layer the gizmo will be added to
  52591. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52592. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52593. */
  52594. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52595. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52596. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52597. /**
  52598. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52599. */
  52600. set snapDistance(value: number);
  52601. get snapDistance(): number;
  52602. /**
  52603. * Ratio for the scale of the gizmo (Default: 1)
  52604. */
  52605. set scaleRatio(value: number);
  52606. get scaleRatio(): number;
  52607. /**
  52608. * Disposes of the gizmo
  52609. */
  52610. dispose(): void;
  52611. /**
  52612. * CustomMeshes are not supported by this gizmo
  52613. * @param mesh The mesh to replace the default mesh of the gizmo
  52614. */
  52615. setCustomMesh(mesh: Mesh): void;
  52616. }
  52617. }
  52618. declare module BABYLON {
  52619. /**
  52620. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52621. */
  52622. export class GizmoManager implements IDisposable {
  52623. private scene;
  52624. /**
  52625. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52626. */
  52627. gizmos: {
  52628. positionGizmo: Nullable<PositionGizmo>;
  52629. rotationGizmo: Nullable<RotationGizmo>;
  52630. scaleGizmo: Nullable<ScaleGizmo>;
  52631. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52632. };
  52633. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52634. clearGizmoOnEmptyPointerEvent: boolean;
  52635. /** Fires an event when the manager is attached to a mesh */
  52636. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52637. private _gizmosEnabled;
  52638. private _pointerObserver;
  52639. private _attachedMesh;
  52640. private _boundingBoxColor;
  52641. private _defaultUtilityLayer;
  52642. private _defaultKeepDepthUtilityLayer;
  52643. /**
  52644. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52645. */
  52646. boundingBoxDragBehavior: SixDofDragBehavior;
  52647. /**
  52648. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52649. */
  52650. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52651. /**
  52652. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52653. */
  52654. usePointerToAttachGizmos: boolean;
  52655. /**
  52656. * Utility layer that the bounding box gizmo belongs to
  52657. */
  52658. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52659. /**
  52660. * Utility layer that all gizmos besides bounding box belong to
  52661. */
  52662. get utilityLayer(): UtilityLayerRenderer;
  52663. /**
  52664. * Instatiates a gizmo manager
  52665. * @param scene the scene to overlay the gizmos on top of
  52666. */
  52667. constructor(scene: Scene);
  52668. /**
  52669. * Attaches a set of gizmos to the specified mesh
  52670. * @param mesh The mesh the gizmo's should be attached to
  52671. */
  52672. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52673. /**
  52674. * If the position gizmo is enabled
  52675. */
  52676. set positionGizmoEnabled(value: boolean);
  52677. get positionGizmoEnabled(): boolean;
  52678. /**
  52679. * If the rotation gizmo is enabled
  52680. */
  52681. set rotationGizmoEnabled(value: boolean);
  52682. get rotationGizmoEnabled(): boolean;
  52683. /**
  52684. * If the scale gizmo is enabled
  52685. */
  52686. set scaleGizmoEnabled(value: boolean);
  52687. get scaleGizmoEnabled(): boolean;
  52688. /**
  52689. * If the boundingBox gizmo is enabled
  52690. */
  52691. set boundingBoxGizmoEnabled(value: boolean);
  52692. get boundingBoxGizmoEnabled(): boolean;
  52693. /**
  52694. * Disposes of the gizmo manager
  52695. */
  52696. dispose(): void;
  52697. }
  52698. }
  52699. declare module BABYLON {
  52700. /**
  52701. * A directional light is defined by a direction (what a surprise!).
  52702. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52703. * 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.
  52704. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52705. */
  52706. export class DirectionalLight extends ShadowLight {
  52707. private _shadowFrustumSize;
  52708. /**
  52709. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52710. */
  52711. get shadowFrustumSize(): number;
  52712. /**
  52713. * Specifies a fix frustum size for the shadow generation.
  52714. */
  52715. set shadowFrustumSize(value: number);
  52716. private _shadowOrthoScale;
  52717. /**
  52718. * Gets the shadow projection scale against the optimal computed one.
  52719. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52720. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52721. */
  52722. get shadowOrthoScale(): number;
  52723. /**
  52724. * Sets the shadow projection scale against the optimal computed one.
  52725. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52726. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52727. */
  52728. set shadowOrthoScale(value: number);
  52729. /**
  52730. * Automatically compute the projection matrix to best fit (including all the casters)
  52731. * on each frame.
  52732. */
  52733. autoUpdateExtends: boolean;
  52734. /**
  52735. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52736. * on each frame. autoUpdateExtends must be set to true for this to work
  52737. */
  52738. autoCalcShadowZBounds: boolean;
  52739. private _orthoLeft;
  52740. private _orthoRight;
  52741. private _orthoTop;
  52742. private _orthoBottom;
  52743. /**
  52744. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52745. * The directional light is emitted from everywhere in the given direction.
  52746. * It can cast shadows.
  52747. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52748. * @param name The friendly name of the light
  52749. * @param direction The direction of the light
  52750. * @param scene The scene the light belongs to
  52751. */
  52752. constructor(name: string, direction: Vector3, scene: Scene);
  52753. /**
  52754. * Returns the string "DirectionalLight".
  52755. * @return The class name
  52756. */
  52757. getClassName(): string;
  52758. /**
  52759. * Returns the integer 1.
  52760. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52761. */
  52762. getTypeID(): number;
  52763. /**
  52764. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52765. * Returns the DirectionalLight Shadow projection matrix.
  52766. */
  52767. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52768. /**
  52769. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52770. * Returns the DirectionalLight Shadow projection matrix.
  52771. */
  52772. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52773. /**
  52774. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52775. * Returns the DirectionalLight Shadow projection matrix.
  52776. */
  52777. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52778. protected _buildUniformLayout(): void;
  52779. /**
  52780. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52781. * @param effect The effect to update
  52782. * @param lightIndex The index of the light in the effect to update
  52783. * @returns The directional light
  52784. */
  52785. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52786. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52787. /**
  52788. * Gets the minZ used for shadow according to both the scene and the light.
  52789. *
  52790. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52791. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52792. * @param activeCamera The camera we are returning the min for
  52793. * @returns the depth min z
  52794. */
  52795. getDepthMinZ(activeCamera: Camera): number;
  52796. /**
  52797. * Gets the maxZ used for shadow according to both the scene and the light.
  52798. *
  52799. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52800. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52801. * @param activeCamera The camera we are returning the max for
  52802. * @returns the depth max z
  52803. */
  52804. getDepthMaxZ(activeCamera: Camera): number;
  52805. /**
  52806. * Prepares the list of defines specific to the light type.
  52807. * @param defines the list of defines
  52808. * @param lightIndex defines the index of the light for the effect
  52809. */
  52810. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52811. }
  52812. }
  52813. declare module BABYLON {
  52814. /**
  52815. * Class containing static functions to help procedurally build meshes
  52816. */
  52817. export class HemisphereBuilder {
  52818. /**
  52819. * Creates a hemisphere mesh
  52820. * @param name defines the name of the mesh
  52821. * @param options defines the options used to create the mesh
  52822. * @param scene defines the hosting scene
  52823. * @returns the hemisphere mesh
  52824. */
  52825. static CreateHemisphere(name: string, options: {
  52826. segments?: number;
  52827. diameter?: number;
  52828. sideOrientation?: number;
  52829. }, scene: any): Mesh;
  52830. }
  52831. }
  52832. declare module BABYLON {
  52833. /**
  52834. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52835. * These values define a cone of light starting from the position, emitting toward the direction.
  52836. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52837. * and the exponent defines the speed of the decay of the light with distance (reach).
  52838. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52839. */
  52840. export class SpotLight extends ShadowLight {
  52841. private _angle;
  52842. private _innerAngle;
  52843. private _cosHalfAngle;
  52844. private _lightAngleScale;
  52845. private _lightAngleOffset;
  52846. /**
  52847. * Gets the cone angle of the spot light in Radians.
  52848. */
  52849. get angle(): number;
  52850. /**
  52851. * Sets the cone angle of the spot light in Radians.
  52852. */
  52853. set angle(value: number);
  52854. /**
  52855. * Only used in gltf falloff mode, this defines the angle where
  52856. * the directional falloff will start before cutting at angle which could be seen
  52857. * as outer angle.
  52858. */
  52859. get innerAngle(): number;
  52860. /**
  52861. * Only used in gltf falloff mode, this defines the angle where
  52862. * the directional falloff will start before cutting at angle which could be seen
  52863. * as outer angle.
  52864. */
  52865. set innerAngle(value: number);
  52866. private _shadowAngleScale;
  52867. /**
  52868. * Allows scaling the angle of the light for shadow generation only.
  52869. */
  52870. get shadowAngleScale(): number;
  52871. /**
  52872. * Allows scaling the angle of the light for shadow generation only.
  52873. */
  52874. set shadowAngleScale(value: number);
  52875. /**
  52876. * The light decay speed with the distance from the emission spot.
  52877. */
  52878. exponent: number;
  52879. private _projectionTextureMatrix;
  52880. /**
  52881. * Allows reading the projecton texture
  52882. */
  52883. get projectionTextureMatrix(): Matrix;
  52884. protected _projectionTextureLightNear: number;
  52885. /**
  52886. * Gets the near clip of the Spotlight for texture projection.
  52887. */
  52888. get projectionTextureLightNear(): number;
  52889. /**
  52890. * Sets the near clip of the Spotlight for texture projection.
  52891. */
  52892. set projectionTextureLightNear(value: number);
  52893. protected _projectionTextureLightFar: number;
  52894. /**
  52895. * Gets the far clip of the Spotlight for texture projection.
  52896. */
  52897. get projectionTextureLightFar(): number;
  52898. /**
  52899. * Sets the far clip of the Spotlight for texture projection.
  52900. */
  52901. set projectionTextureLightFar(value: number);
  52902. protected _projectionTextureUpDirection: Vector3;
  52903. /**
  52904. * Gets the Up vector of the Spotlight for texture projection.
  52905. */
  52906. get projectionTextureUpDirection(): Vector3;
  52907. /**
  52908. * Sets the Up vector of the Spotlight for texture projection.
  52909. */
  52910. set projectionTextureUpDirection(value: Vector3);
  52911. private _projectionTexture;
  52912. /**
  52913. * Gets the projection texture of the light.
  52914. */
  52915. get projectionTexture(): Nullable<BaseTexture>;
  52916. /**
  52917. * Sets the projection texture of the light.
  52918. */
  52919. set projectionTexture(value: Nullable<BaseTexture>);
  52920. private _projectionTextureViewLightDirty;
  52921. private _projectionTextureProjectionLightDirty;
  52922. private _projectionTextureDirty;
  52923. private _projectionTextureViewTargetVector;
  52924. private _projectionTextureViewLightMatrix;
  52925. private _projectionTextureProjectionLightMatrix;
  52926. private _projectionTextureScalingMatrix;
  52927. /**
  52928. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52929. * It can cast shadows.
  52930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52931. * @param name The light friendly name
  52932. * @param position The position of the spot light in the scene
  52933. * @param direction The direction of the light in the scene
  52934. * @param angle The cone angle of the light in Radians
  52935. * @param exponent The light decay speed with the distance from the emission spot
  52936. * @param scene The scene the lights belongs to
  52937. */
  52938. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52939. /**
  52940. * Returns the string "SpotLight".
  52941. * @returns the class name
  52942. */
  52943. getClassName(): string;
  52944. /**
  52945. * Returns the integer 2.
  52946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52947. */
  52948. getTypeID(): number;
  52949. /**
  52950. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52951. */
  52952. protected _setDirection(value: Vector3): void;
  52953. /**
  52954. * Overrides the position setter to recompute the projection texture view light Matrix.
  52955. */
  52956. protected _setPosition(value: Vector3): void;
  52957. /**
  52958. * 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.
  52959. * Returns the SpotLight.
  52960. */
  52961. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52962. protected _computeProjectionTextureViewLightMatrix(): void;
  52963. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52964. /**
  52965. * Main function for light texture projection matrix computing.
  52966. */
  52967. protected _computeProjectionTextureMatrix(): void;
  52968. protected _buildUniformLayout(): void;
  52969. private _computeAngleValues;
  52970. /**
  52971. * Sets the passed Effect "effect" with the Light textures.
  52972. * @param effect The effect to update
  52973. * @param lightIndex The index of the light in the effect to update
  52974. * @returns The light
  52975. */
  52976. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52977. /**
  52978. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52979. * @param effect The effect to update
  52980. * @param lightIndex The index of the light in the effect to update
  52981. * @returns The spot light
  52982. */
  52983. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52984. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52985. /**
  52986. * Disposes the light and the associated resources.
  52987. */
  52988. dispose(): void;
  52989. /**
  52990. * Prepares the list of defines specific to the light type.
  52991. * @param defines the list of defines
  52992. * @param lightIndex defines the index of the light for the effect
  52993. */
  52994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52995. }
  52996. }
  52997. declare module BABYLON {
  52998. /**
  52999. * Gizmo that enables viewing a light
  53000. */
  53001. export class LightGizmo extends Gizmo {
  53002. private _lightMesh;
  53003. private _material;
  53004. private _cachedPosition;
  53005. private _cachedForward;
  53006. private _attachedMeshParent;
  53007. /**
  53008. * Creates a LightGizmo
  53009. * @param gizmoLayer The utility layer the gizmo will be added to
  53010. */
  53011. constructor(gizmoLayer?: UtilityLayerRenderer);
  53012. private _light;
  53013. /**
  53014. * The light that the gizmo is attached to
  53015. */
  53016. set light(light: Nullable<Light>);
  53017. get light(): Nullable<Light>;
  53018. /**
  53019. * Gets the material used to render the light gizmo
  53020. */
  53021. get material(): StandardMaterial;
  53022. /**
  53023. * @hidden
  53024. * Updates the gizmo to match the attached mesh's position/rotation
  53025. */
  53026. protected _update(): void;
  53027. private static _Scale;
  53028. /**
  53029. * Creates the lines for a light mesh
  53030. */
  53031. private static _CreateLightLines;
  53032. /**
  53033. * Disposes of the light gizmo
  53034. */
  53035. dispose(): void;
  53036. private static _CreateHemisphericLightMesh;
  53037. private static _CreatePointLightMesh;
  53038. private static _CreateSpotLightMesh;
  53039. private static _CreateDirectionalLightMesh;
  53040. }
  53041. }
  53042. declare module BABYLON {
  53043. /** @hidden */
  53044. export var backgroundFragmentDeclaration: {
  53045. name: string;
  53046. shader: string;
  53047. };
  53048. }
  53049. declare module BABYLON {
  53050. /** @hidden */
  53051. export var backgroundUboDeclaration: {
  53052. name: string;
  53053. shader: string;
  53054. };
  53055. }
  53056. declare module BABYLON {
  53057. /** @hidden */
  53058. export var backgroundPixelShader: {
  53059. name: string;
  53060. shader: string;
  53061. };
  53062. }
  53063. declare module BABYLON {
  53064. /** @hidden */
  53065. export var backgroundVertexDeclaration: {
  53066. name: string;
  53067. shader: string;
  53068. };
  53069. }
  53070. declare module BABYLON {
  53071. /** @hidden */
  53072. export var backgroundVertexShader: {
  53073. name: string;
  53074. shader: string;
  53075. };
  53076. }
  53077. declare module BABYLON {
  53078. /**
  53079. * Background material used to create an efficient environement around your scene.
  53080. */
  53081. export class BackgroundMaterial extends PushMaterial {
  53082. /**
  53083. * Standard reflectance value at parallel view angle.
  53084. */
  53085. static StandardReflectance0: number;
  53086. /**
  53087. * Standard reflectance value at grazing angle.
  53088. */
  53089. static StandardReflectance90: number;
  53090. protected _primaryColor: Color3;
  53091. /**
  53092. * Key light Color (multiply against the environement texture)
  53093. */
  53094. primaryColor: Color3;
  53095. protected __perceptualColor: Nullable<Color3>;
  53096. /**
  53097. * Experimental Internal Use Only.
  53098. *
  53099. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53100. * This acts as a helper to set the primary color to a more "human friendly" value.
  53101. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53102. * output color as close as possible from the chosen value.
  53103. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53104. * part of lighting setup.)
  53105. */
  53106. get _perceptualColor(): Nullable<Color3>;
  53107. set _perceptualColor(value: Nullable<Color3>);
  53108. protected _primaryColorShadowLevel: float;
  53109. /**
  53110. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53111. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53112. */
  53113. get primaryColorShadowLevel(): float;
  53114. set primaryColorShadowLevel(value: float);
  53115. protected _primaryColorHighlightLevel: float;
  53116. /**
  53117. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53118. * The primary color is used at the level chosen to define what the white area would look.
  53119. */
  53120. get primaryColorHighlightLevel(): float;
  53121. set primaryColorHighlightLevel(value: float);
  53122. protected _reflectionTexture: Nullable<BaseTexture>;
  53123. /**
  53124. * Reflection Texture used in the material.
  53125. * Should be author in a specific way for the best result (refer to the documentation).
  53126. */
  53127. reflectionTexture: Nullable<BaseTexture>;
  53128. protected _reflectionBlur: float;
  53129. /**
  53130. * Reflection Texture level of blur.
  53131. *
  53132. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53133. * texture twice.
  53134. */
  53135. reflectionBlur: float;
  53136. protected _diffuseTexture: Nullable<BaseTexture>;
  53137. /**
  53138. * Diffuse Texture used in the material.
  53139. * Should be author in a specific way for the best result (refer to the documentation).
  53140. */
  53141. diffuseTexture: Nullable<BaseTexture>;
  53142. protected _shadowLights: Nullable<IShadowLight[]>;
  53143. /**
  53144. * Specify the list of lights casting shadow on the material.
  53145. * All scene shadow lights will be included if null.
  53146. */
  53147. shadowLights: Nullable<IShadowLight[]>;
  53148. protected _shadowLevel: float;
  53149. /**
  53150. * Helps adjusting the shadow to a softer level if required.
  53151. * 0 means black shadows and 1 means no shadows.
  53152. */
  53153. shadowLevel: float;
  53154. protected _sceneCenter: Vector3;
  53155. /**
  53156. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53157. * It is usually zero but might be interesting to modify according to your setup.
  53158. */
  53159. sceneCenter: Vector3;
  53160. protected _opacityFresnel: boolean;
  53161. /**
  53162. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53163. * This helps ensuring a nice transition when the camera goes under the ground.
  53164. */
  53165. opacityFresnel: boolean;
  53166. protected _reflectionFresnel: boolean;
  53167. /**
  53168. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53169. * This helps adding a mirror texture on the ground.
  53170. */
  53171. reflectionFresnel: boolean;
  53172. protected _reflectionFalloffDistance: number;
  53173. /**
  53174. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53175. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53176. */
  53177. reflectionFalloffDistance: number;
  53178. protected _reflectionAmount: number;
  53179. /**
  53180. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53181. */
  53182. reflectionAmount: number;
  53183. protected _reflectionReflectance0: number;
  53184. /**
  53185. * This specifies the weight of the reflection at grazing angle.
  53186. */
  53187. reflectionReflectance0: number;
  53188. protected _reflectionReflectance90: number;
  53189. /**
  53190. * This specifies the weight of the reflection at a perpendicular point of view.
  53191. */
  53192. reflectionReflectance90: number;
  53193. /**
  53194. * Sets the reflection reflectance fresnel values according to the default standard
  53195. * empirically know to work well :-)
  53196. */
  53197. set reflectionStandardFresnelWeight(value: number);
  53198. protected _useRGBColor: boolean;
  53199. /**
  53200. * Helps to directly use the maps channels instead of their level.
  53201. */
  53202. useRGBColor: boolean;
  53203. protected _enableNoise: boolean;
  53204. /**
  53205. * This helps reducing the banding effect that could occur on the background.
  53206. */
  53207. enableNoise: boolean;
  53208. /**
  53209. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53210. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53211. * Recommended to be keep at 1.0 except for special cases.
  53212. */
  53213. get fovMultiplier(): number;
  53214. set fovMultiplier(value: number);
  53215. private _fovMultiplier;
  53216. /**
  53217. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53218. */
  53219. useEquirectangularFOV: boolean;
  53220. private _maxSimultaneousLights;
  53221. /**
  53222. * Number of Simultaneous lights allowed on the material.
  53223. */
  53224. maxSimultaneousLights: int;
  53225. /**
  53226. * Default configuration related to image processing available in the Background Material.
  53227. */
  53228. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53229. /**
  53230. * Keep track of the image processing observer to allow dispose and replace.
  53231. */
  53232. private _imageProcessingObserver;
  53233. /**
  53234. * Attaches a new image processing configuration to the PBR Material.
  53235. * @param configuration (if null the scene configuration will be use)
  53236. */
  53237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53238. /**
  53239. * Gets the image processing configuration used either in this material.
  53240. */
  53241. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53242. /**
  53243. * Sets the Default image processing configuration used either in the this material.
  53244. *
  53245. * If sets to null, the scene one is in use.
  53246. */
  53247. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53248. /**
  53249. * Gets wether the color curves effect is enabled.
  53250. */
  53251. get cameraColorCurvesEnabled(): boolean;
  53252. /**
  53253. * Sets wether the color curves effect is enabled.
  53254. */
  53255. set cameraColorCurvesEnabled(value: boolean);
  53256. /**
  53257. * Gets wether the color grading effect is enabled.
  53258. */
  53259. get cameraColorGradingEnabled(): boolean;
  53260. /**
  53261. * Gets wether the color grading effect is enabled.
  53262. */
  53263. set cameraColorGradingEnabled(value: boolean);
  53264. /**
  53265. * Gets wether tonemapping is enabled or not.
  53266. */
  53267. get cameraToneMappingEnabled(): boolean;
  53268. /**
  53269. * Sets wether tonemapping is enabled or not
  53270. */
  53271. set cameraToneMappingEnabled(value: boolean);
  53272. /**
  53273. * The camera exposure used on this material.
  53274. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53275. * This corresponds to a photographic exposure.
  53276. */
  53277. get cameraExposure(): float;
  53278. /**
  53279. * The camera exposure used on this material.
  53280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53281. * This corresponds to a photographic exposure.
  53282. */
  53283. set cameraExposure(value: float);
  53284. /**
  53285. * Gets The camera contrast used on this material.
  53286. */
  53287. get cameraContrast(): float;
  53288. /**
  53289. * Sets The camera contrast used on this material.
  53290. */
  53291. set cameraContrast(value: float);
  53292. /**
  53293. * Gets the Color Grading 2D Lookup Texture.
  53294. */
  53295. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53296. /**
  53297. * Sets the Color Grading 2D Lookup Texture.
  53298. */
  53299. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53300. /**
  53301. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53302. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53303. * 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;
  53304. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53305. */
  53306. get cameraColorCurves(): Nullable<ColorCurves>;
  53307. /**
  53308. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53309. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53310. * 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;
  53311. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53312. */
  53313. set cameraColorCurves(value: Nullable<ColorCurves>);
  53314. /**
  53315. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53316. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53317. */
  53318. switchToBGR: boolean;
  53319. private _renderTargets;
  53320. private _reflectionControls;
  53321. private _white;
  53322. private _primaryShadowColor;
  53323. private _primaryHighlightColor;
  53324. /**
  53325. * Instantiates a Background Material in the given scene
  53326. * @param name The friendly name of the material
  53327. * @param scene The scene to add the material to
  53328. */
  53329. constructor(name: string, scene: Scene);
  53330. /**
  53331. * Gets a boolean indicating that current material needs to register RTT
  53332. */
  53333. get hasRenderTargetTextures(): boolean;
  53334. /**
  53335. * The entire material has been created in order to prevent overdraw.
  53336. * @returns false
  53337. */
  53338. needAlphaTesting(): boolean;
  53339. /**
  53340. * The entire material has been created in order to prevent overdraw.
  53341. * @returns true if blending is enable
  53342. */
  53343. needAlphaBlending(): boolean;
  53344. /**
  53345. * Checks wether the material is ready to be rendered for a given mesh.
  53346. * @param mesh The mesh to render
  53347. * @param subMesh The submesh to check against
  53348. * @param useInstances Specify wether or not the material is used with instances
  53349. * @returns true if all the dependencies are ready (Textures, Effects...)
  53350. */
  53351. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53352. /**
  53353. * Compute the primary color according to the chosen perceptual color.
  53354. */
  53355. private _computePrimaryColorFromPerceptualColor;
  53356. /**
  53357. * Compute the highlights and shadow colors according to their chosen levels.
  53358. */
  53359. private _computePrimaryColors;
  53360. /**
  53361. * Build the uniform buffer used in the material.
  53362. */
  53363. buildUniformLayout(): void;
  53364. /**
  53365. * Unbind the material.
  53366. */
  53367. unbind(): void;
  53368. /**
  53369. * Bind only the world matrix to the material.
  53370. * @param world The world matrix to bind.
  53371. */
  53372. bindOnlyWorldMatrix(world: Matrix): void;
  53373. /**
  53374. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53375. * @param world The world matrix to bind.
  53376. * @param subMesh The submesh to bind for.
  53377. */
  53378. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53379. /**
  53380. * Checks to see if a texture is used in the material.
  53381. * @param texture - Base texture to use.
  53382. * @returns - Boolean specifying if a texture is used in the material.
  53383. */
  53384. hasTexture(texture: BaseTexture): boolean;
  53385. /**
  53386. * Dispose the material.
  53387. * @param forceDisposeEffect Force disposal of the associated effect.
  53388. * @param forceDisposeTextures Force disposal of the associated textures.
  53389. */
  53390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53391. /**
  53392. * Clones the material.
  53393. * @param name The cloned name.
  53394. * @returns The cloned material.
  53395. */
  53396. clone(name: string): BackgroundMaterial;
  53397. /**
  53398. * Serializes the current material to its JSON representation.
  53399. * @returns The JSON representation.
  53400. */
  53401. serialize(): any;
  53402. /**
  53403. * Gets the class name of the material
  53404. * @returns "BackgroundMaterial"
  53405. */
  53406. getClassName(): string;
  53407. /**
  53408. * Parse a JSON input to create back a background material.
  53409. * @param source The JSON data to parse
  53410. * @param scene The scene to create the parsed material in
  53411. * @param rootUrl The root url of the assets the material depends upon
  53412. * @returns the instantiated BackgroundMaterial.
  53413. */
  53414. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53415. }
  53416. }
  53417. declare module BABYLON {
  53418. /**
  53419. * Represents the different options available during the creation of
  53420. * a Environment helper.
  53421. *
  53422. * This can control the default ground, skybox and image processing setup of your scene.
  53423. */
  53424. export interface IEnvironmentHelperOptions {
  53425. /**
  53426. * Specifies whether or not to create a ground.
  53427. * True by default.
  53428. */
  53429. createGround: boolean;
  53430. /**
  53431. * Specifies the ground size.
  53432. * 15 by default.
  53433. */
  53434. groundSize: number;
  53435. /**
  53436. * The texture used on the ground for the main color.
  53437. * Comes from the BabylonJS CDN by default.
  53438. *
  53439. * Remarks: Can be either a texture or a url.
  53440. */
  53441. groundTexture: string | BaseTexture;
  53442. /**
  53443. * The color mixed in the ground texture by default.
  53444. * BabylonJS clearColor by default.
  53445. */
  53446. groundColor: Color3;
  53447. /**
  53448. * Specifies the ground opacity.
  53449. * 1 by default.
  53450. */
  53451. groundOpacity: number;
  53452. /**
  53453. * Enables the ground to receive shadows.
  53454. * True by default.
  53455. */
  53456. enableGroundShadow: boolean;
  53457. /**
  53458. * Helps preventing the shadow to be fully black on the ground.
  53459. * 0.5 by default.
  53460. */
  53461. groundShadowLevel: number;
  53462. /**
  53463. * Creates a mirror texture attach to the ground.
  53464. * false by default.
  53465. */
  53466. enableGroundMirror: boolean;
  53467. /**
  53468. * Specifies the ground mirror size ratio.
  53469. * 0.3 by default as the default kernel is 64.
  53470. */
  53471. groundMirrorSizeRatio: number;
  53472. /**
  53473. * Specifies the ground mirror blur kernel size.
  53474. * 64 by default.
  53475. */
  53476. groundMirrorBlurKernel: number;
  53477. /**
  53478. * Specifies the ground mirror visibility amount.
  53479. * 1 by default
  53480. */
  53481. groundMirrorAmount: number;
  53482. /**
  53483. * Specifies the ground mirror reflectance weight.
  53484. * This uses the standard weight of the background material to setup the fresnel effect
  53485. * of the mirror.
  53486. * 1 by default.
  53487. */
  53488. groundMirrorFresnelWeight: number;
  53489. /**
  53490. * Specifies the ground mirror Falloff distance.
  53491. * This can helps reducing the size of the reflection.
  53492. * 0 by Default.
  53493. */
  53494. groundMirrorFallOffDistance: number;
  53495. /**
  53496. * Specifies the ground mirror texture type.
  53497. * Unsigned Int by Default.
  53498. */
  53499. groundMirrorTextureType: number;
  53500. /**
  53501. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53502. * the shown objects.
  53503. */
  53504. groundYBias: number;
  53505. /**
  53506. * Specifies whether or not to create a skybox.
  53507. * True by default.
  53508. */
  53509. createSkybox: boolean;
  53510. /**
  53511. * Specifies the skybox size.
  53512. * 20 by default.
  53513. */
  53514. skyboxSize: number;
  53515. /**
  53516. * The texture used on the skybox for the main color.
  53517. * Comes from the BabylonJS CDN by default.
  53518. *
  53519. * Remarks: Can be either a texture or a url.
  53520. */
  53521. skyboxTexture: string | BaseTexture;
  53522. /**
  53523. * The color mixed in the skybox texture by default.
  53524. * BabylonJS clearColor by default.
  53525. */
  53526. skyboxColor: Color3;
  53527. /**
  53528. * The background rotation around the Y axis of the scene.
  53529. * This helps aligning the key lights of your scene with the background.
  53530. * 0 by default.
  53531. */
  53532. backgroundYRotation: number;
  53533. /**
  53534. * Compute automatically the size of the elements to best fit with the scene.
  53535. */
  53536. sizeAuto: boolean;
  53537. /**
  53538. * Default position of the rootMesh if autoSize is not true.
  53539. */
  53540. rootPosition: Vector3;
  53541. /**
  53542. * Sets up the image processing in the scene.
  53543. * true by default.
  53544. */
  53545. setupImageProcessing: boolean;
  53546. /**
  53547. * The texture used as your environment texture in the scene.
  53548. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53549. *
  53550. * Remarks: Can be either a texture or a url.
  53551. */
  53552. environmentTexture: string | BaseTexture;
  53553. /**
  53554. * The value of the exposure to apply to the scene.
  53555. * 0.6 by default if setupImageProcessing is true.
  53556. */
  53557. cameraExposure: number;
  53558. /**
  53559. * The value of the contrast to apply to the scene.
  53560. * 1.6 by default if setupImageProcessing is true.
  53561. */
  53562. cameraContrast: number;
  53563. /**
  53564. * Specifies whether or not tonemapping should be enabled in the scene.
  53565. * true by default if setupImageProcessing is true.
  53566. */
  53567. toneMappingEnabled: boolean;
  53568. }
  53569. /**
  53570. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53571. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53572. * It also helps with the default setup of your imageProcessing configuration.
  53573. */
  53574. export class EnvironmentHelper {
  53575. /**
  53576. * Default ground texture URL.
  53577. */
  53578. private static _groundTextureCDNUrl;
  53579. /**
  53580. * Default skybox texture URL.
  53581. */
  53582. private static _skyboxTextureCDNUrl;
  53583. /**
  53584. * Default environment texture URL.
  53585. */
  53586. private static _environmentTextureCDNUrl;
  53587. /**
  53588. * Creates the default options for the helper.
  53589. */
  53590. private static _getDefaultOptions;
  53591. private _rootMesh;
  53592. /**
  53593. * Gets the root mesh created by the helper.
  53594. */
  53595. get rootMesh(): Mesh;
  53596. private _skybox;
  53597. /**
  53598. * Gets the skybox created by the helper.
  53599. */
  53600. get skybox(): Nullable<Mesh>;
  53601. private _skyboxTexture;
  53602. /**
  53603. * Gets the skybox texture created by the helper.
  53604. */
  53605. get skyboxTexture(): Nullable<BaseTexture>;
  53606. private _skyboxMaterial;
  53607. /**
  53608. * Gets the skybox material created by the helper.
  53609. */
  53610. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53611. private _ground;
  53612. /**
  53613. * Gets the ground mesh created by the helper.
  53614. */
  53615. get ground(): Nullable<Mesh>;
  53616. private _groundTexture;
  53617. /**
  53618. * Gets the ground texture created by the helper.
  53619. */
  53620. get groundTexture(): Nullable<BaseTexture>;
  53621. private _groundMirror;
  53622. /**
  53623. * Gets the ground mirror created by the helper.
  53624. */
  53625. get groundMirror(): Nullable<MirrorTexture>;
  53626. /**
  53627. * Gets the ground mirror render list to helps pushing the meshes
  53628. * you wish in the ground reflection.
  53629. */
  53630. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53631. private _groundMaterial;
  53632. /**
  53633. * Gets the ground material created by the helper.
  53634. */
  53635. get groundMaterial(): Nullable<BackgroundMaterial>;
  53636. /**
  53637. * Stores the creation options.
  53638. */
  53639. private readonly _scene;
  53640. private _options;
  53641. /**
  53642. * This observable will be notified with any error during the creation of the environment,
  53643. * mainly texture creation errors.
  53644. */
  53645. onErrorObservable: Observable<{
  53646. message?: string;
  53647. exception?: any;
  53648. }>;
  53649. /**
  53650. * constructor
  53651. * @param options Defines the options we want to customize the helper
  53652. * @param scene The scene to add the material to
  53653. */
  53654. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53655. /**
  53656. * Updates the background according to the new options
  53657. * @param options
  53658. */
  53659. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53660. /**
  53661. * Sets the primary color of all the available elements.
  53662. * @param color the main color to affect to the ground and the background
  53663. */
  53664. setMainColor(color: Color3): void;
  53665. /**
  53666. * Setup the image processing according to the specified options.
  53667. */
  53668. private _setupImageProcessing;
  53669. /**
  53670. * Setup the environment texture according to the specified options.
  53671. */
  53672. private _setupEnvironmentTexture;
  53673. /**
  53674. * Setup the background according to the specified options.
  53675. */
  53676. private _setupBackground;
  53677. /**
  53678. * Get the scene sizes according to the setup.
  53679. */
  53680. private _getSceneSize;
  53681. /**
  53682. * Setup the ground according to the specified options.
  53683. */
  53684. private _setupGround;
  53685. /**
  53686. * Setup the ground material according to the specified options.
  53687. */
  53688. private _setupGroundMaterial;
  53689. /**
  53690. * Setup the ground diffuse texture according to the specified options.
  53691. */
  53692. private _setupGroundDiffuseTexture;
  53693. /**
  53694. * Setup the ground mirror texture according to the specified options.
  53695. */
  53696. private _setupGroundMirrorTexture;
  53697. /**
  53698. * Setup the ground to receive the mirror texture.
  53699. */
  53700. private _setupMirrorInGroundMaterial;
  53701. /**
  53702. * Setup the skybox according to the specified options.
  53703. */
  53704. private _setupSkybox;
  53705. /**
  53706. * Setup the skybox material according to the specified options.
  53707. */
  53708. private _setupSkyboxMaterial;
  53709. /**
  53710. * Setup the skybox reflection texture according to the specified options.
  53711. */
  53712. private _setupSkyboxReflectionTexture;
  53713. private _errorHandler;
  53714. /**
  53715. * Dispose all the elements created by the Helper.
  53716. */
  53717. dispose(): void;
  53718. }
  53719. }
  53720. declare module BABYLON {
  53721. /**
  53722. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53723. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53724. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53725. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53726. */
  53727. export class PhotoDome extends TransformNode {
  53728. /**
  53729. * Define the image as a Monoscopic panoramic 360 image.
  53730. */
  53731. static readonly MODE_MONOSCOPIC: number;
  53732. /**
  53733. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53734. */
  53735. static readonly MODE_TOPBOTTOM: number;
  53736. /**
  53737. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53738. */
  53739. static readonly MODE_SIDEBYSIDE: number;
  53740. private _useDirectMapping;
  53741. /**
  53742. * The texture being displayed on the sphere
  53743. */
  53744. protected _photoTexture: Texture;
  53745. /**
  53746. * Gets or sets the texture being displayed on the sphere
  53747. */
  53748. get photoTexture(): Texture;
  53749. set photoTexture(value: Texture);
  53750. /**
  53751. * Observable raised when an error occured while loading the 360 image
  53752. */
  53753. onLoadErrorObservable: Observable<string>;
  53754. /**
  53755. * The skybox material
  53756. */
  53757. protected _material: BackgroundMaterial;
  53758. /**
  53759. * The surface used for the skybox
  53760. */
  53761. protected _mesh: Mesh;
  53762. /**
  53763. * Gets the mesh used for the skybox.
  53764. */
  53765. get mesh(): Mesh;
  53766. /**
  53767. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53768. * Also see the options.resolution property.
  53769. */
  53770. get fovMultiplier(): number;
  53771. set fovMultiplier(value: number);
  53772. private _imageMode;
  53773. /**
  53774. * Gets or set the current video mode for the video. It can be:
  53775. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53776. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53777. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53778. */
  53779. get imageMode(): number;
  53780. set imageMode(value: number);
  53781. /**
  53782. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53783. * @param name Element's name, child elements will append suffixes for their own names.
  53784. * @param urlsOfPhoto defines the url of the photo to display
  53785. * @param options defines an object containing optional or exposed sub element properties
  53786. * @param onError defines a callback called when an error occured while loading the texture
  53787. */
  53788. constructor(name: string, urlOfPhoto: string, options: {
  53789. resolution?: number;
  53790. size?: number;
  53791. useDirectMapping?: boolean;
  53792. faceForward?: boolean;
  53793. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53794. private _onBeforeCameraRenderObserver;
  53795. private _changeImageMode;
  53796. /**
  53797. * Releases resources associated with this node.
  53798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53800. */
  53801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53802. }
  53803. }
  53804. declare module BABYLON {
  53805. /**
  53806. * Class used to host RGBD texture specific utilities
  53807. */
  53808. export class RGBDTextureTools {
  53809. /**
  53810. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53811. * @param texture the texture to expand.
  53812. */
  53813. static ExpandRGBDTexture(texture: Texture): void;
  53814. }
  53815. }
  53816. declare module BABYLON {
  53817. /**
  53818. * Class used to host texture specific utilities
  53819. */
  53820. export class BRDFTextureTools {
  53821. /**
  53822. * Prevents texture cache collision
  53823. */
  53824. private static _instanceNumber;
  53825. /**
  53826. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53827. * @param scene defines the hosting scene
  53828. * @returns the environment BRDF texture
  53829. */
  53830. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53831. private static _environmentBRDFBase64Texture;
  53832. }
  53833. }
  53834. declare module BABYLON {
  53835. /**
  53836. * @hidden
  53837. */
  53838. export interface IMaterialClearCoatDefines {
  53839. CLEARCOAT: boolean;
  53840. CLEARCOAT_DEFAULTIOR: boolean;
  53841. CLEARCOAT_TEXTURE: boolean;
  53842. CLEARCOAT_TEXTUREDIRECTUV: number;
  53843. CLEARCOAT_BUMP: boolean;
  53844. CLEARCOAT_BUMPDIRECTUV: number;
  53845. CLEARCOAT_TINT: boolean;
  53846. CLEARCOAT_TINT_TEXTURE: boolean;
  53847. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53848. /** @hidden */
  53849. _areTexturesDirty: boolean;
  53850. }
  53851. /**
  53852. * Define the code related to the clear coat parameters of the pbr material.
  53853. */
  53854. export class PBRClearCoatConfiguration {
  53855. /**
  53856. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53857. * The default fits with a polyurethane material.
  53858. */
  53859. private static readonly _DefaultIndexOfRefraction;
  53860. private _isEnabled;
  53861. /**
  53862. * Defines if the clear coat is enabled in the material.
  53863. */
  53864. isEnabled: boolean;
  53865. /**
  53866. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53867. */
  53868. intensity: number;
  53869. /**
  53870. * Defines the clear coat layer roughness.
  53871. */
  53872. roughness: number;
  53873. private _indexOfRefraction;
  53874. /**
  53875. * Defines the index of refraction of the clear coat.
  53876. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53877. * The default fits with a polyurethane material.
  53878. * Changing the default value is more performance intensive.
  53879. */
  53880. indexOfRefraction: number;
  53881. private _texture;
  53882. /**
  53883. * Stores the clear coat values in a texture.
  53884. */
  53885. texture: Nullable<BaseTexture>;
  53886. private _bumpTexture;
  53887. /**
  53888. * Define the clear coat specific bump texture.
  53889. */
  53890. bumpTexture: Nullable<BaseTexture>;
  53891. private _isTintEnabled;
  53892. /**
  53893. * Defines if the clear coat tint is enabled in the material.
  53894. */
  53895. isTintEnabled: boolean;
  53896. /**
  53897. * Defines the clear coat tint of the material.
  53898. * This is only use if tint is enabled
  53899. */
  53900. tintColor: Color3;
  53901. /**
  53902. * Defines the distance at which the tint color should be found in the
  53903. * clear coat media.
  53904. * This is only use if tint is enabled
  53905. */
  53906. tintColorAtDistance: number;
  53907. /**
  53908. * Defines the clear coat layer thickness.
  53909. * This is only use if tint is enabled
  53910. */
  53911. tintThickness: number;
  53912. private _tintTexture;
  53913. /**
  53914. * Stores the clear tint values in a texture.
  53915. * rgb is tint
  53916. * a is a thickness factor
  53917. */
  53918. tintTexture: Nullable<BaseTexture>;
  53919. /** @hidden */
  53920. private _internalMarkAllSubMeshesAsTexturesDirty;
  53921. /** @hidden */
  53922. _markAllSubMeshesAsTexturesDirty(): void;
  53923. /**
  53924. * Instantiate a new istance of clear coat configuration.
  53925. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53926. */
  53927. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53928. /**
  53929. * Gets wehter the submesh is ready to be used or not.
  53930. * @param defines the list of "defines" to update.
  53931. * @param scene defines the scene the material belongs to.
  53932. * @param engine defines the engine the material belongs to.
  53933. * @param disableBumpMap defines wether the material disables bump or not.
  53934. * @returns - boolean indicating that the submesh is ready or not.
  53935. */
  53936. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53937. /**
  53938. * Checks to see if a texture is used in the material.
  53939. * @param defines the list of "defines" to update.
  53940. * @param scene defines the scene to the material belongs to.
  53941. */
  53942. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53943. /**
  53944. * Binds the material data.
  53945. * @param uniformBuffer defines the Uniform buffer to fill in.
  53946. * @param scene defines the scene the material belongs to.
  53947. * @param engine defines the engine the material belongs to.
  53948. * @param disableBumpMap defines wether the material disables bump or not.
  53949. * @param isFrozen defines wether the material is frozen or not.
  53950. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53951. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53952. */
  53953. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53954. /**
  53955. * Checks to see if a texture is used in the material.
  53956. * @param texture - Base texture to use.
  53957. * @returns - Boolean specifying if a texture is used in the material.
  53958. */
  53959. hasTexture(texture: BaseTexture): boolean;
  53960. /**
  53961. * Returns an array of the actively used textures.
  53962. * @param activeTextures Array of BaseTextures
  53963. */
  53964. getActiveTextures(activeTextures: BaseTexture[]): void;
  53965. /**
  53966. * Returns the animatable textures.
  53967. * @param animatables Array of animatable textures.
  53968. */
  53969. getAnimatables(animatables: IAnimatable[]): void;
  53970. /**
  53971. * Disposes the resources of the material.
  53972. * @param forceDisposeTextures - Forces the disposal of all textures.
  53973. */
  53974. dispose(forceDisposeTextures?: boolean): void;
  53975. /**
  53976. * Get the current class name of the texture useful for serialization or dynamic coding.
  53977. * @returns "PBRClearCoatConfiguration"
  53978. */
  53979. getClassName(): string;
  53980. /**
  53981. * Add fallbacks to the effect fallbacks list.
  53982. * @param defines defines the Base texture to use.
  53983. * @param fallbacks defines the current fallback list.
  53984. * @param currentRank defines the current fallback rank.
  53985. * @returns the new fallback rank.
  53986. */
  53987. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53988. /**
  53989. * Add the required uniforms to the current list.
  53990. * @param uniforms defines the current uniform list.
  53991. */
  53992. static AddUniforms(uniforms: string[]): void;
  53993. /**
  53994. * Add the required samplers to the current list.
  53995. * @param samplers defines the current sampler list.
  53996. */
  53997. static AddSamplers(samplers: string[]): void;
  53998. /**
  53999. * Add the required uniforms to the current buffer.
  54000. * @param uniformBuffer defines the current uniform buffer.
  54001. */
  54002. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54003. /**
  54004. * Makes a duplicate of the current configuration into another one.
  54005. * @param clearCoatConfiguration define the config where to copy the info
  54006. */
  54007. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54008. /**
  54009. * Serializes this clear coat configuration.
  54010. * @returns - An object with the serialized config.
  54011. */
  54012. serialize(): any;
  54013. /**
  54014. * Parses a anisotropy Configuration from a serialized object.
  54015. * @param source - Serialized object.
  54016. * @param scene Defines the scene we are parsing for
  54017. * @param rootUrl Defines the rootUrl to load from
  54018. */
  54019. parse(source: any, scene: Scene, rootUrl: string): void;
  54020. }
  54021. }
  54022. declare module BABYLON {
  54023. /**
  54024. * @hidden
  54025. */
  54026. export interface IMaterialAnisotropicDefines {
  54027. ANISOTROPIC: boolean;
  54028. ANISOTROPIC_TEXTURE: boolean;
  54029. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54030. MAINUV1: boolean;
  54031. _areTexturesDirty: boolean;
  54032. _needUVs: boolean;
  54033. }
  54034. /**
  54035. * Define the code related to the anisotropic parameters of the pbr material.
  54036. */
  54037. export class PBRAnisotropicConfiguration {
  54038. private _isEnabled;
  54039. /**
  54040. * Defines if the anisotropy is enabled in the material.
  54041. */
  54042. isEnabled: boolean;
  54043. /**
  54044. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54045. */
  54046. intensity: number;
  54047. /**
  54048. * Defines if the effect is along the tangents, bitangents or in between.
  54049. * By default, the effect is "strectching" the highlights along the tangents.
  54050. */
  54051. direction: Vector2;
  54052. private _texture;
  54053. /**
  54054. * Stores the anisotropy values in a texture.
  54055. * rg is direction (like normal from -1 to 1)
  54056. * b is a intensity
  54057. */
  54058. texture: Nullable<BaseTexture>;
  54059. /** @hidden */
  54060. private _internalMarkAllSubMeshesAsTexturesDirty;
  54061. /** @hidden */
  54062. _markAllSubMeshesAsTexturesDirty(): void;
  54063. /**
  54064. * Instantiate a new istance of anisotropy configuration.
  54065. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54066. */
  54067. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54068. /**
  54069. * Specifies that the submesh is ready to be used.
  54070. * @param defines the list of "defines" to update.
  54071. * @param scene defines the scene the material belongs to.
  54072. * @returns - boolean indicating that the submesh is ready or not.
  54073. */
  54074. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54075. /**
  54076. * Checks to see if a texture is used in the material.
  54077. * @param defines the list of "defines" to update.
  54078. * @param mesh the mesh we are preparing the defines for.
  54079. * @param scene defines the scene the material belongs to.
  54080. */
  54081. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54082. /**
  54083. * Binds the material data.
  54084. * @param uniformBuffer defines the Uniform buffer to fill in.
  54085. * @param scene defines the scene the material belongs to.
  54086. * @param isFrozen defines wether the material is frozen or not.
  54087. */
  54088. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54089. /**
  54090. * Checks to see if a texture is used in the material.
  54091. * @param texture - Base texture to use.
  54092. * @returns - Boolean specifying if a texture is used in the material.
  54093. */
  54094. hasTexture(texture: BaseTexture): boolean;
  54095. /**
  54096. * Returns an array of the actively used textures.
  54097. * @param activeTextures Array of BaseTextures
  54098. */
  54099. getActiveTextures(activeTextures: BaseTexture[]): void;
  54100. /**
  54101. * Returns the animatable textures.
  54102. * @param animatables Array of animatable textures.
  54103. */
  54104. getAnimatables(animatables: IAnimatable[]): void;
  54105. /**
  54106. * Disposes the resources of the material.
  54107. * @param forceDisposeTextures - Forces the disposal of all textures.
  54108. */
  54109. dispose(forceDisposeTextures?: boolean): void;
  54110. /**
  54111. * Get the current class name of the texture useful for serialization or dynamic coding.
  54112. * @returns "PBRAnisotropicConfiguration"
  54113. */
  54114. getClassName(): string;
  54115. /**
  54116. * Add fallbacks to the effect fallbacks list.
  54117. * @param defines defines the Base texture to use.
  54118. * @param fallbacks defines the current fallback list.
  54119. * @param currentRank defines the current fallback rank.
  54120. * @returns the new fallback rank.
  54121. */
  54122. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54123. /**
  54124. * Add the required uniforms to the current list.
  54125. * @param uniforms defines the current uniform list.
  54126. */
  54127. static AddUniforms(uniforms: string[]): void;
  54128. /**
  54129. * Add the required uniforms to the current buffer.
  54130. * @param uniformBuffer defines the current uniform buffer.
  54131. */
  54132. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54133. /**
  54134. * Add the required samplers to the current list.
  54135. * @param samplers defines the current sampler list.
  54136. */
  54137. static AddSamplers(samplers: string[]): void;
  54138. /**
  54139. * Makes a duplicate of the current configuration into another one.
  54140. * @param anisotropicConfiguration define the config where to copy the info
  54141. */
  54142. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54143. /**
  54144. * Serializes this anisotropy configuration.
  54145. * @returns - An object with the serialized config.
  54146. */
  54147. serialize(): any;
  54148. /**
  54149. * Parses a anisotropy Configuration from a serialized object.
  54150. * @param source - Serialized object.
  54151. * @param scene Defines the scene we are parsing for
  54152. * @param rootUrl Defines the rootUrl to load from
  54153. */
  54154. parse(source: any, scene: Scene, rootUrl: string): void;
  54155. }
  54156. }
  54157. declare module BABYLON {
  54158. /**
  54159. * @hidden
  54160. */
  54161. export interface IMaterialBRDFDefines {
  54162. BRDF_V_HEIGHT_CORRELATED: boolean;
  54163. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54164. SPHERICAL_HARMONICS: boolean;
  54165. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54166. /** @hidden */
  54167. _areMiscDirty: boolean;
  54168. }
  54169. /**
  54170. * Define the code related to the BRDF parameters of the pbr material.
  54171. */
  54172. export class PBRBRDFConfiguration {
  54173. /**
  54174. * Default value used for the energy conservation.
  54175. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54176. */
  54177. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54178. /**
  54179. * Default value used for the Smith Visibility Height Correlated mode.
  54180. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54181. */
  54182. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54183. /**
  54184. * Default value used for the IBL diffuse part.
  54185. * This can help switching back to the polynomials mode globally which is a tiny bit
  54186. * less GPU intensive at the drawback of a lower quality.
  54187. */
  54188. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54189. /**
  54190. * Default value used for activating energy conservation for the specular workflow.
  54191. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54192. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54193. */
  54194. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54195. private _useEnergyConservation;
  54196. /**
  54197. * Defines if the material uses energy conservation.
  54198. */
  54199. useEnergyConservation: boolean;
  54200. private _useSmithVisibilityHeightCorrelated;
  54201. /**
  54202. * LEGACY Mode set to false
  54203. * Defines if the material uses height smith correlated visibility term.
  54204. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54205. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54206. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54207. * Not relying on height correlated will also disable energy conservation.
  54208. */
  54209. useSmithVisibilityHeightCorrelated: boolean;
  54210. private _useSphericalHarmonics;
  54211. /**
  54212. * LEGACY Mode set to false
  54213. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54214. * diffuse part of the IBL.
  54215. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54216. * to the ground truth.
  54217. */
  54218. useSphericalHarmonics: boolean;
  54219. private _useSpecularGlossinessInputEnergyConservation;
  54220. /**
  54221. * Defines if the material uses energy conservation, when the specular workflow is active.
  54222. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54223. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54224. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54225. */
  54226. useSpecularGlossinessInputEnergyConservation: boolean;
  54227. /** @hidden */
  54228. private _internalMarkAllSubMeshesAsMiscDirty;
  54229. /** @hidden */
  54230. _markAllSubMeshesAsMiscDirty(): void;
  54231. /**
  54232. * Instantiate a new istance of clear coat configuration.
  54233. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54234. */
  54235. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54236. /**
  54237. * Checks to see if a texture is used in the material.
  54238. * @param defines the list of "defines" to update.
  54239. */
  54240. prepareDefines(defines: IMaterialBRDFDefines): void;
  54241. /**
  54242. * Get the current class name of the texture useful for serialization or dynamic coding.
  54243. * @returns "PBRClearCoatConfiguration"
  54244. */
  54245. getClassName(): string;
  54246. /**
  54247. * Makes a duplicate of the current configuration into another one.
  54248. * @param brdfConfiguration define the config where to copy the info
  54249. */
  54250. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54251. /**
  54252. * Serializes this BRDF configuration.
  54253. * @returns - An object with the serialized config.
  54254. */
  54255. serialize(): any;
  54256. /**
  54257. * Parses a anisotropy Configuration from a serialized object.
  54258. * @param source - Serialized object.
  54259. * @param scene Defines the scene we are parsing for
  54260. * @param rootUrl Defines the rootUrl to load from
  54261. */
  54262. parse(source: any, scene: Scene, rootUrl: string): void;
  54263. }
  54264. }
  54265. declare module BABYLON {
  54266. /**
  54267. * @hidden
  54268. */
  54269. export interface IMaterialSheenDefines {
  54270. SHEEN: boolean;
  54271. SHEEN_TEXTURE: boolean;
  54272. SHEEN_TEXTUREDIRECTUV: number;
  54273. SHEEN_LINKWITHALBEDO: boolean;
  54274. SHEEN_ROUGHNESS: boolean;
  54275. SHEEN_ALBEDOSCALING: boolean;
  54276. /** @hidden */
  54277. _areTexturesDirty: boolean;
  54278. }
  54279. /**
  54280. * Define the code related to the Sheen parameters of the pbr material.
  54281. */
  54282. export class PBRSheenConfiguration {
  54283. private _isEnabled;
  54284. /**
  54285. * Defines if the material uses sheen.
  54286. */
  54287. isEnabled: boolean;
  54288. private _linkSheenWithAlbedo;
  54289. /**
  54290. * Defines if the sheen is linked to the sheen color.
  54291. */
  54292. linkSheenWithAlbedo: boolean;
  54293. /**
  54294. * Defines the sheen intensity.
  54295. */
  54296. intensity: number;
  54297. /**
  54298. * Defines the sheen color.
  54299. */
  54300. color: Color3;
  54301. private _texture;
  54302. /**
  54303. * Stores the sheen tint values in a texture.
  54304. * rgb is tint
  54305. * a is a intensity
  54306. */
  54307. texture: Nullable<BaseTexture>;
  54308. private _roughness;
  54309. /**
  54310. * Defines the sheen roughness.
  54311. * It is not taken into account if linkSheenWithAlbedo is true.
  54312. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54313. */
  54314. roughness: Nullable<number>;
  54315. private _albedoScaling;
  54316. /**
  54317. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54318. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54319. * making it easier to setup and tweak the effect
  54320. */
  54321. albedoScaling: boolean;
  54322. /** @hidden */
  54323. private _internalMarkAllSubMeshesAsTexturesDirty;
  54324. /** @hidden */
  54325. _markAllSubMeshesAsTexturesDirty(): void;
  54326. /**
  54327. * Instantiate a new istance of clear coat configuration.
  54328. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54329. */
  54330. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54331. /**
  54332. * Specifies that the submesh is ready to be used.
  54333. * @param defines the list of "defines" to update.
  54334. * @param scene defines the scene the material belongs to.
  54335. * @returns - boolean indicating that the submesh is ready or not.
  54336. */
  54337. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54338. /**
  54339. * Checks to see if a texture is used in the material.
  54340. * @param defines the list of "defines" to update.
  54341. * @param scene defines the scene the material belongs to.
  54342. */
  54343. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54344. /**
  54345. * Binds the material data.
  54346. * @param uniformBuffer defines the Uniform buffer to fill in.
  54347. * @param scene defines the scene the material belongs to.
  54348. * @param isFrozen defines wether the material is frozen or not.
  54349. */
  54350. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54351. /**
  54352. * Checks to see if a texture is used in the material.
  54353. * @param texture - Base texture to use.
  54354. * @returns - Boolean specifying if a texture is used in the material.
  54355. */
  54356. hasTexture(texture: BaseTexture): boolean;
  54357. /**
  54358. * Returns an array of the actively used textures.
  54359. * @param activeTextures Array of BaseTextures
  54360. */
  54361. getActiveTextures(activeTextures: BaseTexture[]): void;
  54362. /**
  54363. * Returns the animatable textures.
  54364. * @param animatables Array of animatable textures.
  54365. */
  54366. getAnimatables(animatables: IAnimatable[]): void;
  54367. /**
  54368. * Disposes the resources of the material.
  54369. * @param forceDisposeTextures - Forces the disposal of all textures.
  54370. */
  54371. dispose(forceDisposeTextures?: boolean): void;
  54372. /**
  54373. * Get the current class name of the texture useful for serialization or dynamic coding.
  54374. * @returns "PBRSheenConfiguration"
  54375. */
  54376. getClassName(): string;
  54377. /**
  54378. * Add fallbacks to the effect fallbacks list.
  54379. * @param defines defines the Base texture to use.
  54380. * @param fallbacks defines the current fallback list.
  54381. * @param currentRank defines the current fallback rank.
  54382. * @returns the new fallback rank.
  54383. */
  54384. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54385. /**
  54386. * Add the required uniforms to the current list.
  54387. * @param uniforms defines the current uniform list.
  54388. */
  54389. static AddUniforms(uniforms: string[]): void;
  54390. /**
  54391. * Add the required uniforms to the current buffer.
  54392. * @param uniformBuffer defines the current uniform buffer.
  54393. */
  54394. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54395. /**
  54396. * Add the required samplers to the current list.
  54397. * @param samplers defines the current sampler list.
  54398. */
  54399. static AddSamplers(samplers: string[]): void;
  54400. /**
  54401. * Makes a duplicate of the current configuration into another one.
  54402. * @param sheenConfiguration define the config where to copy the info
  54403. */
  54404. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54405. /**
  54406. * Serializes this BRDF configuration.
  54407. * @returns - An object with the serialized config.
  54408. */
  54409. serialize(): any;
  54410. /**
  54411. * Parses a anisotropy Configuration from a serialized object.
  54412. * @param source - Serialized object.
  54413. * @param scene Defines the scene we are parsing for
  54414. * @param rootUrl Defines the rootUrl to load from
  54415. */
  54416. parse(source: any, scene: Scene, rootUrl: string): void;
  54417. }
  54418. }
  54419. declare module BABYLON {
  54420. /**
  54421. * @hidden
  54422. */
  54423. export interface IMaterialSubSurfaceDefines {
  54424. SUBSURFACE: boolean;
  54425. SS_REFRACTION: boolean;
  54426. SS_TRANSLUCENCY: boolean;
  54427. SS_SCATTERING: boolean;
  54428. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54429. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54430. SS_REFRACTIONMAP_3D: boolean;
  54431. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54432. SS_LODINREFRACTIONALPHA: boolean;
  54433. SS_GAMMAREFRACTION: boolean;
  54434. SS_RGBDREFRACTION: boolean;
  54435. SS_LINEARSPECULARREFRACTION: boolean;
  54436. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54437. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54438. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54439. /** @hidden */
  54440. _areTexturesDirty: boolean;
  54441. }
  54442. /**
  54443. * Define the code related to the sub surface parameters of the pbr material.
  54444. */
  54445. export class PBRSubSurfaceConfiguration {
  54446. private _isRefractionEnabled;
  54447. /**
  54448. * Defines if the refraction is enabled in the material.
  54449. */
  54450. isRefractionEnabled: boolean;
  54451. private _isTranslucencyEnabled;
  54452. /**
  54453. * Defines if the translucency is enabled in the material.
  54454. */
  54455. isTranslucencyEnabled: boolean;
  54456. private _isScatteringEnabled;
  54457. /**
  54458. * Defines the refraction intensity of the material.
  54459. * The refraction when enabled replaces the Diffuse part of the material.
  54460. * The intensity helps transitionning between diffuse and refraction.
  54461. */
  54462. refractionIntensity: number;
  54463. /**
  54464. * Defines the translucency intensity of the material.
  54465. * When translucency has been enabled, this defines how much of the "translucency"
  54466. * is addded to the diffuse part of the material.
  54467. */
  54468. translucencyIntensity: number;
  54469. /**
  54470. * Defines the scattering intensity of the material.
  54471. * When scattering has been enabled, this defines how much of the "scattered light"
  54472. * is addded to the diffuse part of the material.
  54473. */
  54474. scatteringIntensity: number;
  54475. /**
  54476. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54477. */
  54478. useAlbedoToTintRefraction: boolean;
  54479. private _thicknessTexture;
  54480. /**
  54481. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54482. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54483. * 0 would mean minimumThickness
  54484. * 1 would mean maximumThickness
  54485. * The other channels might be use as a mask to vary the different effects intensity.
  54486. */
  54487. thicknessTexture: Nullable<BaseTexture>;
  54488. private _refractionTexture;
  54489. /**
  54490. * Defines the texture to use for refraction.
  54491. */
  54492. refractionTexture: Nullable<BaseTexture>;
  54493. private _indexOfRefraction;
  54494. /**
  54495. * Index of refraction of the material base layer.
  54496. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54497. *
  54498. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54499. *
  54500. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54501. */
  54502. indexOfRefraction: number;
  54503. private _volumeIndexOfRefraction;
  54504. /**
  54505. * Index of refraction of the material's volume.
  54506. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54507. *
  54508. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54509. * the volume will use the same IOR as the surface.
  54510. */
  54511. get volumeIndexOfRefraction(): number;
  54512. set volumeIndexOfRefraction(value: number);
  54513. private _invertRefractionY;
  54514. /**
  54515. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54516. */
  54517. invertRefractionY: boolean;
  54518. private _linkRefractionWithTransparency;
  54519. /**
  54520. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54521. * Materials half opaque for instance using refraction could benefit from this control.
  54522. */
  54523. linkRefractionWithTransparency: boolean;
  54524. /**
  54525. * Defines the minimum thickness stored in the thickness map.
  54526. * If no thickness map is defined, this value will be used to simulate thickness.
  54527. */
  54528. minimumThickness: number;
  54529. /**
  54530. * Defines the maximum thickness stored in the thickness map.
  54531. */
  54532. maximumThickness: number;
  54533. /**
  54534. * Defines the volume tint of the material.
  54535. * This is used for both translucency and scattering.
  54536. */
  54537. tintColor: Color3;
  54538. /**
  54539. * Defines the distance at which the tint color should be found in the media.
  54540. * This is used for refraction only.
  54541. */
  54542. tintColorAtDistance: number;
  54543. /**
  54544. * Defines how far each channel transmit through the media.
  54545. * It is defined as a color to simplify it selection.
  54546. */
  54547. diffusionDistance: Color3;
  54548. private _useMaskFromThicknessTexture;
  54549. /**
  54550. * Stores the intensity of the different subsurface effects in the thickness texture.
  54551. * * the green channel is the translucency intensity.
  54552. * * the blue channel is the scattering intensity.
  54553. * * the alpha channel is the refraction intensity.
  54554. */
  54555. useMaskFromThicknessTexture: boolean;
  54556. /** @hidden */
  54557. private _internalMarkAllSubMeshesAsTexturesDirty;
  54558. /** @hidden */
  54559. _markAllSubMeshesAsTexturesDirty(): void;
  54560. /**
  54561. * Instantiate a new istance of sub surface configuration.
  54562. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54563. */
  54564. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54565. /**
  54566. * Gets wehter the submesh is ready to be used or not.
  54567. * @param defines the list of "defines" to update.
  54568. * @param scene defines the scene the material belongs to.
  54569. * @returns - boolean indicating that the submesh is ready or not.
  54570. */
  54571. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54572. /**
  54573. * Checks to see if a texture is used in the material.
  54574. * @param defines the list of "defines" to update.
  54575. * @param scene defines the scene to the material belongs to.
  54576. */
  54577. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54578. /**
  54579. * Binds the material data.
  54580. * @param uniformBuffer defines the Uniform buffer to fill in.
  54581. * @param scene defines the scene the material belongs to.
  54582. * @param engine defines the engine the material belongs to.
  54583. * @param isFrozen defines whether the material is frozen or not.
  54584. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54585. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54586. */
  54587. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54588. /**
  54589. * Unbinds the material from the mesh.
  54590. * @param activeEffect defines the effect that should be unbound from.
  54591. * @returns true if unbound, otherwise false
  54592. */
  54593. unbind(activeEffect: Effect): boolean;
  54594. /**
  54595. * Returns the texture used for refraction or null if none is used.
  54596. * @param scene defines the scene the material belongs to.
  54597. * @returns - Refraction texture if present. If no refraction texture and refraction
  54598. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54599. */
  54600. private _getRefractionTexture;
  54601. /**
  54602. * Returns true if alpha blending should be disabled.
  54603. */
  54604. get disableAlphaBlending(): boolean;
  54605. /**
  54606. * Fills the list of render target textures.
  54607. * @param renderTargets the list of render targets to update
  54608. */
  54609. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54610. /**
  54611. * Checks to see if a texture is used in the material.
  54612. * @param texture - Base texture to use.
  54613. * @returns - Boolean specifying if a texture is used in the material.
  54614. */
  54615. hasTexture(texture: BaseTexture): boolean;
  54616. /**
  54617. * Gets a boolean indicating that current material needs to register RTT
  54618. * @returns true if this uses a render target otherwise false.
  54619. */
  54620. hasRenderTargetTextures(): boolean;
  54621. /**
  54622. * Returns an array of the actively used textures.
  54623. * @param activeTextures Array of BaseTextures
  54624. */
  54625. getActiveTextures(activeTextures: BaseTexture[]): void;
  54626. /**
  54627. * Returns the animatable textures.
  54628. * @param animatables Array of animatable textures.
  54629. */
  54630. getAnimatables(animatables: IAnimatable[]): void;
  54631. /**
  54632. * Disposes the resources of the material.
  54633. * @param forceDisposeTextures - Forces the disposal of all textures.
  54634. */
  54635. dispose(forceDisposeTextures?: boolean): void;
  54636. /**
  54637. * Get the current class name of the texture useful for serialization or dynamic coding.
  54638. * @returns "PBRSubSurfaceConfiguration"
  54639. */
  54640. getClassName(): string;
  54641. /**
  54642. * Add fallbacks to the effect fallbacks list.
  54643. * @param defines defines the Base texture to use.
  54644. * @param fallbacks defines the current fallback list.
  54645. * @param currentRank defines the current fallback rank.
  54646. * @returns the new fallback rank.
  54647. */
  54648. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54649. /**
  54650. * Add the required uniforms to the current list.
  54651. * @param uniforms defines the current uniform list.
  54652. */
  54653. static AddUniforms(uniforms: string[]): void;
  54654. /**
  54655. * Add the required samplers to the current list.
  54656. * @param samplers defines the current sampler list.
  54657. */
  54658. static AddSamplers(samplers: string[]): void;
  54659. /**
  54660. * Add the required uniforms to the current buffer.
  54661. * @param uniformBuffer defines the current uniform buffer.
  54662. */
  54663. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54664. /**
  54665. * Makes a duplicate of the current configuration into another one.
  54666. * @param configuration define the config where to copy the info
  54667. */
  54668. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54669. /**
  54670. * Serializes this Sub Surface configuration.
  54671. * @returns - An object with the serialized config.
  54672. */
  54673. serialize(): any;
  54674. /**
  54675. * Parses a anisotropy Configuration from a serialized object.
  54676. * @param source - Serialized object.
  54677. * @param scene Defines the scene we are parsing for
  54678. * @param rootUrl Defines the rootUrl to load from
  54679. */
  54680. parse(source: any, scene: Scene, rootUrl: string): void;
  54681. }
  54682. }
  54683. declare module BABYLON {
  54684. /** @hidden */
  54685. export var pbrFragmentDeclaration: {
  54686. name: string;
  54687. shader: string;
  54688. };
  54689. }
  54690. declare module BABYLON {
  54691. /** @hidden */
  54692. export var pbrUboDeclaration: {
  54693. name: string;
  54694. shader: string;
  54695. };
  54696. }
  54697. declare module BABYLON {
  54698. /** @hidden */
  54699. export var pbrFragmentExtraDeclaration: {
  54700. name: string;
  54701. shader: string;
  54702. };
  54703. }
  54704. declare module BABYLON {
  54705. /** @hidden */
  54706. export var pbrFragmentSamplersDeclaration: {
  54707. name: string;
  54708. shader: string;
  54709. };
  54710. }
  54711. declare module BABYLON {
  54712. /** @hidden */
  54713. export var importanceSampling: {
  54714. name: string;
  54715. shader: string;
  54716. };
  54717. }
  54718. declare module BABYLON {
  54719. /** @hidden */
  54720. export var pbrHelperFunctions: {
  54721. name: string;
  54722. shader: string;
  54723. };
  54724. }
  54725. declare module BABYLON {
  54726. /** @hidden */
  54727. export var harmonicsFunctions: {
  54728. name: string;
  54729. shader: string;
  54730. };
  54731. }
  54732. declare module BABYLON {
  54733. /** @hidden */
  54734. export var pbrDirectLightingSetupFunctions: {
  54735. name: string;
  54736. shader: string;
  54737. };
  54738. }
  54739. declare module BABYLON {
  54740. /** @hidden */
  54741. export var pbrDirectLightingFalloffFunctions: {
  54742. name: string;
  54743. shader: string;
  54744. };
  54745. }
  54746. declare module BABYLON {
  54747. /** @hidden */
  54748. export var pbrBRDFFunctions: {
  54749. name: string;
  54750. shader: string;
  54751. };
  54752. }
  54753. declare module BABYLON {
  54754. /** @hidden */
  54755. export var hdrFilteringFunctions: {
  54756. name: string;
  54757. shader: string;
  54758. };
  54759. }
  54760. declare module BABYLON {
  54761. /** @hidden */
  54762. export var pbrDirectLightingFunctions: {
  54763. name: string;
  54764. shader: string;
  54765. };
  54766. }
  54767. declare module BABYLON {
  54768. /** @hidden */
  54769. export var pbrIBLFunctions: {
  54770. name: string;
  54771. shader: string;
  54772. };
  54773. }
  54774. declare module BABYLON {
  54775. /** @hidden */
  54776. export var pbrBlockAlbedoOpacity: {
  54777. name: string;
  54778. shader: string;
  54779. };
  54780. }
  54781. declare module BABYLON {
  54782. /** @hidden */
  54783. export var pbrBlockReflectivity: {
  54784. name: string;
  54785. shader: string;
  54786. };
  54787. }
  54788. declare module BABYLON {
  54789. /** @hidden */
  54790. export var pbrBlockAmbientOcclusion: {
  54791. name: string;
  54792. shader: string;
  54793. };
  54794. }
  54795. declare module BABYLON {
  54796. /** @hidden */
  54797. export var pbrBlockAlphaFresnel: {
  54798. name: string;
  54799. shader: string;
  54800. };
  54801. }
  54802. declare module BABYLON {
  54803. /** @hidden */
  54804. export var pbrBlockAnisotropic: {
  54805. name: string;
  54806. shader: string;
  54807. };
  54808. }
  54809. declare module BABYLON {
  54810. /** @hidden */
  54811. export var pbrBlockReflection: {
  54812. name: string;
  54813. shader: string;
  54814. };
  54815. }
  54816. declare module BABYLON {
  54817. /** @hidden */
  54818. export var pbrBlockSheen: {
  54819. name: string;
  54820. shader: string;
  54821. };
  54822. }
  54823. declare module BABYLON {
  54824. /** @hidden */
  54825. export var pbrBlockClearcoat: {
  54826. name: string;
  54827. shader: string;
  54828. };
  54829. }
  54830. declare module BABYLON {
  54831. /** @hidden */
  54832. export var pbrBlockSubSurface: {
  54833. name: string;
  54834. shader: string;
  54835. };
  54836. }
  54837. declare module BABYLON {
  54838. /** @hidden */
  54839. export var pbrBlockNormalGeometric: {
  54840. name: string;
  54841. shader: string;
  54842. };
  54843. }
  54844. declare module BABYLON {
  54845. /** @hidden */
  54846. export var pbrBlockNormalFinal: {
  54847. name: string;
  54848. shader: string;
  54849. };
  54850. }
  54851. declare module BABYLON {
  54852. /** @hidden */
  54853. export var pbrBlockGeometryInfo: {
  54854. name: string;
  54855. shader: string;
  54856. };
  54857. }
  54858. declare module BABYLON {
  54859. /** @hidden */
  54860. export var pbrBlockReflectance0: {
  54861. name: string;
  54862. shader: string;
  54863. };
  54864. }
  54865. declare module BABYLON {
  54866. /** @hidden */
  54867. export var pbrBlockReflectance: {
  54868. name: string;
  54869. shader: string;
  54870. };
  54871. }
  54872. declare module BABYLON {
  54873. /** @hidden */
  54874. export var pbrBlockDirectLighting: {
  54875. name: string;
  54876. shader: string;
  54877. };
  54878. }
  54879. declare module BABYLON {
  54880. /** @hidden */
  54881. export var pbrBlockFinalLitComponents: {
  54882. name: string;
  54883. shader: string;
  54884. };
  54885. }
  54886. declare module BABYLON {
  54887. /** @hidden */
  54888. export var pbrBlockFinalUnlitComponents: {
  54889. name: string;
  54890. shader: string;
  54891. };
  54892. }
  54893. declare module BABYLON {
  54894. /** @hidden */
  54895. export var pbrBlockFinalColorComposition: {
  54896. name: string;
  54897. shader: string;
  54898. };
  54899. }
  54900. declare module BABYLON {
  54901. /** @hidden */
  54902. export var pbrBlockImageProcessing: {
  54903. name: string;
  54904. shader: string;
  54905. };
  54906. }
  54907. declare module BABYLON {
  54908. /** @hidden */
  54909. export var pbrDebug: {
  54910. name: string;
  54911. shader: string;
  54912. };
  54913. }
  54914. declare module BABYLON {
  54915. /** @hidden */
  54916. export var pbrPixelShader: {
  54917. name: string;
  54918. shader: string;
  54919. };
  54920. }
  54921. declare module BABYLON {
  54922. /** @hidden */
  54923. export var pbrVertexDeclaration: {
  54924. name: string;
  54925. shader: string;
  54926. };
  54927. }
  54928. declare module BABYLON {
  54929. /** @hidden */
  54930. export var pbrVertexShader: {
  54931. name: string;
  54932. shader: string;
  54933. };
  54934. }
  54935. declare module BABYLON {
  54936. /**
  54937. * Manages the defines for the PBR Material.
  54938. * @hidden
  54939. */
  54940. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  54941. PBR: boolean;
  54942. NUM_SAMPLES: string;
  54943. REALTIME_FILTERING: boolean;
  54944. MAINUV1: boolean;
  54945. MAINUV2: boolean;
  54946. UV1: boolean;
  54947. UV2: boolean;
  54948. ALBEDO: boolean;
  54949. GAMMAALBEDO: boolean;
  54950. ALBEDODIRECTUV: number;
  54951. VERTEXCOLOR: boolean;
  54952. DETAIL: boolean;
  54953. DETAILDIRECTUV: number;
  54954. DETAIL_NORMALBLENDMETHOD: number;
  54955. AMBIENT: boolean;
  54956. AMBIENTDIRECTUV: number;
  54957. AMBIENTINGRAYSCALE: boolean;
  54958. OPACITY: boolean;
  54959. VERTEXALPHA: boolean;
  54960. OPACITYDIRECTUV: number;
  54961. OPACITYRGB: boolean;
  54962. ALPHATEST: boolean;
  54963. DEPTHPREPASS: boolean;
  54964. ALPHABLEND: boolean;
  54965. ALPHAFROMALBEDO: boolean;
  54966. ALPHATESTVALUE: string;
  54967. SPECULAROVERALPHA: boolean;
  54968. RADIANCEOVERALPHA: boolean;
  54969. ALPHAFRESNEL: boolean;
  54970. LINEARALPHAFRESNEL: boolean;
  54971. PREMULTIPLYALPHA: boolean;
  54972. EMISSIVE: boolean;
  54973. EMISSIVEDIRECTUV: number;
  54974. REFLECTIVITY: boolean;
  54975. REFLECTIVITYDIRECTUV: number;
  54976. SPECULARTERM: boolean;
  54977. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54978. MICROSURFACEAUTOMATIC: boolean;
  54979. LODBASEDMICROSFURACE: boolean;
  54980. MICROSURFACEMAP: boolean;
  54981. MICROSURFACEMAPDIRECTUV: number;
  54982. METALLICWORKFLOW: boolean;
  54983. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54984. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54985. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54986. AOSTOREINMETALMAPRED: boolean;
  54987. METALLIC_REFLECTANCE: boolean;
  54988. METALLIC_REFLECTANCEDIRECTUV: number;
  54989. ENVIRONMENTBRDF: boolean;
  54990. ENVIRONMENTBRDF_RGBD: boolean;
  54991. NORMAL: boolean;
  54992. TANGENT: boolean;
  54993. BUMP: boolean;
  54994. BUMPDIRECTUV: number;
  54995. OBJECTSPACE_NORMALMAP: boolean;
  54996. PARALLAX: boolean;
  54997. PARALLAXOCCLUSION: boolean;
  54998. NORMALXYSCALE: boolean;
  54999. LIGHTMAP: boolean;
  55000. LIGHTMAPDIRECTUV: number;
  55001. USELIGHTMAPASSHADOWMAP: boolean;
  55002. GAMMALIGHTMAP: boolean;
  55003. RGBDLIGHTMAP: boolean;
  55004. REFLECTION: boolean;
  55005. REFLECTIONMAP_3D: boolean;
  55006. REFLECTIONMAP_SPHERICAL: boolean;
  55007. REFLECTIONMAP_PLANAR: boolean;
  55008. REFLECTIONMAP_CUBIC: boolean;
  55009. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55010. REFLECTIONMAP_PROJECTION: boolean;
  55011. REFLECTIONMAP_SKYBOX: boolean;
  55012. REFLECTIONMAP_EXPLICIT: boolean;
  55013. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55014. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55015. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55016. INVERTCUBICMAP: boolean;
  55017. USESPHERICALFROMREFLECTIONMAP: boolean;
  55018. USEIRRADIANCEMAP: boolean;
  55019. SPHERICAL_HARMONICS: boolean;
  55020. USESPHERICALINVERTEX: boolean;
  55021. REFLECTIONMAP_OPPOSITEZ: boolean;
  55022. LODINREFLECTIONALPHA: boolean;
  55023. GAMMAREFLECTION: boolean;
  55024. RGBDREFLECTION: boolean;
  55025. LINEARSPECULARREFLECTION: boolean;
  55026. RADIANCEOCCLUSION: boolean;
  55027. HORIZONOCCLUSION: boolean;
  55028. INSTANCES: boolean;
  55029. THIN_INSTANCES: boolean;
  55030. NUM_BONE_INFLUENCERS: number;
  55031. BonesPerMesh: number;
  55032. BONETEXTURE: boolean;
  55033. NONUNIFORMSCALING: boolean;
  55034. MORPHTARGETS: boolean;
  55035. MORPHTARGETS_NORMAL: boolean;
  55036. MORPHTARGETS_TANGENT: boolean;
  55037. MORPHTARGETS_UV: boolean;
  55038. NUM_MORPH_INFLUENCERS: number;
  55039. IMAGEPROCESSING: boolean;
  55040. VIGNETTE: boolean;
  55041. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55042. VIGNETTEBLENDMODEOPAQUE: boolean;
  55043. TONEMAPPING: boolean;
  55044. TONEMAPPING_ACES: boolean;
  55045. CONTRAST: boolean;
  55046. COLORCURVES: boolean;
  55047. COLORGRADING: boolean;
  55048. COLORGRADING3D: boolean;
  55049. SAMPLER3DGREENDEPTH: boolean;
  55050. SAMPLER3DBGRMAP: boolean;
  55051. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55052. EXPOSURE: boolean;
  55053. MULTIVIEW: boolean;
  55054. USEPHYSICALLIGHTFALLOFF: boolean;
  55055. USEGLTFLIGHTFALLOFF: boolean;
  55056. TWOSIDEDLIGHTING: boolean;
  55057. SHADOWFLOAT: boolean;
  55058. CLIPPLANE: boolean;
  55059. CLIPPLANE2: boolean;
  55060. CLIPPLANE3: boolean;
  55061. CLIPPLANE4: boolean;
  55062. CLIPPLANE5: boolean;
  55063. CLIPPLANE6: boolean;
  55064. POINTSIZE: boolean;
  55065. FOG: boolean;
  55066. LOGARITHMICDEPTH: boolean;
  55067. FORCENORMALFORWARD: boolean;
  55068. SPECULARAA: boolean;
  55069. CLEARCOAT: boolean;
  55070. CLEARCOAT_DEFAULTIOR: boolean;
  55071. CLEARCOAT_TEXTURE: boolean;
  55072. CLEARCOAT_TEXTUREDIRECTUV: number;
  55073. CLEARCOAT_BUMP: boolean;
  55074. CLEARCOAT_BUMPDIRECTUV: number;
  55075. CLEARCOAT_TINT: boolean;
  55076. CLEARCOAT_TINT_TEXTURE: boolean;
  55077. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55078. ANISOTROPIC: boolean;
  55079. ANISOTROPIC_TEXTURE: boolean;
  55080. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55081. BRDF_V_HEIGHT_CORRELATED: boolean;
  55082. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55083. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55084. SHEEN: boolean;
  55085. SHEEN_TEXTURE: boolean;
  55086. SHEEN_TEXTUREDIRECTUV: number;
  55087. SHEEN_LINKWITHALBEDO: boolean;
  55088. SHEEN_ROUGHNESS: boolean;
  55089. SHEEN_ALBEDOSCALING: boolean;
  55090. SUBSURFACE: boolean;
  55091. SS_REFRACTION: boolean;
  55092. SS_TRANSLUCENCY: boolean;
  55093. SS_SCATTERING: boolean;
  55094. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55095. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55096. SS_REFRACTIONMAP_3D: boolean;
  55097. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55098. SS_LODINREFRACTIONALPHA: boolean;
  55099. SS_GAMMAREFRACTION: boolean;
  55100. SS_RGBDREFRACTION: boolean;
  55101. SS_LINEARSPECULARREFRACTION: boolean;
  55102. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55103. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55104. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55105. UNLIT: boolean;
  55106. DEBUGMODE: number;
  55107. /**
  55108. * Initializes the PBR Material defines.
  55109. */
  55110. constructor();
  55111. /**
  55112. * Resets the PBR Material defines.
  55113. */
  55114. reset(): void;
  55115. }
  55116. /**
  55117. * The Physically based material base class of BJS.
  55118. *
  55119. * This offers the main features of a standard PBR material.
  55120. * For more information, please refer to the documentation :
  55121. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55122. */
  55123. export abstract class PBRBaseMaterial extends PushMaterial {
  55124. /**
  55125. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55126. */
  55127. static readonly PBRMATERIAL_OPAQUE: number;
  55128. /**
  55129. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55130. */
  55131. static readonly PBRMATERIAL_ALPHATEST: number;
  55132. /**
  55133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55134. */
  55135. static readonly PBRMATERIAL_ALPHABLEND: number;
  55136. /**
  55137. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55138. * They are also discarded below the alpha cutoff threshold to improve performances.
  55139. */
  55140. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55141. /**
  55142. * Defines the default value of how much AO map is occluding the analytical lights
  55143. * (point spot...).
  55144. */
  55145. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55146. /**
  55147. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55148. */
  55149. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55150. /**
  55151. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55152. * to enhance interoperability with other engines.
  55153. */
  55154. static readonly LIGHTFALLOFF_GLTF: number;
  55155. /**
  55156. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55157. * to enhance interoperability with other materials.
  55158. */
  55159. static readonly LIGHTFALLOFF_STANDARD: number;
  55160. /**
  55161. * Intensity of the direct lights e.g. the four lights available in your scene.
  55162. * This impacts both the direct diffuse and specular highlights.
  55163. */
  55164. protected _directIntensity: number;
  55165. /**
  55166. * Intensity of the emissive part of the material.
  55167. * This helps controlling the emissive effect without modifying the emissive color.
  55168. */
  55169. protected _emissiveIntensity: number;
  55170. /**
  55171. * Intensity of the environment e.g. how much the environment will light the object
  55172. * either through harmonics for rough material or through the refelction for shiny ones.
  55173. */
  55174. protected _environmentIntensity: number;
  55175. /**
  55176. * This is a special control allowing the reduction of the specular highlights coming from the
  55177. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55178. */
  55179. protected _specularIntensity: number;
  55180. /**
  55181. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55182. */
  55183. private _lightingInfos;
  55184. /**
  55185. * Debug Control allowing disabling the bump map on this material.
  55186. */
  55187. protected _disableBumpMap: boolean;
  55188. /**
  55189. * AKA Diffuse Texture in standard nomenclature.
  55190. */
  55191. protected _albedoTexture: Nullable<BaseTexture>;
  55192. /**
  55193. * AKA Occlusion Texture in other nomenclature.
  55194. */
  55195. protected _ambientTexture: Nullable<BaseTexture>;
  55196. /**
  55197. * AKA Occlusion Texture Intensity in other nomenclature.
  55198. */
  55199. protected _ambientTextureStrength: number;
  55200. /**
  55201. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55202. * 1 means it completely occludes it
  55203. * 0 mean it has no impact
  55204. */
  55205. protected _ambientTextureImpactOnAnalyticalLights: number;
  55206. /**
  55207. * Stores the alpha values in a texture.
  55208. */
  55209. protected _opacityTexture: Nullable<BaseTexture>;
  55210. /**
  55211. * Stores the reflection values in a texture.
  55212. */
  55213. protected _reflectionTexture: Nullable<BaseTexture>;
  55214. /**
  55215. * Stores the emissive values in a texture.
  55216. */
  55217. protected _emissiveTexture: Nullable<BaseTexture>;
  55218. /**
  55219. * AKA Specular texture in other nomenclature.
  55220. */
  55221. protected _reflectivityTexture: Nullable<BaseTexture>;
  55222. /**
  55223. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55224. */
  55225. protected _metallicTexture: Nullable<BaseTexture>;
  55226. /**
  55227. * Specifies the metallic scalar of the metallic/roughness workflow.
  55228. * Can also be used to scale the metalness values of the metallic texture.
  55229. */
  55230. protected _metallic: Nullable<number>;
  55231. /**
  55232. * Specifies the roughness scalar of the metallic/roughness workflow.
  55233. * Can also be used to scale the roughness values of the metallic texture.
  55234. */
  55235. protected _roughness: Nullable<number>;
  55236. /**
  55237. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55238. * By default the indexOfrefraction is used to compute F0;
  55239. *
  55240. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55241. *
  55242. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55243. * F90 = metallicReflectanceColor;
  55244. */
  55245. protected _metallicF0Factor: number;
  55246. /**
  55247. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55248. * By default the F90 is always 1;
  55249. *
  55250. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55251. *
  55252. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55253. * F90 = metallicReflectanceColor;
  55254. */
  55255. protected _metallicReflectanceColor: Color3;
  55256. /**
  55257. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55258. * This is multiply against the scalar values defined in the material.
  55259. */
  55260. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55261. /**
  55262. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55263. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55264. */
  55265. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55266. /**
  55267. * Stores surface normal data used to displace a mesh in a texture.
  55268. */
  55269. protected _bumpTexture: Nullable<BaseTexture>;
  55270. /**
  55271. * Stores the pre-calculated light information of a mesh in a texture.
  55272. */
  55273. protected _lightmapTexture: Nullable<BaseTexture>;
  55274. /**
  55275. * The color of a material in ambient lighting.
  55276. */
  55277. protected _ambientColor: Color3;
  55278. /**
  55279. * AKA Diffuse Color in other nomenclature.
  55280. */
  55281. protected _albedoColor: Color3;
  55282. /**
  55283. * AKA Specular Color in other nomenclature.
  55284. */
  55285. protected _reflectivityColor: Color3;
  55286. /**
  55287. * The color applied when light is reflected from a material.
  55288. */
  55289. protected _reflectionColor: Color3;
  55290. /**
  55291. * The color applied when light is emitted from a material.
  55292. */
  55293. protected _emissiveColor: Color3;
  55294. /**
  55295. * AKA Glossiness in other nomenclature.
  55296. */
  55297. protected _microSurface: number;
  55298. /**
  55299. * Specifies that the material will use the light map as a show map.
  55300. */
  55301. protected _useLightmapAsShadowmap: boolean;
  55302. /**
  55303. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55304. * makes the reflect vector face the model (under horizon).
  55305. */
  55306. protected _useHorizonOcclusion: boolean;
  55307. /**
  55308. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55309. * too much the area relying on ambient texture to define their ambient occlusion.
  55310. */
  55311. protected _useRadianceOcclusion: boolean;
  55312. /**
  55313. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55314. */
  55315. protected _useAlphaFromAlbedoTexture: boolean;
  55316. /**
  55317. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55318. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55319. */
  55320. protected _useSpecularOverAlpha: boolean;
  55321. /**
  55322. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55323. */
  55324. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55325. /**
  55326. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55327. */
  55328. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55329. /**
  55330. * Specifies if the metallic texture contains the roughness information in its green channel.
  55331. */
  55332. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55333. /**
  55334. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55335. */
  55336. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55337. /**
  55338. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55339. */
  55340. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55341. /**
  55342. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55343. */
  55344. protected _useAmbientInGrayScale: boolean;
  55345. /**
  55346. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55347. * The material will try to infer what glossiness each pixel should be.
  55348. */
  55349. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55350. /**
  55351. * Defines the falloff type used in this material.
  55352. * It by default is Physical.
  55353. */
  55354. protected _lightFalloff: number;
  55355. /**
  55356. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55357. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55358. */
  55359. protected _useRadianceOverAlpha: boolean;
  55360. /**
  55361. * Allows using an object space normal map (instead of tangent space).
  55362. */
  55363. protected _useObjectSpaceNormalMap: boolean;
  55364. /**
  55365. * Allows using the bump map in parallax mode.
  55366. */
  55367. protected _useParallax: boolean;
  55368. /**
  55369. * Allows using the bump map in parallax occlusion mode.
  55370. */
  55371. protected _useParallaxOcclusion: boolean;
  55372. /**
  55373. * Controls the scale bias of the parallax mode.
  55374. */
  55375. protected _parallaxScaleBias: number;
  55376. /**
  55377. * If sets to true, disables all the lights affecting the material.
  55378. */
  55379. protected _disableLighting: boolean;
  55380. /**
  55381. * Number of Simultaneous lights allowed on the material.
  55382. */
  55383. protected _maxSimultaneousLights: number;
  55384. /**
  55385. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55386. */
  55387. protected _invertNormalMapX: boolean;
  55388. /**
  55389. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55390. */
  55391. protected _invertNormalMapY: boolean;
  55392. /**
  55393. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55394. */
  55395. protected _twoSidedLighting: boolean;
  55396. /**
  55397. * Defines the alpha limits in alpha test mode.
  55398. */
  55399. protected _alphaCutOff: number;
  55400. /**
  55401. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55402. */
  55403. protected _forceAlphaTest: boolean;
  55404. /**
  55405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55406. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55407. */
  55408. protected _useAlphaFresnel: boolean;
  55409. /**
  55410. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55411. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55412. */
  55413. protected _useLinearAlphaFresnel: boolean;
  55414. /**
  55415. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55416. * from cos thetav and roughness:
  55417. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55418. */
  55419. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55420. /**
  55421. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55422. */
  55423. protected _forceIrradianceInFragment: boolean;
  55424. private _realTimeFiltering;
  55425. /**
  55426. * Enables realtime filtering on the texture.
  55427. */
  55428. get realTimeFiltering(): boolean;
  55429. set realTimeFiltering(b: boolean);
  55430. private _realTimeFilteringQuality;
  55431. /**
  55432. * Quality switch for realtime filtering
  55433. */
  55434. get realTimeFilteringQuality(): number;
  55435. set realTimeFilteringQuality(n: number);
  55436. /**
  55437. * Force normal to face away from face.
  55438. */
  55439. protected _forceNormalForward: boolean;
  55440. /**
  55441. * Enables specular anti aliasing in the PBR shader.
  55442. * It will both interacts on the Geometry for analytical and IBL lighting.
  55443. * It also prefilter the roughness map based on the bump values.
  55444. */
  55445. protected _enableSpecularAntiAliasing: boolean;
  55446. /**
  55447. * Default configuration related to image processing available in the PBR Material.
  55448. */
  55449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55450. /**
  55451. * Keep track of the image processing observer to allow dispose and replace.
  55452. */
  55453. private _imageProcessingObserver;
  55454. /**
  55455. * Attaches a new image processing configuration to the PBR Material.
  55456. * @param configuration
  55457. */
  55458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55459. /**
  55460. * Stores the available render targets.
  55461. */
  55462. private _renderTargets;
  55463. /**
  55464. * Sets the global ambient color for the material used in lighting calculations.
  55465. */
  55466. private _globalAmbientColor;
  55467. /**
  55468. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55469. */
  55470. private _useLogarithmicDepth;
  55471. /**
  55472. * If set to true, no lighting calculations will be applied.
  55473. */
  55474. private _unlit;
  55475. private _debugMode;
  55476. /**
  55477. * @hidden
  55478. * This is reserved for the inspector.
  55479. * Defines the material debug mode.
  55480. * It helps seeing only some components of the material while troubleshooting.
  55481. */
  55482. debugMode: number;
  55483. /**
  55484. * @hidden
  55485. * This is reserved for the inspector.
  55486. * Specify from where on screen the debug mode should start.
  55487. * The value goes from -1 (full screen) to 1 (not visible)
  55488. * It helps with side by side comparison against the final render
  55489. * This defaults to -1
  55490. */
  55491. private debugLimit;
  55492. /**
  55493. * @hidden
  55494. * This is reserved for the inspector.
  55495. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55496. * You can use the factor to better multiply the final value.
  55497. */
  55498. private debugFactor;
  55499. /**
  55500. * Defines the clear coat layer parameters for the material.
  55501. */
  55502. readonly clearCoat: PBRClearCoatConfiguration;
  55503. /**
  55504. * Defines the anisotropic parameters for the material.
  55505. */
  55506. readonly anisotropy: PBRAnisotropicConfiguration;
  55507. /**
  55508. * Defines the BRDF parameters for the material.
  55509. */
  55510. readonly brdf: PBRBRDFConfiguration;
  55511. /**
  55512. * Defines the Sheen parameters for the material.
  55513. */
  55514. readonly sheen: PBRSheenConfiguration;
  55515. /**
  55516. * Defines the SubSurface parameters for the material.
  55517. */
  55518. readonly subSurface: PBRSubSurfaceConfiguration;
  55519. /**
  55520. * Defines the detail map parameters for the material.
  55521. */
  55522. readonly detailMap: DetailMapConfiguration;
  55523. protected _rebuildInParallel: boolean;
  55524. /**
  55525. * Instantiates a new PBRMaterial instance.
  55526. *
  55527. * @param name The material name
  55528. * @param scene The scene the material will be use in.
  55529. */
  55530. constructor(name: string, scene: Scene);
  55531. /**
  55532. * Gets a boolean indicating that current material needs to register RTT
  55533. */
  55534. get hasRenderTargetTextures(): boolean;
  55535. /**
  55536. * Gets the name of the material class.
  55537. */
  55538. getClassName(): string;
  55539. /**
  55540. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55541. */
  55542. get useLogarithmicDepth(): boolean;
  55543. /**
  55544. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55545. */
  55546. set useLogarithmicDepth(value: boolean);
  55547. /**
  55548. * Returns true if alpha blending should be disabled.
  55549. */
  55550. protected get _disableAlphaBlending(): boolean;
  55551. /**
  55552. * Specifies whether or not this material should be rendered in alpha blend mode.
  55553. */
  55554. needAlphaBlending(): boolean;
  55555. /**
  55556. * Specifies whether or not this material should be rendered in alpha test mode.
  55557. */
  55558. needAlphaTesting(): boolean;
  55559. /**
  55560. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55561. */
  55562. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55563. /**
  55564. * Gets the texture used for the alpha test.
  55565. */
  55566. getAlphaTestTexture(): Nullable<BaseTexture>;
  55567. /**
  55568. * Specifies that the submesh is ready to be used.
  55569. * @param mesh - BJS mesh.
  55570. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55571. * @param useInstances - Specifies that instances should be used.
  55572. * @returns - boolean indicating that the submesh is ready or not.
  55573. */
  55574. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55575. /**
  55576. * Specifies if the material uses metallic roughness workflow.
  55577. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55578. */
  55579. isMetallicWorkflow(): boolean;
  55580. private _prepareEffect;
  55581. private _prepareDefines;
  55582. /**
  55583. * Force shader compilation
  55584. */
  55585. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55586. /**
  55587. * Initializes the uniform buffer layout for the shader.
  55588. */
  55589. buildUniformLayout(): void;
  55590. /**
  55591. * Unbinds the material from the mesh
  55592. */
  55593. unbind(): void;
  55594. /**
  55595. * Binds the submesh data.
  55596. * @param world - The world matrix.
  55597. * @param mesh - The BJS mesh.
  55598. * @param subMesh - A submesh of the BJS mesh.
  55599. */
  55600. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55601. /**
  55602. * Returns the animatable textures.
  55603. * @returns - Array of animatable textures.
  55604. */
  55605. getAnimatables(): IAnimatable[];
  55606. /**
  55607. * Returns the texture used for reflections.
  55608. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55609. */
  55610. private _getReflectionTexture;
  55611. /**
  55612. * Returns an array of the actively used textures.
  55613. * @returns - Array of BaseTextures
  55614. */
  55615. getActiveTextures(): BaseTexture[];
  55616. /**
  55617. * Checks to see if a texture is used in the material.
  55618. * @param texture - Base texture to use.
  55619. * @returns - Boolean specifying if a texture is used in the material.
  55620. */
  55621. hasTexture(texture: BaseTexture): boolean;
  55622. /**
  55623. * Disposes the resources of the material.
  55624. * @param forceDisposeEffect - Forces the disposal of effects.
  55625. * @param forceDisposeTextures - Forces the disposal of all textures.
  55626. */
  55627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55628. }
  55629. }
  55630. declare module BABYLON {
  55631. /**
  55632. * The Physically based material of BJS.
  55633. *
  55634. * This offers the main features of a standard PBR material.
  55635. * For more information, please refer to the documentation :
  55636. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55637. */
  55638. export class PBRMaterial extends PBRBaseMaterial {
  55639. /**
  55640. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55641. */
  55642. static readonly PBRMATERIAL_OPAQUE: number;
  55643. /**
  55644. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55645. */
  55646. static readonly PBRMATERIAL_ALPHATEST: number;
  55647. /**
  55648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55649. */
  55650. static readonly PBRMATERIAL_ALPHABLEND: number;
  55651. /**
  55652. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55653. * They are also discarded below the alpha cutoff threshold to improve performances.
  55654. */
  55655. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55656. /**
  55657. * Defines the default value of how much AO map is occluding the analytical lights
  55658. * (point spot...).
  55659. */
  55660. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55661. /**
  55662. * Intensity of the direct lights e.g. the four lights available in your scene.
  55663. * This impacts both the direct diffuse and specular highlights.
  55664. */
  55665. directIntensity: number;
  55666. /**
  55667. * Intensity of the emissive part of the material.
  55668. * This helps controlling the emissive effect without modifying the emissive color.
  55669. */
  55670. emissiveIntensity: number;
  55671. /**
  55672. * Intensity of the environment e.g. how much the environment will light the object
  55673. * either through harmonics for rough material or through the refelction for shiny ones.
  55674. */
  55675. environmentIntensity: number;
  55676. /**
  55677. * This is a special control allowing the reduction of the specular highlights coming from the
  55678. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55679. */
  55680. specularIntensity: number;
  55681. /**
  55682. * Debug Control allowing disabling the bump map on this material.
  55683. */
  55684. disableBumpMap: boolean;
  55685. /**
  55686. * AKA Diffuse Texture in standard nomenclature.
  55687. */
  55688. albedoTexture: BaseTexture;
  55689. /**
  55690. * AKA Occlusion Texture in other nomenclature.
  55691. */
  55692. ambientTexture: BaseTexture;
  55693. /**
  55694. * AKA Occlusion Texture Intensity in other nomenclature.
  55695. */
  55696. ambientTextureStrength: number;
  55697. /**
  55698. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55699. * 1 means it completely occludes it
  55700. * 0 mean it has no impact
  55701. */
  55702. ambientTextureImpactOnAnalyticalLights: number;
  55703. /**
  55704. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55705. */
  55706. opacityTexture: BaseTexture;
  55707. /**
  55708. * Stores the reflection values in a texture.
  55709. */
  55710. reflectionTexture: Nullable<BaseTexture>;
  55711. /**
  55712. * Stores the emissive values in a texture.
  55713. */
  55714. emissiveTexture: BaseTexture;
  55715. /**
  55716. * AKA Specular texture in other nomenclature.
  55717. */
  55718. reflectivityTexture: BaseTexture;
  55719. /**
  55720. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55721. */
  55722. metallicTexture: BaseTexture;
  55723. /**
  55724. * Specifies the metallic scalar of the metallic/roughness workflow.
  55725. * Can also be used to scale the metalness values of the metallic texture.
  55726. */
  55727. metallic: Nullable<number>;
  55728. /**
  55729. * Specifies the roughness scalar of the metallic/roughness workflow.
  55730. * Can also be used to scale the roughness values of the metallic texture.
  55731. */
  55732. roughness: Nullable<number>;
  55733. /**
  55734. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55735. * By default the indexOfrefraction is used to compute F0;
  55736. *
  55737. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55738. *
  55739. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55740. * F90 = metallicReflectanceColor;
  55741. */
  55742. metallicF0Factor: number;
  55743. /**
  55744. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55745. * By default the F90 is always 1;
  55746. *
  55747. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55748. *
  55749. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55750. * F90 = metallicReflectanceColor;
  55751. */
  55752. metallicReflectanceColor: Color3;
  55753. /**
  55754. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55755. * This is multiply against the scalar values defined in the material.
  55756. */
  55757. metallicReflectanceTexture: Nullable<BaseTexture>;
  55758. /**
  55759. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55760. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55761. */
  55762. microSurfaceTexture: BaseTexture;
  55763. /**
  55764. * Stores surface normal data used to displace a mesh in a texture.
  55765. */
  55766. bumpTexture: BaseTexture;
  55767. /**
  55768. * Stores the pre-calculated light information of a mesh in a texture.
  55769. */
  55770. lightmapTexture: BaseTexture;
  55771. /**
  55772. * Stores the refracted light information in a texture.
  55773. */
  55774. get refractionTexture(): Nullable<BaseTexture>;
  55775. set refractionTexture(value: Nullable<BaseTexture>);
  55776. /**
  55777. * The color of a material in ambient lighting.
  55778. */
  55779. ambientColor: Color3;
  55780. /**
  55781. * AKA Diffuse Color in other nomenclature.
  55782. */
  55783. albedoColor: Color3;
  55784. /**
  55785. * AKA Specular Color in other nomenclature.
  55786. */
  55787. reflectivityColor: Color3;
  55788. /**
  55789. * The color reflected from the material.
  55790. */
  55791. reflectionColor: Color3;
  55792. /**
  55793. * The color emitted from the material.
  55794. */
  55795. emissiveColor: Color3;
  55796. /**
  55797. * AKA Glossiness in other nomenclature.
  55798. */
  55799. microSurface: number;
  55800. /**
  55801. * Index of refraction of the material base layer.
  55802. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55803. *
  55804. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55805. *
  55806. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55807. */
  55808. get indexOfRefraction(): number;
  55809. set indexOfRefraction(value: number);
  55810. /**
  55811. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55812. */
  55813. get invertRefractionY(): boolean;
  55814. set invertRefractionY(value: boolean);
  55815. /**
  55816. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55817. * Materials half opaque for instance using refraction could benefit from this control.
  55818. */
  55819. get linkRefractionWithTransparency(): boolean;
  55820. set linkRefractionWithTransparency(value: boolean);
  55821. /**
  55822. * If true, the light map contains occlusion information instead of lighting info.
  55823. */
  55824. useLightmapAsShadowmap: boolean;
  55825. /**
  55826. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55827. */
  55828. useAlphaFromAlbedoTexture: boolean;
  55829. /**
  55830. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55831. */
  55832. forceAlphaTest: boolean;
  55833. /**
  55834. * Defines the alpha limits in alpha test mode.
  55835. */
  55836. alphaCutOff: number;
  55837. /**
  55838. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55839. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55840. */
  55841. useSpecularOverAlpha: boolean;
  55842. /**
  55843. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55844. */
  55845. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55846. /**
  55847. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55848. */
  55849. useRoughnessFromMetallicTextureAlpha: boolean;
  55850. /**
  55851. * Specifies if the metallic texture contains the roughness information in its green channel.
  55852. */
  55853. useRoughnessFromMetallicTextureGreen: boolean;
  55854. /**
  55855. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55856. */
  55857. useMetallnessFromMetallicTextureBlue: boolean;
  55858. /**
  55859. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55860. */
  55861. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55862. /**
  55863. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55864. */
  55865. useAmbientInGrayScale: boolean;
  55866. /**
  55867. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55868. * The material will try to infer what glossiness each pixel should be.
  55869. */
  55870. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55871. /**
  55872. * BJS is using an harcoded light falloff based on a manually sets up range.
  55873. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55874. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55875. */
  55876. get usePhysicalLightFalloff(): boolean;
  55877. /**
  55878. * BJS is using an harcoded light falloff based on a manually sets up range.
  55879. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55880. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55881. */
  55882. set usePhysicalLightFalloff(value: boolean);
  55883. /**
  55884. * In order to support the falloff compatibility with gltf, a special mode has been added
  55885. * to reproduce the gltf light falloff.
  55886. */
  55887. get useGLTFLightFalloff(): boolean;
  55888. /**
  55889. * In order to support the falloff compatibility with gltf, a special mode has been added
  55890. * to reproduce the gltf light falloff.
  55891. */
  55892. set useGLTFLightFalloff(value: boolean);
  55893. /**
  55894. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55895. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55896. */
  55897. useRadianceOverAlpha: boolean;
  55898. /**
  55899. * Allows using an object space normal map (instead of tangent space).
  55900. */
  55901. useObjectSpaceNormalMap: boolean;
  55902. /**
  55903. * Allows using the bump map in parallax mode.
  55904. */
  55905. useParallax: boolean;
  55906. /**
  55907. * Allows using the bump map in parallax occlusion mode.
  55908. */
  55909. useParallaxOcclusion: boolean;
  55910. /**
  55911. * Controls the scale bias of the parallax mode.
  55912. */
  55913. parallaxScaleBias: number;
  55914. /**
  55915. * If sets to true, disables all the lights affecting the material.
  55916. */
  55917. disableLighting: boolean;
  55918. /**
  55919. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55920. */
  55921. forceIrradianceInFragment: boolean;
  55922. /**
  55923. * Number of Simultaneous lights allowed on the material.
  55924. */
  55925. maxSimultaneousLights: number;
  55926. /**
  55927. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55928. */
  55929. invertNormalMapX: boolean;
  55930. /**
  55931. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55932. */
  55933. invertNormalMapY: boolean;
  55934. /**
  55935. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55936. */
  55937. twoSidedLighting: boolean;
  55938. /**
  55939. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55940. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55941. */
  55942. useAlphaFresnel: boolean;
  55943. /**
  55944. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55945. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55946. */
  55947. useLinearAlphaFresnel: boolean;
  55948. /**
  55949. * Let user defines the brdf lookup texture used for IBL.
  55950. * A default 8bit version is embedded but you could point at :
  55951. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55952. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55953. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55954. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55955. */
  55956. environmentBRDFTexture: Nullable<BaseTexture>;
  55957. /**
  55958. * Force normal to face away from face.
  55959. */
  55960. forceNormalForward: boolean;
  55961. /**
  55962. * Enables specular anti aliasing in the PBR shader.
  55963. * It will both interacts on the Geometry for analytical and IBL lighting.
  55964. * It also prefilter the roughness map based on the bump values.
  55965. */
  55966. enableSpecularAntiAliasing: boolean;
  55967. /**
  55968. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55969. * makes the reflect vector face the model (under horizon).
  55970. */
  55971. useHorizonOcclusion: boolean;
  55972. /**
  55973. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55974. * too much the area relying on ambient texture to define their ambient occlusion.
  55975. */
  55976. useRadianceOcclusion: boolean;
  55977. /**
  55978. * If set to true, no lighting calculations will be applied.
  55979. */
  55980. unlit: boolean;
  55981. /**
  55982. * Gets the image processing configuration used either in this material.
  55983. */
  55984. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55985. /**
  55986. * Sets the Default image processing configuration used either in the this material.
  55987. *
  55988. * If sets to null, the scene one is in use.
  55989. */
  55990. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55991. /**
  55992. * Gets wether the color curves effect is enabled.
  55993. */
  55994. get cameraColorCurvesEnabled(): boolean;
  55995. /**
  55996. * Sets wether the color curves effect is enabled.
  55997. */
  55998. set cameraColorCurvesEnabled(value: boolean);
  55999. /**
  56000. * Gets wether the color grading effect is enabled.
  56001. */
  56002. get cameraColorGradingEnabled(): boolean;
  56003. /**
  56004. * Gets wether the color grading effect is enabled.
  56005. */
  56006. set cameraColorGradingEnabled(value: boolean);
  56007. /**
  56008. * Gets wether tonemapping is enabled or not.
  56009. */
  56010. get cameraToneMappingEnabled(): boolean;
  56011. /**
  56012. * Sets wether tonemapping is enabled or not
  56013. */
  56014. set cameraToneMappingEnabled(value: boolean);
  56015. /**
  56016. * The camera exposure used on this material.
  56017. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56018. * This corresponds to a photographic exposure.
  56019. */
  56020. get cameraExposure(): number;
  56021. /**
  56022. * The camera exposure used on this material.
  56023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56024. * This corresponds to a photographic exposure.
  56025. */
  56026. set cameraExposure(value: number);
  56027. /**
  56028. * Gets The camera contrast used on this material.
  56029. */
  56030. get cameraContrast(): number;
  56031. /**
  56032. * Sets The camera contrast used on this material.
  56033. */
  56034. set cameraContrast(value: number);
  56035. /**
  56036. * Gets the Color Grading 2D Lookup Texture.
  56037. */
  56038. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56039. /**
  56040. * Sets the Color Grading 2D Lookup Texture.
  56041. */
  56042. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56043. /**
  56044. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56045. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56046. * 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;
  56047. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56048. */
  56049. get cameraColorCurves(): Nullable<ColorCurves>;
  56050. /**
  56051. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56052. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56053. * 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;
  56054. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56055. */
  56056. set cameraColorCurves(value: Nullable<ColorCurves>);
  56057. /**
  56058. * Instantiates a new PBRMaterial instance.
  56059. *
  56060. * @param name The material name
  56061. * @param scene The scene the material will be use in.
  56062. */
  56063. constructor(name: string, scene: Scene);
  56064. /**
  56065. * Returns the name of this material class.
  56066. */
  56067. getClassName(): string;
  56068. /**
  56069. * Makes a duplicate of the current material.
  56070. * @param name - name to use for the new material.
  56071. */
  56072. clone(name: string): PBRMaterial;
  56073. /**
  56074. * Serializes this PBR Material.
  56075. * @returns - An object with the serialized material.
  56076. */
  56077. serialize(): any;
  56078. /**
  56079. * Parses a PBR Material from a serialized object.
  56080. * @param source - Serialized object.
  56081. * @param scene - BJS scene instance.
  56082. * @param rootUrl - url for the scene object
  56083. * @returns - PBRMaterial
  56084. */
  56085. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56086. }
  56087. }
  56088. declare module BABYLON {
  56089. /**
  56090. * Direct draw surface info
  56091. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56092. */
  56093. export interface DDSInfo {
  56094. /**
  56095. * Width of the texture
  56096. */
  56097. width: number;
  56098. /**
  56099. * Width of the texture
  56100. */
  56101. height: number;
  56102. /**
  56103. * Number of Mipmaps for the texture
  56104. * @see https://en.wikipedia.org/wiki/Mipmap
  56105. */
  56106. mipmapCount: number;
  56107. /**
  56108. * If the textures format is a known fourCC format
  56109. * @see https://www.fourcc.org/
  56110. */
  56111. isFourCC: boolean;
  56112. /**
  56113. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56114. */
  56115. isRGB: boolean;
  56116. /**
  56117. * If the texture is a lumincance format
  56118. */
  56119. isLuminance: boolean;
  56120. /**
  56121. * If this is a cube texture
  56122. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56123. */
  56124. isCube: boolean;
  56125. /**
  56126. * If the texture is a compressed format eg. FOURCC_DXT1
  56127. */
  56128. isCompressed: boolean;
  56129. /**
  56130. * The dxgiFormat of the texture
  56131. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56132. */
  56133. dxgiFormat: number;
  56134. /**
  56135. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56136. */
  56137. textureType: number;
  56138. /**
  56139. * Sphericle polynomial created for the dds texture
  56140. */
  56141. sphericalPolynomial?: SphericalPolynomial;
  56142. }
  56143. /**
  56144. * Class used to provide DDS decompression tools
  56145. */
  56146. export class DDSTools {
  56147. /**
  56148. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56149. */
  56150. static StoreLODInAlphaChannel: boolean;
  56151. /**
  56152. * Gets DDS information from an array buffer
  56153. * @param data defines the array buffer view to read data from
  56154. * @returns the DDS information
  56155. */
  56156. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56157. private static _FloatView;
  56158. private static _Int32View;
  56159. private static _ToHalfFloat;
  56160. private static _FromHalfFloat;
  56161. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56162. private static _GetHalfFloatRGBAArrayBuffer;
  56163. private static _GetFloatRGBAArrayBuffer;
  56164. private static _GetFloatAsUIntRGBAArrayBuffer;
  56165. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56166. private static _GetRGBAArrayBuffer;
  56167. private static _ExtractLongWordOrder;
  56168. private static _GetRGBArrayBuffer;
  56169. private static _GetLuminanceArrayBuffer;
  56170. /**
  56171. * Uploads DDS Levels to a Babylon Texture
  56172. * @hidden
  56173. */
  56174. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56175. }
  56176. interface ThinEngine {
  56177. /**
  56178. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56179. * @param rootUrl defines the url where the file to load is located
  56180. * @param scene defines the current scene
  56181. * @param lodScale defines scale to apply to the mip map selection
  56182. * @param lodOffset defines offset to apply to the mip map selection
  56183. * @param onLoad defines an optional callback raised when the texture is loaded
  56184. * @param onError defines an optional callback raised if there is an issue to load the texture
  56185. * @param format defines the format of the data
  56186. * @param forcedExtension defines the extension to use to pick the right loader
  56187. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56188. * @returns the cube texture as an InternalTexture
  56189. */
  56190. 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;
  56191. }
  56192. }
  56193. declare module BABYLON {
  56194. /**
  56195. * Implementation of the DDS Texture Loader.
  56196. * @hidden
  56197. */
  56198. export class _DDSTextureLoader implements IInternalTextureLoader {
  56199. /**
  56200. * Defines wether the loader supports cascade loading the different faces.
  56201. */
  56202. readonly supportCascades: boolean;
  56203. /**
  56204. * This returns if the loader support the current file information.
  56205. * @param extension defines the file extension of the file being loaded
  56206. * @returns true if the loader can load the specified file
  56207. */
  56208. canLoad(extension: string): boolean;
  56209. /**
  56210. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56211. * @param data contains the texture data
  56212. * @param texture defines the BabylonJS internal texture
  56213. * @param createPolynomials will be true if polynomials have been requested
  56214. * @param onLoad defines the callback to trigger once the texture is ready
  56215. * @param onError defines the callback to trigger in case of error
  56216. */
  56217. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56218. /**
  56219. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56220. * @param data contains the texture data
  56221. * @param texture defines the BabylonJS internal texture
  56222. * @param callback defines the method to call once ready to upload
  56223. */
  56224. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56225. }
  56226. }
  56227. declare module BABYLON {
  56228. /**
  56229. * Implementation of the ENV Texture Loader.
  56230. * @hidden
  56231. */
  56232. export class _ENVTextureLoader implements IInternalTextureLoader {
  56233. /**
  56234. * Defines wether the loader supports cascade loading the different faces.
  56235. */
  56236. readonly supportCascades: boolean;
  56237. /**
  56238. * This returns if the loader support the current file information.
  56239. * @param extension defines the file extension of the file being loaded
  56240. * @returns true if the loader can load the specified file
  56241. */
  56242. canLoad(extension: string): boolean;
  56243. /**
  56244. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56245. * @param data contains the texture data
  56246. * @param texture defines the BabylonJS internal texture
  56247. * @param createPolynomials will be true if polynomials have been requested
  56248. * @param onLoad defines the callback to trigger once the texture is ready
  56249. * @param onError defines the callback to trigger in case of error
  56250. */
  56251. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56252. /**
  56253. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56254. * @param data contains the texture data
  56255. * @param texture defines the BabylonJS internal texture
  56256. * @param callback defines the method to call once ready to upload
  56257. */
  56258. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56259. }
  56260. }
  56261. declare module BABYLON {
  56262. /**
  56263. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56264. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56265. */
  56266. export class KhronosTextureContainer {
  56267. /** contents of the KTX container file */
  56268. data: ArrayBufferView;
  56269. private static HEADER_LEN;
  56270. private static COMPRESSED_2D;
  56271. private static COMPRESSED_3D;
  56272. private static TEX_2D;
  56273. private static TEX_3D;
  56274. /**
  56275. * Gets the openGL type
  56276. */
  56277. glType: number;
  56278. /**
  56279. * Gets the openGL type size
  56280. */
  56281. glTypeSize: number;
  56282. /**
  56283. * Gets the openGL format
  56284. */
  56285. glFormat: number;
  56286. /**
  56287. * Gets the openGL internal format
  56288. */
  56289. glInternalFormat: number;
  56290. /**
  56291. * Gets the base internal format
  56292. */
  56293. glBaseInternalFormat: number;
  56294. /**
  56295. * Gets image width in pixel
  56296. */
  56297. pixelWidth: number;
  56298. /**
  56299. * Gets image height in pixel
  56300. */
  56301. pixelHeight: number;
  56302. /**
  56303. * Gets image depth in pixels
  56304. */
  56305. pixelDepth: number;
  56306. /**
  56307. * Gets the number of array elements
  56308. */
  56309. numberOfArrayElements: number;
  56310. /**
  56311. * Gets the number of faces
  56312. */
  56313. numberOfFaces: number;
  56314. /**
  56315. * Gets the number of mipmap levels
  56316. */
  56317. numberOfMipmapLevels: number;
  56318. /**
  56319. * Gets the bytes of key value data
  56320. */
  56321. bytesOfKeyValueData: number;
  56322. /**
  56323. * Gets the load type
  56324. */
  56325. loadType: number;
  56326. /**
  56327. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56328. */
  56329. isInvalid: boolean;
  56330. /**
  56331. * Creates a new KhronosTextureContainer
  56332. * @param data contents of the KTX container file
  56333. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56334. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56335. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56336. */
  56337. constructor(
  56338. /** contents of the KTX container file */
  56339. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56340. /**
  56341. * Uploads KTX content to a Babylon Texture.
  56342. * It is assumed that the texture has already been created & is currently bound
  56343. * @hidden
  56344. */
  56345. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56346. private _upload2DCompressedLevels;
  56347. /**
  56348. * Checks if the given data starts with a KTX file identifier.
  56349. * @param data the data to check
  56350. * @returns true if the data is a KTX file or false otherwise
  56351. */
  56352. static IsValid(data: ArrayBufferView): boolean;
  56353. }
  56354. }
  56355. declare module BABYLON {
  56356. /**
  56357. * Class for loading KTX2 files
  56358. * !!! Experimental Extension Subject to Changes !!!
  56359. * @hidden
  56360. */
  56361. export class KhronosTextureContainer2 {
  56362. private static _ModulePromise;
  56363. private static _TranscodeFormat;
  56364. constructor(engine: ThinEngine);
  56365. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56366. private _determineTranscodeFormat;
  56367. /**
  56368. * Checks if the given data starts with a KTX2 file identifier.
  56369. * @param data the data to check
  56370. * @returns true if the data is a KTX2 file or false otherwise
  56371. */
  56372. static IsValid(data: ArrayBufferView): boolean;
  56373. }
  56374. }
  56375. declare module BABYLON {
  56376. /**
  56377. * Implementation of the KTX Texture Loader.
  56378. * @hidden
  56379. */
  56380. export class _KTXTextureLoader implements IInternalTextureLoader {
  56381. /**
  56382. * Defines wether the loader supports cascade loading the different faces.
  56383. */
  56384. readonly supportCascades: boolean;
  56385. /**
  56386. * This returns if the loader support the current file information.
  56387. * @param extension defines the file extension of the file being loaded
  56388. * @returns true if the loader can load the specified file
  56389. */
  56390. canLoad(extension: string): boolean;
  56391. /**
  56392. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56393. * @param data contains the texture data
  56394. * @param texture defines the BabylonJS internal texture
  56395. * @param createPolynomials will be true if polynomials have been requested
  56396. * @param onLoad defines the callback to trigger once the texture is ready
  56397. * @param onError defines the callback to trigger in case of error
  56398. */
  56399. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56400. /**
  56401. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56402. * @param data contains the texture data
  56403. * @param texture defines the BabylonJS internal texture
  56404. * @param callback defines the method to call once ready to upload
  56405. */
  56406. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56407. }
  56408. }
  56409. declare module BABYLON {
  56410. /** @hidden */
  56411. export var _forceSceneHelpersToBundle: boolean;
  56412. interface Scene {
  56413. /**
  56414. * Creates a default light for the scene.
  56415. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56416. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56417. */
  56418. createDefaultLight(replace?: boolean): void;
  56419. /**
  56420. * Creates a default camera for the scene.
  56421. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56422. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56423. * @param replace has default false, when true replaces the active camera in the scene
  56424. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56425. */
  56426. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56427. /**
  56428. * Creates a default camera and a default light.
  56429. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56431. * @param replace has the default false, when true replaces the active camera/light in the scene
  56432. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56433. */
  56434. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56435. /**
  56436. * Creates a new sky box
  56437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56438. * @param environmentTexture defines the texture to use as environment texture
  56439. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56440. * @param scale defines the overall scale of the skybox
  56441. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56442. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56443. * @returns a new mesh holding the sky box
  56444. */
  56445. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56446. /**
  56447. * Creates a new environment
  56448. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56449. * @param options defines the options you can use to configure the environment
  56450. * @returns the new EnvironmentHelper
  56451. */
  56452. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56453. /**
  56454. * Creates a new VREXperienceHelper
  56455. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56456. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56457. * @returns a new VREXperienceHelper
  56458. */
  56459. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56460. /**
  56461. * Creates a new WebXRDefaultExperience
  56462. * @see http://doc.babylonjs.com/how_to/webxr
  56463. * @param options experience options
  56464. * @returns a promise for a new WebXRDefaultExperience
  56465. */
  56466. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56467. }
  56468. }
  56469. declare module BABYLON {
  56470. /**
  56471. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56472. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56473. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56474. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56475. */
  56476. export class VideoDome extends TransformNode {
  56477. /**
  56478. * Define the video source as a Monoscopic panoramic 360 video.
  56479. */
  56480. static readonly MODE_MONOSCOPIC: number;
  56481. /**
  56482. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56483. */
  56484. static readonly MODE_TOPBOTTOM: number;
  56485. /**
  56486. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56487. */
  56488. static readonly MODE_SIDEBYSIDE: number;
  56489. private _halfDome;
  56490. private _useDirectMapping;
  56491. /**
  56492. * The video texture being displayed on the sphere
  56493. */
  56494. protected _videoTexture: VideoTexture;
  56495. /**
  56496. * Gets the video texture being displayed on the sphere
  56497. */
  56498. get videoTexture(): VideoTexture;
  56499. /**
  56500. * The skybox material
  56501. */
  56502. protected _material: BackgroundMaterial;
  56503. /**
  56504. * The surface used for the skybox
  56505. */
  56506. protected _mesh: Mesh;
  56507. /**
  56508. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56509. */
  56510. private _halfDomeMask;
  56511. /**
  56512. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56513. * Also see the options.resolution property.
  56514. */
  56515. get fovMultiplier(): number;
  56516. set fovMultiplier(value: number);
  56517. private _videoMode;
  56518. /**
  56519. * Gets or set the current video mode for the video. It can be:
  56520. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56521. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56522. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56523. */
  56524. get videoMode(): number;
  56525. set videoMode(value: number);
  56526. /**
  56527. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56528. *
  56529. */
  56530. get halfDome(): boolean;
  56531. /**
  56532. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56533. */
  56534. set halfDome(enabled: boolean);
  56535. /**
  56536. * Oberserver used in Stereoscopic VR Mode.
  56537. */
  56538. private _onBeforeCameraRenderObserver;
  56539. /**
  56540. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56541. * @param name Element's name, child elements will append suffixes for their own names.
  56542. * @param urlsOrVideo defines the url(s) or the video element to use
  56543. * @param options An object containing optional or exposed sub element properties
  56544. */
  56545. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56546. resolution?: number;
  56547. clickToPlay?: boolean;
  56548. autoPlay?: boolean;
  56549. loop?: boolean;
  56550. size?: number;
  56551. poster?: string;
  56552. faceForward?: boolean;
  56553. useDirectMapping?: boolean;
  56554. halfDomeMode?: boolean;
  56555. }, scene: Scene);
  56556. private _changeVideoMode;
  56557. /**
  56558. * Releases resources associated with this node.
  56559. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56560. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56561. */
  56562. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56563. }
  56564. }
  56565. declare module BABYLON {
  56566. /**
  56567. * This class can be used to get instrumentation data from a Babylon engine
  56568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56569. */
  56570. export class EngineInstrumentation implements IDisposable {
  56571. /**
  56572. * Define the instrumented engine.
  56573. */
  56574. engine: Engine;
  56575. private _captureGPUFrameTime;
  56576. private _gpuFrameTimeToken;
  56577. private _gpuFrameTime;
  56578. private _captureShaderCompilationTime;
  56579. private _shaderCompilationTime;
  56580. private _onBeginFrameObserver;
  56581. private _onEndFrameObserver;
  56582. private _onBeforeShaderCompilationObserver;
  56583. private _onAfterShaderCompilationObserver;
  56584. /**
  56585. * Gets the perf counter used for GPU frame time
  56586. */
  56587. get gpuFrameTimeCounter(): PerfCounter;
  56588. /**
  56589. * Gets the GPU frame time capture status
  56590. */
  56591. get captureGPUFrameTime(): boolean;
  56592. /**
  56593. * Enable or disable the GPU frame time capture
  56594. */
  56595. set captureGPUFrameTime(value: boolean);
  56596. /**
  56597. * Gets the perf counter used for shader compilation time
  56598. */
  56599. get shaderCompilationTimeCounter(): PerfCounter;
  56600. /**
  56601. * Gets the shader compilation time capture status
  56602. */
  56603. get captureShaderCompilationTime(): boolean;
  56604. /**
  56605. * Enable or disable the shader compilation time capture
  56606. */
  56607. set captureShaderCompilationTime(value: boolean);
  56608. /**
  56609. * Instantiates a new engine instrumentation.
  56610. * This class can be used to get instrumentation data from a Babylon engine
  56611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56612. * @param engine Defines the engine to instrument
  56613. */
  56614. constructor(
  56615. /**
  56616. * Define the instrumented engine.
  56617. */
  56618. engine: Engine);
  56619. /**
  56620. * Dispose and release associated resources.
  56621. */
  56622. dispose(): void;
  56623. }
  56624. }
  56625. declare module BABYLON {
  56626. /**
  56627. * This class can be used to get instrumentation data from a Babylon engine
  56628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56629. */
  56630. export class SceneInstrumentation implements IDisposable {
  56631. /**
  56632. * Defines the scene to instrument
  56633. */
  56634. scene: Scene;
  56635. private _captureActiveMeshesEvaluationTime;
  56636. private _activeMeshesEvaluationTime;
  56637. private _captureRenderTargetsRenderTime;
  56638. private _renderTargetsRenderTime;
  56639. private _captureFrameTime;
  56640. private _frameTime;
  56641. private _captureRenderTime;
  56642. private _renderTime;
  56643. private _captureInterFrameTime;
  56644. private _interFrameTime;
  56645. private _captureParticlesRenderTime;
  56646. private _particlesRenderTime;
  56647. private _captureSpritesRenderTime;
  56648. private _spritesRenderTime;
  56649. private _capturePhysicsTime;
  56650. private _physicsTime;
  56651. private _captureAnimationsTime;
  56652. private _animationsTime;
  56653. private _captureCameraRenderTime;
  56654. private _cameraRenderTime;
  56655. private _onBeforeActiveMeshesEvaluationObserver;
  56656. private _onAfterActiveMeshesEvaluationObserver;
  56657. private _onBeforeRenderTargetsRenderObserver;
  56658. private _onAfterRenderTargetsRenderObserver;
  56659. private _onAfterRenderObserver;
  56660. private _onBeforeDrawPhaseObserver;
  56661. private _onAfterDrawPhaseObserver;
  56662. private _onBeforeAnimationsObserver;
  56663. private _onBeforeParticlesRenderingObserver;
  56664. private _onAfterParticlesRenderingObserver;
  56665. private _onBeforeSpritesRenderingObserver;
  56666. private _onAfterSpritesRenderingObserver;
  56667. private _onBeforePhysicsObserver;
  56668. private _onAfterPhysicsObserver;
  56669. private _onAfterAnimationsObserver;
  56670. private _onBeforeCameraRenderObserver;
  56671. private _onAfterCameraRenderObserver;
  56672. /**
  56673. * Gets the perf counter used for active meshes evaluation time
  56674. */
  56675. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56676. /**
  56677. * Gets the active meshes evaluation time capture status
  56678. */
  56679. get captureActiveMeshesEvaluationTime(): boolean;
  56680. /**
  56681. * Enable or disable the active meshes evaluation time capture
  56682. */
  56683. set captureActiveMeshesEvaluationTime(value: boolean);
  56684. /**
  56685. * Gets the perf counter used for render targets render time
  56686. */
  56687. get renderTargetsRenderTimeCounter(): PerfCounter;
  56688. /**
  56689. * Gets the render targets render time capture status
  56690. */
  56691. get captureRenderTargetsRenderTime(): boolean;
  56692. /**
  56693. * Enable or disable the render targets render time capture
  56694. */
  56695. set captureRenderTargetsRenderTime(value: boolean);
  56696. /**
  56697. * Gets the perf counter used for particles render time
  56698. */
  56699. get particlesRenderTimeCounter(): PerfCounter;
  56700. /**
  56701. * Gets the particles render time capture status
  56702. */
  56703. get captureParticlesRenderTime(): boolean;
  56704. /**
  56705. * Enable or disable the particles render time capture
  56706. */
  56707. set captureParticlesRenderTime(value: boolean);
  56708. /**
  56709. * Gets the perf counter used for sprites render time
  56710. */
  56711. get spritesRenderTimeCounter(): PerfCounter;
  56712. /**
  56713. * Gets the sprites render time capture status
  56714. */
  56715. get captureSpritesRenderTime(): boolean;
  56716. /**
  56717. * Enable or disable the sprites render time capture
  56718. */
  56719. set captureSpritesRenderTime(value: boolean);
  56720. /**
  56721. * Gets the perf counter used for physics time
  56722. */
  56723. get physicsTimeCounter(): PerfCounter;
  56724. /**
  56725. * Gets the physics time capture status
  56726. */
  56727. get capturePhysicsTime(): boolean;
  56728. /**
  56729. * Enable or disable the physics time capture
  56730. */
  56731. set capturePhysicsTime(value: boolean);
  56732. /**
  56733. * Gets the perf counter used for animations time
  56734. */
  56735. get animationsTimeCounter(): PerfCounter;
  56736. /**
  56737. * Gets the animations time capture status
  56738. */
  56739. get captureAnimationsTime(): boolean;
  56740. /**
  56741. * Enable or disable the animations time capture
  56742. */
  56743. set captureAnimationsTime(value: boolean);
  56744. /**
  56745. * Gets the perf counter used for frame time capture
  56746. */
  56747. get frameTimeCounter(): PerfCounter;
  56748. /**
  56749. * Gets the frame time capture status
  56750. */
  56751. get captureFrameTime(): boolean;
  56752. /**
  56753. * Enable or disable the frame time capture
  56754. */
  56755. set captureFrameTime(value: boolean);
  56756. /**
  56757. * Gets the perf counter used for inter-frames time capture
  56758. */
  56759. get interFrameTimeCounter(): PerfCounter;
  56760. /**
  56761. * Gets the inter-frames time capture status
  56762. */
  56763. get captureInterFrameTime(): boolean;
  56764. /**
  56765. * Enable or disable the inter-frames time capture
  56766. */
  56767. set captureInterFrameTime(value: boolean);
  56768. /**
  56769. * Gets the perf counter used for render time capture
  56770. */
  56771. get renderTimeCounter(): PerfCounter;
  56772. /**
  56773. * Gets the render time capture status
  56774. */
  56775. get captureRenderTime(): boolean;
  56776. /**
  56777. * Enable or disable the render time capture
  56778. */
  56779. set captureRenderTime(value: boolean);
  56780. /**
  56781. * Gets the perf counter used for camera render time capture
  56782. */
  56783. get cameraRenderTimeCounter(): PerfCounter;
  56784. /**
  56785. * Gets the camera render time capture status
  56786. */
  56787. get captureCameraRenderTime(): boolean;
  56788. /**
  56789. * Enable or disable the camera render time capture
  56790. */
  56791. set captureCameraRenderTime(value: boolean);
  56792. /**
  56793. * Gets the perf counter used for draw calls
  56794. */
  56795. get drawCallsCounter(): PerfCounter;
  56796. /**
  56797. * Instantiates a new scene instrumentation.
  56798. * This class can be used to get instrumentation data from a Babylon engine
  56799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56800. * @param scene Defines the scene to instrument
  56801. */
  56802. constructor(
  56803. /**
  56804. * Defines the scene to instrument
  56805. */
  56806. scene: Scene);
  56807. /**
  56808. * Dispose and release associated resources.
  56809. */
  56810. dispose(): void;
  56811. }
  56812. }
  56813. declare module BABYLON {
  56814. /** @hidden */
  56815. export var glowMapGenerationPixelShader: {
  56816. name: string;
  56817. shader: string;
  56818. };
  56819. }
  56820. declare module BABYLON {
  56821. /** @hidden */
  56822. export var glowMapGenerationVertexShader: {
  56823. name: string;
  56824. shader: string;
  56825. };
  56826. }
  56827. declare module BABYLON {
  56828. /**
  56829. * Effect layer options. This helps customizing the behaviour
  56830. * of the effect layer.
  56831. */
  56832. export interface IEffectLayerOptions {
  56833. /**
  56834. * Multiplication factor apply to the canvas size to compute the render target size
  56835. * used to generated the objects (the smaller the faster).
  56836. */
  56837. mainTextureRatio: number;
  56838. /**
  56839. * Enforces a fixed size texture to ensure effect stability across devices.
  56840. */
  56841. mainTextureFixedSize?: number;
  56842. /**
  56843. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56844. */
  56845. alphaBlendingMode: number;
  56846. /**
  56847. * The camera attached to the layer.
  56848. */
  56849. camera: Nullable<Camera>;
  56850. /**
  56851. * The rendering group to draw the layer in.
  56852. */
  56853. renderingGroupId: number;
  56854. }
  56855. /**
  56856. * The effect layer Helps adding post process effect blended with the main pass.
  56857. *
  56858. * This can be for instance use to generate glow or higlight effects on the scene.
  56859. *
  56860. * The effect layer class can not be used directly and is intented to inherited from to be
  56861. * customized per effects.
  56862. */
  56863. export abstract class EffectLayer {
  56864. private _vertexBuffers;
  56865. private _indexBuffer;
  56866. private _cachedDefines;
  56867. private _effectLayerMapGenerationEffect;
  56868. private _effectLayerOptions;
  56869. private _mergeEffect;
  56870. protected _scene: Scene;
  56871. protected _engine: Engine;
  56872. protected _maxSize: number;
  56873. protected _mainTextureDesiredSize: ISize;
  56874. protected _mainTexture: RenderTargetTexture;
  56875. protected _shouldRender: boolean;
  56876. protected _postProcesses: PostProcess[];
  56877. protected _textures: BaseTexture[];
  56878. protected _emissiveTextureAndColor: {
  56879. texture: Nullable<BaseTexture>;
  56880. color: Color4;
  56881. };
  56882. /**
  56883. * The name of the layer
  56884. */
  56885. name: string;
  56886. /**
  56887. * The clear color of the texture used to generate the glow map.
  56888. */
  56889. neutralColor: Color4;
  56890. /**
  56891. * Specifies whether the highlight layer is enabled or not.
  56892. */
  56893. isEnabled: boolean;
  56894. /**
  56895. * Gets the camera attached to the layer.
  56896. */
  56897. get camera(): Nullable<Camera>;
  56898. /**
  56899. * Gets the rendering group id the layer should render in.
  56900. */
  56901. get renderingGroupId(): number;
  56902. set renderingGroupId(renderingGroupId: number);
  56903. /**
  56904. * An event triggered when the effect layer has been disposed.
  56905. */
  56906. onDisposeObservable: Observable<EffectLayer>;
  56907. /**
  56908. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56909. */
  56910. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56911. /**
  56912. * An event triggered when the generated texture is being merged in the scene.
  56913. */
  56914. onBeforeComposeObservable: Observable<EffectLayer>;
  56915. /**
  56916. * An event triggered when the mesh is rendered into the effect render target.
  56917. */
  56918. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56919. /**
  56920. * An event triggered after the mesh has been rendered into the effect render target.
  56921. */
  56922. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56923. /**
  56924. * An event triggered when the generated texture has been merged in the scene.
  56925. */
  56926. onAfterComposeObservable: Observable<EffectLayer>;
  56927. /**
  56928. * An event triggered when the efffect layer changes its size.
  56929. */
  56930. onSizeChangedObservable: Observable<EffectLayer>;
  56931. /** @hidden */
  56932. static _SceneComponentInitialization: (scene: Scene) => void;
  56933. /**
  56934. * Instantiates a new effect Layer and references it in the scene.
  56935. * @param name The name of the layer
  56936. * @param scene The scene to use the layer in
  56937. */
  56938. constructor(
  56939. /** The Friendly of the effect in the scene */
  56940. name: string, scene: Scene);
  56941. /**
  56942. * Get the effect name of the layer.
  56943. * @return The effect name
  56944. */
  56945. abstract getEffectName(): string;
  56946. /**
  56947. * Checks for the readiness of the element composing the layer.
  56948. * @param subMesh the mesh to check for
  56949. * @param useInstances specify whether or not to use instances to render the mesh
  56950. * @return true if ready otherwise, false
  56951. */
  56952. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56953. /**
  56954. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56955. * @returns true if the effect requires stencil during the main canvas render pass.
  56956. */
  56957. abstract needStencil(): boolean;
  56958. /**
  56959. * Create the merge effect. This is the shader use to blit the information back
  56960. * to the main canvas at the end of the scene rendering.
  56961. * @returns The effect containing the shader used to merge the effect on the main canvas
  56962. */
  56963. protected abstract _createMergeEffect(): Effect;
  56964. /**
  56965. * Creates the render target textures and post processes used in the effect layer.
  56966. */
  56967. protected abstract _createTextureAndPostProcesses(): void;
  56968. /**
  56969. * Implementation specific of rendering the generating effect on the main canvas.
  56970. * @param effect The effect used to render through
  56971. */
  56972. protected abstract _internalRender(effect: Effect): void;
  56973. /**
  56974. * Sets the required values for both the emissive texture and and the main color.
  56975. */
  56976. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56977. /**
  56978. * Free any resources and references associated to a mesh.
  56979. * Internal use
  56980. * @param mesh The mesh to free.
  56981. */
  56982. abstract _disposeMesh(mesh: Mesh): void;
  56983. /**
  56984. * Serializes this layer (Glow or Highlight for example)
  56985. * @returns a serialized layer object
  56986. */
  56987. abstract serialize?(): any;
  56988. /**
  56989. * Initializes the effect layer with the required options.
  56990. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56991. */
  56992. protected _init(options: Partial<IEffectLayerOptions>): void;
  56993. /**
  56994. * Generates the index buffer of the full screen quad blending to the main canvas.
  56995. */
  56996. private _generateIndexBuffer;
  56997. /**
  56998. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56999. */
  57000. private _generateVertexBuffer;
  57001. /**
  57002. * Sets the main texture desired size which is the closest power of two
  57003. * of the engine canvas size.
  57004. */
  57005. private _setMainTextureSize;
  57006. /**
  57007. * Creates the main texture for the effect layer.
  57008. */
  57009. protected _createMainTexture(): void;
  57010. /**
  57011. * Adds specific effects defines.
  57012. * @param defines The defines to add specifics to.
  57013. */
  57014. protected _addCustomEffectDefines(defines: string[]): void;
  57015. /**
  57016. * Checks for the readiness of the element composing the layer.
  57017. * @param subMesh the mesh to check for
  57018. * @param useInstances specify whether or not to use instances to render the mesh
  57019. * @param emissiveTexture the associated emissive texture used to generate the glow
  57020. * @return true if ready otherwise, false
  57021. */
  57022. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57023. /**
  57024. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57025. */
  57026. render(): void;
  57027. /**
  57028. * Determine if a given mesh will be used in the current effect.
  57029. * @param mesh mesh to test
  57030. * @returns true if the mesh will be used
  57031. */
  57032. hasMesh(mesh: AbstractMesh): boolean;
  57033. /**
  57034. * Returns true if the layer contains information to display, otherwise false.
  57035. * @returns true if the glow layer should be rendered
  57036. */
  57037. shouldRender(): boolean;
  57038. /**
  57039. * Returns true if the mesh should render, otherwise false.
  57040. * @param mesh The mesh to render
  57041. * @returns true if it should render otherwise false
  57042. */
  57043. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57044. /**
  57045. * Returns true if the mesh can be rendered, otherwise false.
  57046. * @param mesh The mesh to render
  57047. * @param material The material used on the mesh
  57048. * @returns true if it can be rendered otherwise false
  57049. */
  57050. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57051. /**
  57052. * Returns true if the mesh should render, otherwise false.
  57053. * @param mesh The mesh to render
  57054. * @returns true if it should render otherwise false
  57055. */
  57056. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57057. /**
  57058. * Renders the submesh passed in parameter to the generation map.
  57059. */
  57060. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57061. /**
  57062. * Defines whether the current material of the mesh should be use to render the effect.
  57063. * @param mesh defines the current mesh to render
  57064. */
  57065. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57066. /**
  57067. * Rebuild the required buffers.
  57068. * @hidden Internal use only.
  57069. */
  57070. _rebuild(): void;
  57071. /**
  57072. * Dispose only the render target textures and post process.
  57073. */
  57074. private _disposeTextureAndPostProcesses;
  57075. /**
  57076. * Dispose the highlight layer and free resources.
  57077. */
  57078. dispose(): void;
  57079. /**
  57080. * Gets the class name of the effect layer
  57081. * @returns the string with the class name of the effect layer
  57082. */
  57083. getClassName(): string;
  57084. /**
  57085. * Creates an effect layer from parsed effect layer data
  57086. * @param parsedEffectLayer defines effect layer data
  57087. * @param scene defines the current scene
  57088. * @param rootUrl defines the root URL containing the effect layer information
  57089. * @returns a parsed effect Layer
  57090. */
  57091. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57092. }
  57093. }
  57094. declare module BABYLON {
  57095. interface AbstractScene {
  57096. /**
  57097. * The list of effect layers (highlights/glow) added to the scene
  57098. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57099. * @see http://doc.babylonjs.com/how_to/glow_layer
  57100. */
  57101. effectLayers: Array<EffectLayer>;
  57102. /**
  57103. * Removes the given effect layer from this scene.
  57104. * @param toRemove defines the effect layer to remove
  57105. * @returns the index of the removed effect layer
  57106. */
  57107. removeEffectLayer(toRemove: EffectLayer): number;
  57108. /**
  57109. * Adds the given effect layer to this scene
  57110. * @param newEffectLayer defines the effect layer to add
  57111. */
  57112. addEffectLayer(newEffectLayer: EffectLayer): void;
  57113. }
  57114. /**
  57115. * Defines the layer scene component responsible to manage any effect layers
  57116. * in a given scene.
  57117. */
  57118. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57119. /**
  57120. * The component name helpfull to identify the component in the list of scene components.
  57121. */
  57122. readonly name: string;
  57123. /**
  57124. * The scene the component belongs to.
  57125. */
  57126. scene: Scene;
  57127. private _engine;
  57128. private _renderEffects;
  57129. private _needStencil;
  57130. private _previousStencilState;
  57131. /**
  57132. * Creates a new instance of the component for the given scene
  57133. * @param scene Defines the scene to register the component in
  57134. */
  57135. constructor(scene: Scene);
  57136. /**
  57137. * Registers the component in a given scene
  57138. */
  57139. register(): void;
  57140. /**
  57141. * Rebuilds the elements related to this component in case of
  57142. * context lost for instance.
  57143. */
  57144. rebuild(): void;
  57145. /**
  57146. * Serializes the component data to the specified json object
  57147. * @param serializationObject The object to serialize to
  57148. */
  57149. serialize(serializationObject: any): void;
  57150. /**
  57151. * Adds all the elements from the container to the scene
  57152. * @param container the container holding the elements
  57153. */
  57154. addFromContainer(container: AbstractScene): void;
  57155. /**
  57156. * Removes all the elements in the container from the scene
  57157. * @param container contains the elements to remove
  57158. * @param dispose if the removed element should be disposed (default: false)
  57159. */
  57160. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57161. /**
  57162. * Disposes the component and the associated ressources.
  57163. */
  57164. dispose(): void;
  57165. private _isReadyForMesh;
  57166. private _renderMainTexture;
  57167. private _setStencil;
  57168. private _setStencilBack;
  57169. private _draw;
  57170. private _drawCamera;
  57171. private _drawRenderingGroup;
  57172. }
  57173. }
  57174. declare module BABYLON {
  57175. /** @hidden */
  57176. export var glowMapMergePixelShader: {
  57177. name: string;
  57178. shader: string;
  57179. };
  57180. }
  57181. declare module BABYLON {
  57182. /** @hidden */
  57183. export var glowMapMergeVertexShader: {
  57184. name: string;
  57185. shader: string;
  57186. };
  57187. }
  57188. declare module BABYLON {
  57189. interface AbstractScene {
  57190. /**
  57191. * Return a the first highlight layer of the scene with a given name.
  57192. * @param name The name of the highlight layer to look for.
  57193. * @return The highlight layer if found otherwise null.
  57194. */
  57195. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57196. }
  57197. /**
  57198. * Glow layer options. This helps customizing the behaviour
  57199. * of the glow layer.
  57200. */
  57201. export interface IGlowLayerOptions {
  57202. /**
  57203. * Multiplication factor apply to the canvas size to compute the render target size
  57204. * used to generated the glowing objects (the smaller the faster).
  57205. */
  57206. mainTextureRatio: number;
  57207. /**
  57208. * Enforces a fixed size texture to ensure resize independant blur.
  57209. */
  57210. mainTextureFixedSize?: number;
  57211. /**
  57212. * How big is the kernel of the blur texture.
  57213. */
  57214. blurKernelSize: number;
  57215. /**
  57216. * The camera attached to the layer.
  57217. */
  57218. camera: Nullable<Camera>;
  57219. /**
  57220. * Enable MSAA by chosing the number of samples.
  57221. */
  57222. mainTextureSamples?: number;
  57223. /**
  57224. * The rendering group to draw the layer in.
  57225. */
  57226. renderingGroupId: number;
  57227. }
  57228. /**
  57229. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57230. *
  57231. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57232. *
  57233. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57234. */
  57235. export class GlowLayer extends EffectLayer {
  57236. /**
  57237. * Effect Name of the layer.
  57238. */
  57239. static readonly EffectName: string;
  57240. /**
  57241. * The default blur kernel size used for the glow.
  57242. */
  57243. static DefaultBlurKernelSize: number;
  57244. /**
  57245. * The default texture size ratio used for the glow.
  57246. */
  57247. static DefaultTextureRatio: number;
  57248. /**
  57249. * Sets the kernel size of the blur.
  57250. */
  57251. set blurKernelSize(value: number);
  57252. /**
  57253. * Gets the kernel size of the blur.
  57254. */
  57255. get blurKernelSize(): number;
  57256. /**
  57257. * Sets the glow intensity.
  57258. */
  57259. set intensity(value: number);
  57260. /**
  57261. * Gets the glow intensity.
  57262. */
  57263. get intensity(): number;
  57264. private _options;
  57265. private _intensity;
  57266. private _horizontalBlurPostprocess1;
  57267. private _verticalBlurPostprocess1;
  57268. private _horizontalBlurPostprocess2;
  57269. private _verticalBlurPostprocess2;
  57270. private _blurTexture1;
  57271. private _blurTexture2;
  57272. private _postProcesses1;
  57273. private _postProcesses2;
  57274. private _includedOnlyMeshes;
  57275. private _excludedMeshes;
  57276. private _meshesUsingTheirOwnMaterials;
  57277. /**
  57278. * Callback used to let the user override the color selection on a per mesh basis
  57279. */
  57280. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57281. /**
  57282. * Callback used to let the user override the texture selection on a per mesh basis
  57283. */
  57284. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57285. /**
  57286. * Instantiates a new glow Layer and references it to the scene.
  57287. * @param name The name of the layer
  57288. * @param scene The scene to use the layer in
  57289. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57290. */
  57291. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57292. /**
  57293. * Get the effect name of the layer.
  57294. * @return The effect name
  57295. */
  57296. getEffectName(): string;
  57297. /**
  57298. * Create the merge effect. This is the shader use to blit the information back
  57299. * to the main canvas at the end of the scene rendering.
  57300. */
  57301. protected _createMergeEffect(): Effect;
  57302. /**
  57303. * Creates the render target textures and post processes used in the glow layer.
  57304. */
  57305. protected _createTextureAndPostProcesses(): void;
  57306. /**
  57307. * Checks for the readiness of the element composing the layer.
  57308. * @param subMesh the mesh to check for
  57309. * @param useInstances specify wether or not to use instances to render the mesh
  57310. * @param emissiveTexture the associated emissive texture used to generate the glow
  57311. * @return true if ready otherwise, false
  57312. */
  57313. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57314. /**
  57315. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57316. */
  57317. needStencil(): boolean;
  57318. /**
  57319. * Returns true if the mesh can be rendered, otherwise false.
  57320. * @param mesh The mesh to render
  57321. * @param material The material used on the mesh
  57322. * @returns true if it can be rendered otherwise false
  57323. */
  57324. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57325. /**
  57326. * Implementation specific of rendering the generating effect on the main canvas.
  57327. * @param effect The effect used to render through
  57328. */
  57329. protected _internalRender(effect: Effect): void;
  57330. /**
  57331. * Sets the required values for both the emissive texture and and the main color.
  57332. */
  57333. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57334. /**
  57335. * Returns true if the mesh should render, otherwise false.
  57336. * @param mesh The mesh to render
  57337. * @returns true if it should render otherwise false
  57338. */
  57339. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57340. /**
  57341. * Adds specific effects defines.
  57342. * @param defines The defines to add specifics to.
  57343. */
  57344. protected _addCustomEffectDefines(defines: string[]): void;
  57345. /**
  57346. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57347. * @param mesh The mesh to exclude from the glow layer
  57348. */
  57349. addExcludedMesh(mesh: Mesh): void;
  57350. /**
  57351. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57352. * @param mesh The mesh to remove
  57353. */
  57354. removeExcludedMesh(mesh: Mesh): void;
  57355. /**
  57356. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57357. * @param mesh The mesh to include in the glow layer
  57358. */
  57359. addIncludedOnlyMesh(mesh: Mesh): void;
  57360. /**
  57361. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57362. * @param mesh The mesh to remove
  57363. */
  57364. removeIncludedOnlyMesh(mesh: Mesh): void;
  57365. /**
  57366. * Determine if a given mesh will be used in the glow layer
  57367. * @param mesh The mesh to test
  57368. * @returns true if the mesh will be highlighted by the current glow layer
  57369. */
  57370. hasMesh(mesh: AbstractMesh): boolean;
  57371. /**
  57372. * Defines whether the current material of the mesh should be use to render the effect.
  57373. * @param mesh defines the current mesh to render
  57374. */
  57375. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57376. /**
  57377. * Add a mesh to be rendered through its own material and not with emissive only.
  57378. * @param mesh The mesh for which we need to use its material
  57379. */
  57380. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57381. /**
  57382. * Remove a mesh from being rendered through its own material and not with emissive only.
  57383. * @param mesh The mesh for which we need to not use its material
  57384. */
  57385. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57386. /**
  57387. * Free any resources and references associated to a mesh.
  57388. * Internal use
  57389. * @param mesh The mesh to free.
  57390. * @hidden
  57391. */
  57392. _disposeMesh(mesh: Mesh): void;
  57393. /**
  57394. * Gets the class name of the effect layer
  57395. * @returns the string with the class name of the effect layer
  57396. */
  57397. getClassName(): string;
  57398. /**
  57399. * Serializes this glow layer
  57400. * @returns a serialized glow layer object
  57401. */
  57402. serialize(): any;
  57403. /**
  57404. * Creates a Glow Layer from parsed glow layer data
  57405. * @param parsedGlowLayer defines glow layer data
  57406. * @param scene defines the current scene
  57407. * @param rootUrl defines the root URL containing the glow layer information
  57408. * @returns a parsed Glow Layer
  57409. */
  57410. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57411. }
  57412. }
  57413. declare module BABYLON {
  57414. /** @hidden */
  57415. export var glowBlurPostProcessPixelShader: {
  57416. name: string;
  57417. shader: string;
  57418. };
  57419. }
  57420. declare module BABYLON {
  57421. interface AbstractScene {
  57422. /**
  57423. * Return a the first highlight layer of the scene with a given name.
  57424. * @param name The name of the highlight layer to look for.
  57425. * @return The highlight layer if found otherwise null.
  57426. */
  57427. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57428. }
  57429. /**
  57430. * Highlight layer options. This helps customizing the behaviour
  57431. * of the highlight layer.
  57432. */
  57433. export interface IHighlightLayerOptions {
  57434. /**
  57435. * Multiplication factor apply to the canvas size to compute the render target size
  57436. * used to generated the glowing objects (the smaller the faster).
  57437. */
  57438. mainTextureRatio: number;
  57439. /**
  57440. * Enforces a fixed size texture to ensure resize independant blur.
  57441. */
  57442. mainTextureFixedSize?: number;
  57443. /**
  57444. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57445. * of the picture to blur (the smaller the faster).
  57446. */
  57447. blurTextureSizeRatio: number;
  57448. /**
  57449. * How big in texel of the blur texture is the vertical blur.
  57450. */
  57451. blurVerticalSize: number;
  57452. /**
  57453. * How big in texel of the blur texture is the horizontal blur.
  57454. */
  57455. blurHorizontalSize: number;
  57456. /**
  57457. * Alpha blending mode used to apply the blur. Default is combine.
  57458. */
  57459. alphaBlendingMode: number;
  57460. /**
  57461. * The camera attached to the layer.
  57462. */
  57463. camera: Nullable<Camera>;
  57464. /**
  57465. * Should we display highlight as a solid stroke?
  57466. */
  57467. isStroke?: boolean;
  57468. /**
  57469. * The rendering group to draw the layer in.
  57470. */
  57471. renderingGroupId: number;
  57472. }
  57473. /**
  57474. * The highlight layer Helps adding a glow effect around a mesh.
  57475. *
  57476. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57477. * glowy meshes to your scene.
  57478. *
  57479. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57480. */
  57481. export class HighlightLayer extends EffectLayer {
  57482. name: string;
  57483. /**
  57484. * Effect Name of the highlight layer.
  57485. */
  57486. static readonly EffectName: string;
  57487. /**
  57488. * The neutral color used during the preparation of the glow effect.
  57489. * This is black by default as the blend operation is a blend operation.
  57490. */
  57491. static NeutralColor: Color4;
  57492. /**
  57493. * Stencil value used for glowing meshes.
  57494. */
  57495. static GlowingMeshStencilReference: number;
  57496. /**
  57497. * Stencil value used for the other meshes in the scene.
  57498. */
  57499. static NormalMeshStencilReference: number;
  57500. /**
  57501. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57502. */
  57503. innerGlow: boolean;
  57504. /**
  57505. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57506. */
  57507. outerGlow: boolean;
  57508. /**
  57509. * Specifies the horizontal size of the blur.
  57510. */
  57511. set blurHorizontalSize(value: number);
  57512. /**
  57513. * Specifies the vertical size of the blur.
  57514. */
  57515. set blurVerticalSize(value: number);
  57516. /**
  57517. * Gets the horizontal size of the blur.
  57518. */
  57519. get blurHorizontalSize(): number;
  57520. /**
  57521. * Gets the vertical size of the blur.
  57522. */
  57523. get blurVerticalSize(): number;
  57524. /**
  57525. * An event triggered when the highlight layer is being blurred.
  57526. */
  57527. onBeforeBlurObservable: Observable<HighlightLayer>;
  57528. /**
  57529. * An event triggered when the highlight layer has been blurred.
  57530. */
  57531. onAfterBlurObservable: Observable<HighlightLayer>;
  57532. private _instanceGlowingMeshStencilReference;
  57533. private _options;
  57534. private _downSamplePostprocess;
  57535. private _horizontalBlurPostprocess;
  57536. private _verticalBlurPostprocess;
  57537. private _blurTexture;
  57538. private _meshes;
  57539. private _excludedMeshes;
  57540. /**
  57541. * Instantiates a new highlight Layer and references it to the scene..
  57542. * @param name The name of the layer
  57543. * @param scene The scene to use the layer in
  57544. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57545. */
  57546. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57547. /**
  57548. * Get the effect name of the layer.
  57549. * @return The effect name
  57550. */
  57551. getEffectName(): string;
  57552. /**
  57553. * Create the merge effect. This is the shader use to blit the information back
  57554. * to the main canvas at the end of the scene rendering.
  57555. */
  57556. protected _createMergeEffect(): Effect;
  57557. /**
  57558. * Creates the render target textures and post processes used in the highlight layer.
  57559. */
  57560. protected _createTextureAndPostProcesses(): void;
  57561. /**
  57562. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57563. */
  57564. needStencil(): boolean;
  57565. /**
  57566. * Checks for the readiness of the element composing the layer.
  57567. * @param subMesh the mesh to check for
  57568. * @param useInstances specify wether or not to use instances to render the mesh
  57569. * @param emissiveTexture the associated emissive texture used to generate the glow
  57570. * @return true if ready otherwise, false
  57571. */
  57572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57573. /**
  57574. * Implementation specific of rendering the generating effect on the main canvas.
  57575. * @param effect The effect used to render through
  57576. */
  57577. protected _internalRender(effect: Effect): void;
  57578. /**
  57579. * Returns true if the layer contains information to display, otherwise false.
  57580. */
  57581. shouldRender(): boolean;
  57582. /**
  57583. * Returns true if the mesh should render, otherwise false.
  57584. * @param mesh The mesh to render
  57585. * @returns true if it should render otherwise false
  57586. */
  57587. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57588. /**
  57589. * Adds specific effects defines.
  57590. * @param defines The defines to add specifics to.
  57591. */
  57592. protected _addCustomEffectDefines(defines: string[]): void;
  57593. /**
  57594. * Sets the required values for both the emissive texture and and the main color.
  57595. */
  57596. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57597. /**
  57598. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57599. * @param mesh The mesh to exclude from the highlight layer
  57600. */
  57601. addExcludedMesh(mesh: Mesh): void;
  57602. /**
  57603. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57604. * @param mesh The mesh to highlight
  57605. */
  57606. removeExcludedMesh(mesh: Mesh): void;
  57607. /**
  57608. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57609. * @param mesh mesh to test
  57610. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57611. */
  57612. hasMesh(mesh: AbstractMesh): boolean;
  57613. /**
  57614. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57615. * @param mesh The mesh to highlight
  57616. * @param color The color of the highlight
  57617. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57618. */
  57619. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57620. /**
  57621. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57622. * @param mesh The mesh to highlight
  57623. */
  57624. removeMesh(mesh: Mesh): void;
  57625. /**
  57626. * Remove all the meshes currently referenced in the highlight layer
  57627. */
  57628. removeAllMeshes(): void;
  57629. /**
  57630. * Force the stencil to the normal expected value for none glowing parts
  57631. */
  57632. private _defaultStencilReference;
  57633. /**
  57634. * Free any resources and references associated to a mesh.
  57635. * Internal use
  57636. * @param mesh The mesh to free.
  57637. * @hidden
  57638. */
  57639. _disposeMesh(mesh: Mesh): void;
  57640. /**
  57641. * Dispose the highlight layer and free resources.
  57642. */
  57643. dispose(): void;
  57644. /**
  57645. * Gets the class name of the effect layer
  57646. * @returns the string with the class name of the effect layer
  57647. */
  57648. getClassName(): string;
  57649. /**
  57650. * Serializes this Highlight layer
  57651. * @returns a serialized Highlight layer object
  57652. */
  57653. serialize(): any;
  57654. /**
  57655. * Creates a Highlight layer from parsed Highlight layer data
  57656. * @param parsedHightlightLayer defines the Highlight layer data
  57657. * @param scene defines the current scene
  57658. * @param rootUrl defines the root URL containing the Highlight layer information
  57659. * @returns a parsed Highlight layer
  57660. */
  57661. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57662. }
  57663. }
  57664. declare module BABYLON {
  57665. interface AbstractScene {
  57666. /**
  57667. * The list of layers (background and foreground) of the scene
  57668. */
  57669. layers: Array<Layer>;
  57670. }
  57671. /**
  57672. * Defines the layer scene component responsible to manage any layers
  57673. * in a given scene.
  57674. */
  57675. export class LayerSceneComponent implements ISceneComponent {
  57676. /**
  57677. * The component name helpfull to identify the component in the list of scene components.
  57678. */
  57679. readonly name: string;
  57680. /**
  57681. * The scene the component belongs to.
  57682. */
  57683. scene: Scene;
  57684. private _engine;
  57685. /**
  57686. * Creates a new instance of the component for the given scene
  57687. * @param scene Defines the scene to register the component in
  57688. */
  57689. constructor(scene: Scene);
  57690. /**
  57691. * Registers the component in a given scene
  57692. */
  57693. register(): void;
  57694. /**
  57695. * Rebuilds the elements related to this component in case of
  57696. * context lost for instance.
  57697. */
  57698. rebuild(): void;
  57699. /**
  57700. * Disposes the component and the associated ressources.
  57701. */
  57702. dispose(): void;
  57703. private _draw;
  57704. private _drawCameraPredicate;
  57705. private _drawCameraBackground;
  57706. private _drawCameraForeground;
  57707. private _drawRenderTargetPredicate;
  57708. private _drawRenderTargetBackground;
  57709. private _drawRenderTargetForeground;
  57710. /**
  57711. * Adds all the elements from the container to the scene
  57712. * @param container the container holding the elements
  57713. */
  57714. addFromContainer(container: AbstractScene): void;
  57715. /**
  57716. * Removes all the elements in the container from the scene
  57717. * @param container contains the elements to remove
  57718. * @param dispose if the removed element should be disposed (default: false)
  57719. */
  57720. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57721. }
  57722. }
  57723. declare module BABYLON {
  57724. /** @hidden */
  57725. export var layerPixelShader: {
  57726. name: string;
  57727. shader: string;
  57728. };
  57729. }
  57730. declare module BABYLON {
  57731. /** @hidden */
  57732. export var layerVertexShader: {
  57733. name: string;
  57734. shader: string;
  57735. };
  57736. }
  57737. declare module BABYLON {
  57738. /**
  57739. * This represents a full screen 2d layer.
  57740. * This can be useful to display a picture in the background of your scene for instance.
  57741. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57742. */
  57743. export class Layer {
  57744. /**
  57745. * Define the name of the layer.
  57746. */
  57747. name: string;
  57748. /**
  57749. * Define the texture the layer should display.
  57750. */
  57751. texture: Nullable<Texture>;
  57752. /**
  57753. * Is the layer in background or foreground.
  57754. */
  57755. isBackground: boolean;
  57756. /**
  57757. * Define the color of the layer (instead of texture).
  57758. */
  57759. color: Color4;
  57760. /**
  57761. * Define the scale of the layer in order to zoom in out of the texture.
  57762. */
  57763. scale: Vector2;
  57764. /**
  57765. * Define an offset for the layer in order to shift the texture.
  57766. */
  57767. offset: Vector2;
  57768. /**
  57769. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57770. */
  57771. alphaBlendingMode: number;
  57772. /**
  57773. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57774. * Alpha test will not mix with the background color in case of transparency.
  57775. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57776. */
  57777. alphaTest: boolean;
  57778. /**
  57779. * Define a mask to restrict the layer to only some of the scene cameras.
  57780. */
  57781. layerMask: number;
  57782. /**
  57783. * Define the list of render target the layer is visible into.
  57784. */
  57785. renderTargetTextures: RenderTargetTexture[];
  57786. /**
  57787. * Define if the layer is only used in renderTarget or if it also
  57788. * renders in the main frame buffer of the canvas.
  57789. */
  57790. renderOnlyInRenderTargetTextures: boolean;
  57791. private _scene;
  57792. private _vertexBuffers;
  57793. private _indexBuffer;
  57794. private _effect;
  57795. private _previousDefines;
  57796. /**
  57797. * An event triggered when the layer is disposed.
  57798. */
  57799. onDisposeObservable: Observable<Layer>;
  57800. private _onDisposeObserver;
  57801. /**
  57802. * Back compatibility with callback before the onDisposeObservable existed.
  57803. * The set callback will be triggered when the layer has been disposed.
  57804. */
  57805. set onDispose(callback: () => void);
  57806. /**
  57807. * An event triggered before rendering the scene
  57808. */
  57809. onBeforeRenderObservable: Observable<Layer>;
  57810. private _onBeforeRenderObserver;
  57811. /**
  57812. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57813. * The set callback will be triggered just before rendering the layer.
  57814. */
  57815. set onBeforeRender(callback: () => void);
  57816. /**
  57817. * An event triggered after rendering the scene
  57818. */
  57819. onAfterRenderObservable: Observable<Layer>;
  57820. private _onAfterRenderObserver;
  57821. /**
  57822. * Back compatibility with callback before the onAfterRenderObservable existed.
  57823. * The set callback will be triggered just after rendering the layer.
  57824. */
  57825. set onAfterRender(callback: () => void);
  57826. /**
  57827. * Instantiates a new layer.
  57828. * This represents a full screen 2d layer.
  57829. * This can be useful to display a picture in the background of your scene for instance.
  57830. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57831. * @param name Define the name of the layer in the scene
  57832. * @param imgUrl Define the url of the texture to display in the layer
  57833. * @param scene Define the scene the layer belongs to
  57834. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57835. * @param color Defines a color for the layer
  57836. */
  57837. constructor(
  57838. /**
  57839. * Define the name of the layer.
  57840. */
  57841. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57842. private _createIndexBuffer;
  57843. /** @hidden */
  57844. _rebuild(): void;
  57845. /**
  57846. * Renders the layer in the scene.
  57847. */
  57848. render(): void;
  57849. /**
  57850. * Disposes and releases the associated ressources.
  57851. */
  57852. dispose(): void;
  57853. }
  57854. }
  57855. declare module BABYLON {
  57856. /** @hidden */
  57857. export var lensFlarePixelShader: {
  57858. name: string;
  57859. shader: string;
  57860. };
  57861. }
  57862. declare module BABYLON {
  57863. /** @hidden */
  57864. export var lensFlareVertexShader: {
  57865. name: string;
  57866. shader: string;
  57867. };
  57868. }
  57869. declare module BABYLON {
  57870. /**
  57871. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57872. * It is usually composed of several `lensFlare`.
  57873. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57874. */
  57875. export class LensFlareSystem {
  57876. /**
  57877. * Define the name of the lens flare system
  57878. */
  57879. name: string;
  57880. /**
  57881. * List of lens flares used in this system.
  57882. */
  57883. lensFlares: LensFlare[];
  57884. /**
  57885. * Define a limit from the border the lens flare can be visible.
  57886. */
  57887. borderLimit: number;
  57888. /**
  57889. * Define a viewport border we do not want to see the lens flare in.
  57890. */
  57891. viewportBorder: number;
  57892. /**
  57893. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57894. */
  57895. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57896. /**
  57897. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57898. */
  57899. layerMask: number;
  57900. /**
  57901. * Define the id of the lens flare system in the scene.
  57902. * (equal to name by default)
  57903. */
  57904. id: string;
  57905. private _scene;
  57906. private _emitter;
  57907. private _vertexBuffers;
  57908. private _indexBuffer;
  57909. private _effect;
  57910. private _positionX;
  57911. private _positionY;
  57912. private _isEnabled;
  57913. /** @hidden */
  57914. static _SceneComponentInitialization: (scene: Scene) => void;
  57915. /**
  57916. * Instantiates a lens flare system.
  57917. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57918. * It is usually composed of several `lensFlare`.
  57919. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57920. * @param name Define the name of the lens flare system in the scene
  57921. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57922. * @param scene Define the scene the lens flare system belongs to
  57923. */
  57924. constructor(
  57925. /**
  57926. * Define the name of the lens flare system
  57927. */
  57928. name: string, emitter: any, scene: Scene);
  57929. /**
  57930. * Define if the lens flare system is enabled.
  57931. */
  57932. get isEnabled(): boolean;
  57933. set isEnabled(value: boolean);
  57934. /**
  57935. * Get the scene the effects belongs to.
  57936. * @returns the scene holding the lens flare system
  57937. */
  57938. getScene(): Scene;
  57939. /**
  57940. * Get the emitter of the lens flare system.
  57941. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57942. * @returns the emitter of the lens flare system
  57943. */
  57944. getEmitter(): any;
  57945. /**
  57946. * Set the emitter of the lens flare system.
  57947. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57948. * @param newEmitter Define the new emitter of the system
  57949. */
  57950. setEmitter(newEmitter: any): void;
  57951. /**
  57952. * Get the lens flare system emitter position.
  57953. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57954. * @returns the position
  57955. */
  57956. getEmitterPosition(): Vector3;
  57957. /**
  57958. * @hidden
  57959. */
  57960. computeEffectivePosition(globalViewport: Viewport): boolean;
  57961. /** @hidden */
  57962. _isVisible(): boolean;
  57963. /**
  57964. * @hidden
  57965. */
  57966. render(): boolean;
  57967. /**
  57968. * Dispose and release the lens flare with its associated resources.
  57969. */
  57970. dispose(): void;
  57971. /**
  57972. * Parse a lens flare system from a JSON repressentation
  57973. * @param parsedLensFlareSystem Define the JSON to parse
  57974. * @param scene Define the scene the parsed system should be instantiated in
  57975. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57976. * @returns the parsed system
  57977. */
  57978. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57979. /**
  57980. * Serialize the current Lens Flare System into a JSON representation.
  57981. * @returns the serialized JSON
  57982. */
  57983. serialize(): any;
  57984. }
  57985. }
  57986. declare module BABYLON {
  57987. /**
  57988. * This represents one of the lens effect in a `lensFlareSystem`.
  57989. * It controls one of the indiviual texture used in the effect.
  57990. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57991. */
  57992. export class LensFlare {
  57993. /**
  57994. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57995. */
  57996. size: number;
  57997. /**
  57998. * 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.
  57999. */
  58000. position: number;
  58001. /**
  58002. * Define the lens color.
  58003. */
  58004. color: Color3;
  58005. /**
  58006. * Define the lens texture.
  58007. */
  58008. texture: Nullable<Texture>;
  58009. /**
  58010. * Define the alpha mode to render this particular lens.
  58011. */
  58012. alphaMode: number;
  58013. private _system;
  58014. /**
  58015. * Creates a new Lens Flare.
  58016. * This represents one of the lens effect in a `lensFlareSystem`.
  58017. * It controls one of the indiviual texture used in the effect.
  58018. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58019. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58020. * @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.
  58021. * @param color Define the lens color
  58022. * @param imgUrl Define the lens texture url
  58023. * @param system Define the `lensFlareSystem` this flare is part of
  58024. * @returns The newly created Lens Flare
  58025. */
  58026. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58027. /**
  58028. * Instantiates a new Lens Flare.
  58029. * This represents one of the lens effect in a `lensFlareSystem`.
  58030. * It controls one of the indiviual texture used in the effect.
  58031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58032. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58033. * @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.
  58034. * @param color Define the lens color
  58035. * @param imgUrl Define the lens texture url
  58036. * @param system Define the `lensFlareSystem` this flare is part of
  58037. */
  58038. constructor(
  58039. /**
  58040. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58041. */
  58042. size: number,
  58043. /**
  58044. * 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.
  58045. */
  58046. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58047. /**
  58048. * Dispose and release the lens flare with its associated resources.
  58049. */
  58050. dispose(): void;
  58051. }
  58052. }
  58053. declare module BABYLON {
  58054. interface AbstractScene {
  58055. /**
  58056. * The list of lens flare system added to the scene
  58057. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58058. */
  58059. lensFlareSystems: Array<LensFlareSystem>;
  58060. /**
  58061. * Removes the given lens flare system from this scene.
  58062. * @param toRemove The lens flare system to remove
  58063. * @returns The index of the removed lens flare system
  58064. */
  58065. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58066. /**
  58067. * Adds the given lens flare system to this scene
  58068. * @param newLensFlareSystem The lens flare system to add
  58069. */
  58070. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58071. /**
  58072. * Gets a lens flare system using its name
  58073. * @param name defines the name to look for
  58074. * @returns the lens flare system or null if not found
  58075. */
  58076. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58077. /**
  58078. * Gets a lens flare system using its id
  58079. * @param id defines the id to look for
  58080. * @returns the lens flare system or null if not found
  58081. */
  58082. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58083. }
  58084. /**
  58085. * Defines the lens flare scene component responsible to manage any lens flares
  58086. * in a given scene.
  58087. */
  58088. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58089. /**
  58090. * The component name helpfull to identify the component in the list of scene components.
  58091. */
  58092. readonly name: string;
  58093. /**
  58094. * The scene the component belongs to.
  58095. */
  58096. scene: Scene;
  58097. /**
  58098. * Creates a new instance of the component for the given scene
  58099. * @param scene Defines the scene to register the component in
  58100. */
  58101. constructor(scene: Scene);
  58102. /**
  58103. * Registers the component in a given scene
  58104. */
  58105. register(): void;
  58106. /**
  58107. * Rebuilds the elements related to this component in case of
  58108. * context lost for instance.
  58109. */
  58110. rebuild(): void;
  58111. /**
  58112. * Adds all the elements from the container to the scene
  58113. * @param container the container holding the elements
  58114. */
  58115. addFromContainer(container: AbstractScene): void;
  58116. /**
  58117. * Removes all the elements in the container from the scene
  58118. * @param container contains the elements to remove
  58119. * @param dispose if the removed element should be disposed (default: false)
  58120. */
  58121. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58122. /**
  58123. * Serializes the component data to the specified json object
  58124. * @param serializationObject The object to serialize to
  58125. */
  58126. serialize(serializationObject: any): void;
  58127. /**
  58128. * Disposes the component and the associated ressources.
  58129. */
  58130. dispose(): void;
  58131. private _draw;
  58132. }
  58133. }
  58134. declare module BABYLON {
  58135. /** @hidden */
  58136. export var depthPixelShader: {
  58137. name: string;
  58138. shader: string;
  58139. };
  58140. }
  58141. declare module BABYLON {
  58142. /** @hidden */
  58143. export var depthVertexShader: {
  58144. name: string;
  58145. shader: string;
  58146. };
  58147. }
  58148. declare module BABYLON {
  58149. /**
  58150. * This represents a depth renderer in Babylon.
  58151. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58152. */
  58153. export class DepthRenderer {
  58154. private _scene;
  58155. private _depthMap;
  58156. private _effect;
  58157. private readonly _storeNonLinearDepth;
  58158. private readonly _clearColor;
  58159. /** Get if the depth renderer is using packed depth or not */
  58160. readonly isPacked: boolean;
  58161. private _cachedDefines;
  58162. private _camera;
  58163. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58164. enabled: boolean;
  58165. /**
  58166. * Specifiess that the depth renderer will only be used within
  58167. * the camera it is created for.
  58168. * This can help forcing its rendering during the camera processing.
  58169. */
  58170. useOnlyInActiveCamera: boolean;
  58171. /** @hidden */
  58172. static _SceneComponentInitialization: (scene: Scene) => void;
  58173. /**
  58174. * Instantiates a depth renderer
  58175. * @param scene The scene the renderer belongs to
  58176. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58177. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58178. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58179. */
  58180. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58181. /**
  58182. * Creates the depth rendering effect and checks if the effect is ready.
  58183. * @param subMesh The submesh to be used to render the depth map of
  58184. * @param useInstances If multiple world instances should be used
  58185. * @returns if the depth renderer is ready to render the depth map
  58186. */
  58187. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58188. /**
  58189. * Gets the texture which the depth map will be written to.
  58190. * @returns The depth map texture
  58191. */
  58192. getDepthMap(): RenderTargetTexture;
  58193. /**
  58194. * Disposes of the depth renderer.
  58195. */
  58196. dispose(): void;
  58197. }
  58198. }
  58199. declare module BABYLON {
  58200. /** @hidden */
  58201. export var minmaxReduxPixelShader: {
  58202. name: string;
  58203. shader: string;
  58204. };
  58205. }
  58206. declare module BABYLON {
  58207. /**
  58208. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58209. * and maximum values from all values of the texture.
  58210. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58211. * The source values are read from the red channel of the texture.
  58212. */
  58213. export class MinMaxReducer {
  58214. /**
  58215. * Observable triggered when the computation has been performed
  58216. */
  58217. onAfterReductionPerformed: Observable<{
  58218. min: number;
  58219. max: number;
  58220. }>;
  58221. protected _camera: Camera;
  58222. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58223. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58224. protected _postProcessManager: PostProcessManager;
  58225. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58226. protected _forceFullscreenViewport: boolean;
  58227. /**
  58228. * Creates a min/max reducer
  58229. * @param camera The camera to use for the post processes
  58230. */
  58231. constructor(camera: Camera);
  58232. /**
  58233. * Gets the texture used to read the values from.
  58234. */
  58235. get sourceTexture(): Nullable<RenderTargetTexture>;
  58236. /**
  58237. * Sets the source texture to read the values from.
  58238. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58239. * because in such textures '1' value must not be taken into account to compute the maximum
  58240. * as this value is used to clear the texture.
  58241. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58242. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58243. * @param depthRedux Indicates if the texture is a depth texture or not
  58244. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58245. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58246. */
  58247. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58248. /**
  58249. * Defines the refresh rate of the computation.
  58250. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58251. */
  58252. get refreshRate(): number;
  58253. set refreshRate(value: number);
  58254. protected _activated: boolean;
  58255. /**
  58256. * Gets the activation status of the reducer
  58257. */
  58258. get activated(): boolean;
  58259. /**
  58260. * Activates the reduction computation.
  58261. * When activated, the observers registered in onAfterReductionPerformed are
  58262. * called after the compuation is performed
  58263. */
  58264. activate(): void;
  58265. /**
  58266. * Deactivates the reduction computation.
  58267. */
  58268. deactivate(): void;
  58269. /**
  58270. * Disposes the min/max reducer
  58271. * @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.
  58272. */
  58273. dispose(disposeAll?: boolean): void;
  58274. }
  58275. }
  58276. declare module BABYLON {
  58277. /**
  58278. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58279. */
  58280. export class DepthReducer extends MinMaxReducer {
  58281. private _depthRenderer;
  58282. private _depthRendererId;
  58283. /**
  58284. * Gets the depth renderer used for the computation.
  58285. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58286. */
  58287. get depthRenderer(): Nullable<DepthRenderer>;
  58288. /**
  58289. * Creates a depth reducer
  58290. * @param camera The camera used to render the depth texture
  58291. */
  58292. constructor(camera: Camera);
  58293. /**
  58294. * Sets the depth renderer to use to generate the depth map
  58295. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58296. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58297. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58298. */
  58299. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58300. /** @hidden */
  58301. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58302. /**
  58303. * Activates the reduction computation.
  58304. * When activated, the observers registered in onAfterReductionPerformed are
  58305. * called after the compuation is performed
  58306. */
  58307. activate(): void;
  58308. /**
  58309. * Deactivates the reduction computation.
  58310. */
  58311. deactivate(): void;
  58312. /**
  58313. * Disposes the depth reducer
  58314. * @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.
  58315. */
  58316. dispose(disposeAll?: boolean): void;
  58317. }
  58318. }
  58319. declare module BABYLON {
  58320. /**
  58321. * A CSM implementation allowing casting shadows on large scenes.
  58322. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58323. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58324. */
  58325. export class CascadedShadowGenerator extends ShadowGenerator {
  58326. private static readonly frustumCornersNDCSpace;
  58327. /**
  58328. * Name of the CSM class
  58329. */
  58330. static CLASSNAME: string;
  58331. /**
  58332. * Defines the default number of cascades used by the CSM.
  58333. */
  58334. static readonly DEFAULT_CASCADES_COUNT: number;
  58335. /**
  58336. * Defines the minimum number of cascades used by the CSM.
  58337. */
  58338. static readonly MIN_CASCADES_COUNT: number;
  58339. /**
  58340. * Defines the maximum number of cascades used by the CSM.
  58341. */
  58342. static readonly MAX_CASCADES_COUNT: number;
  58343. protected _validateFilter(filter: number): number;
  58344. /**
  58345. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58346. */
  58347. penumbraDarkness: number;
  58348. private _numCascades;
  58349. /**
  58350. * Gets or set the number of cascades used by the CSM.
  58351. */
  58352. get numCascades(): number;
  58353. set numCascades(value: number);
  58354. /**
  58355. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58356. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58357. */
  58358. stabilizeCascades: boolean;
  58359. private _freezeShadowCastersBoundingInfo;
  58360. private _freezeShadowCastersBoundingInfoObservable;
  58361. /**
  58362. * Enables or disables the shadow casters bounding info computation.
  58363. * If your shadow casters don't move, you can disable this feature.
  58364. * If it is enabled, the bounding box computation is done every frame.
  58365. */
  58366. get freezeShadowCastersBoundingInfo(): boolean;
  58367. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58368. private _scbiMin;
  58369. private _scbiMax;
  58370. protected _computeShadowCastersBoundingInfo(): void;
  58371. protected _shadowCastersBoundingInfo: BoundingInfo;
  58372. /**
  58373. * Gets or sets the shadow casters bounding info.
  58374. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58375. * so that the system won't overwrite the bounds you provide
  58376. */
  58377. get shadowCastersBoundingInfo(): BoundingInfo;
  58378. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58379. protected _breaksAreDirty: boolean;
  58380. protected _minDistance: number;
  58381. protected _maxDistance: number;
  58382. /**
  58383. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58384. *
  58385. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58386. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58387. * @param min minimal distance for the breaks (default to 0.)
  58388. * @param max maximal distance for the breaks (default to 1.)
  58389. */
  58390. setMinMaxDistance(min: number, max: number): void;
  58391. /** Gets the minimal distance used in the cascade break computation */
  58392. get minDistance(): number;
  58393. /** Gets the maximal distance used in the cascade break computation */
  58394. get maxDistance(): number;
  58395. /**
  58396. * Gets the class name of that object
  58397. * @returns "CascadedShadowGenerator"
  58398. */
  58399. getClassName(): string;
  58400. private _cascadeMinExtents;
  58401. private _cascadeMaxExtents;
  58402. /**
  58403. * Gets a cascade minimum extents
  58404. * @param cascadeIndex index of the cascade
  58405. * @returns the minimum cascade extents
  58406. */
  58407. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58408. /**
  58409. * Gets a cascade maximum extents
  58410. * @param cascadeIndex index of the cascade
  58411. * @returns the maximum cascade extents
  58412. */
  58413. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58414. private _cascades;
  58415. private _currentLayer;
  58416. private _viewSpaceFrustumsZ;
  58417. private _viewMatrices;
  58418. private _projectionMatrices;
  58419. private _transformMatrices;
  58420. private _transformMatricesAsArray;
  58421. private _frustumLengths;
  58422. private _lightSizeUVCorrection;
  58423. private _depthCorrection;
  58424. private _frustumCornersWorldSpace;
  58425. private _frustumCenter;
  58426. private _shadowCameraPos;
  58427. private _shadowMaxZ;
  58428. /**
  58429. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58430. * It defaults to camera.maxZ
  58431. */
  58432. get shadowMaxZ(): number;
  58433. /**
  58434. * Sets the shadow max z distance.
  58435. */
  58436. set shadowMaxZ(value: number);
  58437. protected _debug: boolean;
  58438. /**
  58439. * Gets or sets the debug flag.
  58440. * When enabled, the cascades are materialized by different colors on the screen.
  58441. */
  58442. get debug(): boolean;
  58443. set debug(dbg: boolean);
  58444. private _depthClamp;
  58445. /**
  58446. * Gets or sets the depth clamping value.
  58447. *
  58448. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58449. * to account for the shadow casters far away.
  58450. *
  58451. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58452. */
  58453. get depthClamp(): boolean;
  58454. set depthClamp(value: boolean);
  58455. private _cascadeBlendPercentage;
  58456. /**
  58457. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58458. * It defaults to 0.1 (10% blending).
  58459. */
  58460. get cascadeBlendPercentage(): number;
  58461. set cascadeBlendPercentage(value: number);
  58462. private _lambda;
  58463. /**
  58464. * Gets or set the lambda parameter.
  58465. * This parameter is used to split the camera frustum and create the cascades.
  58466. * 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.
  58467. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58468. */
  58469. get lambda(): number;
  58470. set lambda(value: number);
  58471. /**
  58472. * Gets the view matrix corresponding to a given cascade
  58473. * @param cascadeNum cascade to retrieve the view matrix from
  58474. * @returns the cascade view matrix
  58475. */
  58476. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58477. /**
  58478. * Gets the projection matrix corresponding to a given cascade
  58479. * @param cascadeNum cascade to retrieve the projection matrix from
  58480. * @returns the cascade projection matrix
  58481. */
  58482. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58483. /**
  58484. * Gets the transformation matrix corresponding to a given cascade
  58485. * @param cascadeNum cascade to retrieve the transformation matrix from
  58486. * @returns the cascade transformation matrix
  58487. */
  58488. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58489. private _depthRenderer;
  58490. /**
  58491. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58492. *
  58493. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58494. *
  58495. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58496. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58497. * @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
  58498. */
  58499. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58500. private _depthReducer;
  58501. private _autoCalcDepthBounds;
  58502. /**
  58503. * Gets or sets the autoCalcDepthBounds property.
  58504. *
  58505. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58506. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58507. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58508. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58509. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58510. */
  58511. get autoCalcDepthBounds(): boolean;
  58512. set autoCalcDepthBounds(value: boolean);
  58513. /**
  58514. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58515. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58516. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58517. * for setting the refresh rate on the renderer yourself!
  58518. */
  58519. get autoCalcDepthBoundsRefreshRate(): number;
  58520. set autoCalcDepthBoundsRefreshRate(value: number);
  58521. /**
  58522. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58523. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58524. * you change the camera near/far planes!
  58525. */
  58526. splitFrustum(): void;
  58527. private _splitFrustum;
  58528. private _computeMatrices;
  58529. private _computeFrustumInWorldSpace;
  58530. private _computeCascadeFrustum;
  58531. /**
  58532. * Support test.
  58533. */
  58534. static get IsSupported(): boolean;
  58535. /** @hidden */
  58536. static _SceneComponentInitialization: (scene: Scene) => void;
  58537. /**
  58538. * Creates a Cascaded Shadow Generator object.
  58539. * A ShadowGenerator is the required tool to use the shadows.
  58540. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58541. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58542. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58543. * @param light The directional light object generating the shadows.
  58544. * @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.
  58545. */
  58546. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58547. protected _initializeGenerator(): void;
  58548. protected _createTargetRenderTexture(): void;
  58549. protected _initializeShadowMap(): void;
  58550. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58551. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58552. /**
  58553. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58554. * @param defines Defines of the material we want to update
  58555. * @param lightIndex Index of the light in the enabled light list of the material
  58556. */
  58557. prepareDefines(defines: any, lightIndex: number): void;
  58558. /**
  58559. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58560. * defined in the generator but impacting the effect).
  58561. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58562. * @param effect The effect we are binfing the information for
  58563. */
  58564. bindShadowLight(lightIndex: string, effect: Effect): void;
  58565. /**
  58566. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58567. * (eq to view projection * shadow projection matrices)
  58568. * @returns The transform matrix used to create the shadow map
  58569. */
  58570. getTransformMatrix(): Matrix;
  58571. /**
  58572. * Disposes the ShadowGenerator.
  58573. * Returns nothing.
  58574. */
  58575. dispose(): void;
  58576. /**
  58577. * Serializes the shadow generator setup to a json object.
  58578. * @returns The serialized JSON object
  58579. */
  58580. serialize(): any;
  58581. /**
  58582. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58583. * @param parsedShadowGenerator The JSON object to parse
  58584. * @param scene The scene to create the shadow map for
  58585. * @returns The parsed shadow generator
  58586. */
  58587. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58588. }
  58589. }
  58590. declare module BABYLON {
  58591. /**
  58592. * Defines the shadow generator component responsible to manage any shadow generators
  58593. * in a given scene.
  58594. */
  58595. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58596. /**
  58597. * The component name helpfull to identify the component in the list of scene components.
  58598. */
  58599. readonly name: string;
  58600. /**
  58601. * The scene the component belongs to.
  58602. */
  58603. scene: Scene;
  58604. /**
  58605. * Creates a new instance of the component for the given scene
  58606. * @param scene Defines the scene to register the component in
  58607. */
  58608. constructor(scene: Scene);
  58609. /**
  58610. * Registers the component in a given scene
  58611. */
  58612. register(): void;
  58613. /**
  58614. * Rebuilds the elements related to this component in case of
  58615. * context lost for instance.
  58616. */
  58617. rebuild(): void;
  58618. /**
  58619. * Serializes the component data to the specified json object
  58620. * @param serializationObject The object to serialize to
  58621. */
  58622. serialize(serializationObject: any): void;
  58623. /**
  58624. * Adds all the elements from the container to the scene
  58625. * @param container the container holding the elements
  58626. */
  58627. addFromContainer(container: AbstractScene): void;
  58628. /**
  58629. * Removes all the elements in the container from the scene
  58630. * @param container contains the elements to remove
  58631. * @param dispose if the removed element should be disposed (default: false)
  58632. */
  58633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58634. /**
  58635. * Rebuilds the elements related to this component in case of
  58636. * context lost for instance.
  58637. */
  58638. dispose(): void;
  58639. private _gatherRenderTargets;
  58640. }
  58641. }
  58642. declare module BABYLON {
  58643. /**
  58644. * A point light is a light defined by an unique point in world space.
  58645. * The light is emitted in every direction from this point.
  58646. * A good example of a point light is a standard light bulb.
  58647. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58648. */
  58649. export class PointLight extends ShadowLight {
  58650. private _shadowAngle;
  58651. /**
  58652. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58653. * This specifies what angle the shadow will use to be created.
  58654. *
  58655. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58656. */
  58657. get shadowAngle(): number;
  58658. /**
  58659. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58660. * This specifies what angle the shadow will use to be created.
  58661. *
  58662. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58663. */
  58664. set shadowAngle(value: number);
  58665. /**
  58666. * Gets the direction if it has been set.
  58667. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58668. */
  58669. get direction(): Vector3;
  58670. /**
  58671. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58672. */
  58673. set direction(value: Vector3);
  58674. /**
  58675. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58676. * A PointLight emits the light in every direction.
  58677. * It can cast shadows.
  58678. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58679. * ```javascript
  58680. * var pointLight = new PointLight("pl", camera.position, scene);
  58681. * ```
  58682. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58683. * @param name The light friendly name
  58684. * @param position The position of the point light in the scene
  58685. * @param scene The scene the lights belongs to
  58686. */
  58687. constructor(name: string, position: Vector3, scene: Scene);
  58688. /**
  58689. * Returns the string "PointLight"
  58690. * @returns the class name
  58691. */
  58692. getClassName(): string;
  58693. /**
  58694. * Returns the integer 0.
  58695. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58696. */
  58697. getTypeID(): number;
  58698. /**
  58699. * Specifies wether or not the shadowmap should be a cube texture.
  58700. * @returns true if the shadowmap needs to be a cube texture.
  58701. */
  58702. needCube(): boolean;
  58703. /**
  58704. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58705. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58706. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58707. */
  58708. getShadowDirection(faceIndex?: number): Vector3;
  58709. /**
  58710. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58711. * - fov = PI / 2
  58712. * - aspect ratio : 1.0
  58713. * - z-near and far equal to the active camera minZ and maxZ.
  58714. * Returns the PointLight.
  58715. */
  58716. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58717. protected _buildUniformLayout(): void;
  58718. /**
  58719. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58720. * @param effect The effect to update
  58721. * @param lightIndex The index of the light in the effect to update
  58722. * @returns The point light
  58723. */
  58724. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58725. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58726. /**
  58727. * Prepares the list of defines specific to the light type.
  58728. * @param defines the list of defines
  58729. * @param lightIndex defines the index of the light for the effect
  58730. */
  58731. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58732. }
  58733. }
  58734. declare module BABYLON {
  58735. /**
  58736. * Header information of HDR texture files.
  58737. */
  58738. export interface HDRInfo {
  58739. /**
  58740. * The height of the texture in pixels.
  58741. */
  58742. height: number;
  58743. /**
  58744. * The width of the texture in pixels.
  58745. */
  58746. width: number;
  58747. /**
  58748. * The index of the beginning of the data in the binary file.
  58749. */
  58750. dataPosition: number;
  58751. }
  58752. /**
  58753. * This groups tools to convert HDR texture to native colors array.
  58754. */
  58755. export class HDRTools {
  58756. private static Ldexp;
  58757. private static Rgbe2float;
  58758. private static readStringLine;
  58759. /**
  58760. * Reads header information from an RGBE texture stored in a native array.
  58761. * More information on this format are available here:
  58762. * https://en.wikipedia.org/wiki/RGBE_image_format
  58763. *
  58764. * @param uint8array The binary file stored in native array.
  58765. * @return The header information.
  58766. */
  58767. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58768. /**
  58769. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58770. * This RGBE texture needs to store the information as a panorama.
  58771. *
  58772. * More information on this format are available here:
  58773. * https://en.wikipedia.org/wiki/RGBE_image_format
  58774. *
  58775. * @param buffer The binary file stored in an array buffer.
  58776. * @param size The expected size of the extracted cubemap.
  58777. * @return The Cube Map information.
  58778. */
  58779. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58780. /**
  58781. * Returns the pixels data extracted from an RGBE texture.
  58782. * This pixels will be stored left to right up to down in the R G B order in one array.
  58783. *
  58784. * More information on this format are available here:
  58785. * https://en.wikipedia.org/wiki/RGBE_image_format
  58786. *
  58787. * @param uint8array The binary file stored in an array buffer.
  58788. * @param hdrInfo The header information of the file.
  58789. * @return The pixels data in RGB right to left up to down order.
  58790. */
  58791. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58792. private static RGBE_ReadPixels_RLE;
  58793. }
  58794. }
  58795. declare module BABYLON {
  58796. /**
  58797. * Effect Render Options
  58798. */
  58799. export interface IEffectRendererOptions {
  58800. /**
  58801. * Defines the vertices positions.
  58802. */
  58803. positions?: number[];
  58804. /**
  58805. * Defines the indices.
  58806. */
  58807. indices?: number[];
  58808. }
  58809. /**
  58810. * Helper class to render one or more effects.
  58811. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58812. */
  58813. export class EffectRenderer {
  58814. private engine;
  58815. private static _DefaultOptions;
  58816. private _vertexBuffers;
  58817. private _indexBuffer;
  58818. private _fullscreenViewport;
  58819. /**
  58820. * Creates an effect renderer
  58821. * @param engine the engine to use for rendering
  58822. * @param options defines the options of the effect renderer
  58823. */
  58824. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58825. /**
  58826. * Sets the current viewport in normalized coordinates 0-1
  58827. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58828. */
  58829. setViewport(viewport?: Viewport): void;
  58830. /**
  58831. * Binds the embedded attributes buffer to the effect.
  58832. * @param effect Defines the effect to bind the attributes for
  58833. */
  58834. bindBuffers(effect: Effect): void;
  58835. /**
  58836. * Sets the current effect wrapper to use during draw.
  58837. * The effect needs to be ready before calling this api.
  58838. * This also sets the default full screen position attribute.
  58839. * @param effectWrapper Defines the effect to draw with
  58840. */
  58841. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58842. /**
  58843. * Restores engine states
  58844. */
  58845. restoreStates(): void;
  58846. /**
  58847. * Draws a full screen quad.
  58848. */
  58849. draw(): void;
  58850. private isRenderTargetTexture;
  58851. /**
  58852. * renders one or more effects to a specified texture
  58853. * @param effectWrapper the effect to renderer
  58854. * @param outputTexture texture to draw to, if null it will render to the screen.
  58855. */
  58856. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58857. /**
  58858. * Disposes of the effect renderer
  58859. */
  58860. dispose(): void;
  58861. }
  58862. /**
  58863. * Options to create an EffectWrapper
  58864. */
  58865. interface EffectWrapperCreationOptions {
  58866. /**
  58867. * Engine to use to create the effect
  58868. */
  58869. engine: ThinEngine;
  58870. /**
  58871. * Fragment shader for the effect
  58872. */
  58873. fragmentShader: string;
  58874. /**
  58875. * Use the shader store instead of direct source code
  58876. */
  58877. useShaderStore?: boolean;
  58878. /**
  58879. * Vertex shader for the effect
  58880. */
  58881. vertexShader?: string;
  58882. /**
  58883. * Attributes to use in the shader
  58884. */
  58885. attributeNames?: Array<string>;
  58886. /**
  58887. * Uniforms to use in the shader
  58888. */
  58889. uniformNames?: Array<string>;
  58890. /**
  58891. * Texture sampler names to use in the shader
  58892. */
  58893. samplerNames?: Array<string>;
  58894. /**
  58895. * Defines to use in the shader
  58896. */
  58897. defines?: Array<string>;
  58898. /**
  58899. * Callback when effect is compiled
  58900. */
  58901. onCompiled?: Nullable<(effect: Effect) => void>;
  58902. /**
  58903. * The friendly name of the effect displayed in Spector.
  58904. */
  58905. name?: string;
  58906. }
  58907. /**
  58908. * Wraps an effect to be used for rendering
  58909. */
  58910. export class EffectWrapper {
  58911. /**
  58912. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58913. */
  58914. onApplyObservable: Observable<{}>;
  58915. /**
  58916. * The underlying effect
  58917. */
  58918. effect: Effect;
  58919. /**
  58920. * Creates an effect to be renderer
  58921. * @param creationOptions options to create the effect
  58922. */
  58923. constructor(creationOptions: EffectWrapperCreationOptions);
  58924. /**
  58925. * Disposes of the effect wrapper
  58926. */
  58927. dispose(): void;
  58928. }
  58929. }
  58930. declare module BABYLON {
  58931. /** @hidden */
  58932. export var hdrFilteringVertexShader: {
  58933. name: string;
  58934. shader: string;
  58935. };
  58936. }
  58937. declare module BABYLON {
  58938. /** @hidden */
  58939. export var hdrFilteringPixelShader: {
  58940. name: string;
  58941. shader: string;
  58942. };
  58943. }
  58944. declare module BABYLON {
  58945. /**
  58946. * Options for texture filtering
  58947. */
  58948. interface IHDRFilteringOptions {
  58949. /**
  58950. * Scales pixel intensity for the input HDR map.
  58951. */
  58952. hdrScale?: number;
  58953. /**
  58954. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58955. */
  58956. quality?: number;
  58957. }
  58958. /**
  58959. * Filters HDR maps to get correct renderings of PBR reflections
  58960. */
  58961. export class HDRFiltering {
  58962. private _engine;
  58963. private _effectRenderer;
  58964. private _effectWrapper;
  58965. private _lodGenerationOffset;
  58966. private _lodGenerationScale;
  58967. /**
  58968. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58969. * you care about baking speed.
  58970. */
  58971. quality: number;
  58972. /**
  58973. * Scales pixel intensity for the input HDR map.
  58974. */
  58975. hdrScale: number;
  58976. /**
  58977. * Instantiates HDR filter for reflection maps
  58978. *
  58979. * @param engine Thin engine
  58980. * @param options Options
  58981. */
  58982. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58983. private _createRenderTarget;
  58984. private _prefilterInternal;
  58985. private _createEffect;
  58986. /**
  58987. * Get a value indicating if the filter is ready to be used
  58988. * @param texture Texture to filter
  58989. * @returns true if the filter is ready
  58990. */
  58991. isReady(texture: BaseTexture): boolean;
  58992. /**
  58993. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58994. * Prefiltering will be invoked at the end of next rendering pass.
  58995. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58996. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58997. * @param texture Texture to filter
  58998. * @param onFinished Callback when filtering is done
  58999. * @return Promise called when prefiltering is done
  59000. */
  59001. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59002. }
  59003. }
  59004. declare module BABYLON {
  59005. /**
  59006. * This represents a texture coming from an HDR input.
  59007. *
  59008. * The only supported format is currently panorama picture stored in RGBE format.
  59009. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59010. */
  59011. export class HDRCubeTexture extends BaseTexture {
  59012. private static _facesMapping;
  59013. private _generateHarmonics;
  59014. private _noMipmap;
  59015. private _prefilterOnLoad;
  59016. private _textureMatrix;
  59017. private _size;
  59018. private _onLoad;
  59019. private _onError;
  59020. /**
  59021. * The texture URL.
  59022. */
  59023. url: string;
  59024. /**
  59025. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59026. */
  59027. coordinatesMode: number;
  59028. protected _isBlocking: boolean;
  59029. /**
  59030. * Sets wether or not the texture is blocking during loading.
  59031. */
  59032. set isBlocking(value: boolean);
  59033. /**
  59034. * Gets wether or not the texture is blocking during loading.
  59035. */
  59036. get isBlocking(): boolean;
  59037. protected _rotationY: number;
  59038. /**
  59039. * Sets texture matrix rotation angle around Y axis in radians.
  59040. */
  59041. set rotationY(value: number);
  59042. /**
  59043. * Gets texture matrix rotation angle around Y axis radians.
  59044. */
  59045. get rotationY(): number;
  59046. /**
  59047. * Gets or sets the center of the bounding box associated with the cube texture
  59048. * It must define where the camera used to render the texture was set
  59049. */
  59050. boundingBoxPosition: Vector3;
  59051. private _boundingBoxSize;
  59052. /**
  59053. * Gets or sets the size of the bounding box associated with the cube texture
  59054. * When defined, the cubemap will switch to local mode
  59055. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59056. * @example https://www.babylonjs-playground.com/#RNASML
  59057. */
  59058. set boundingBoxSize(value: Vector3);
  59059. get boundingBoxSize(): Vector3;
  59060. /**
  59061. * Instantiates an HDRTexture from the following parameters.
  59062. *
  59063. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59064. * @param sceneOrEngine The scene or engine the texture will be used in
  59065. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59066. * @param noMipmap Forces to not generate the mipmap if true
  59067. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59068. * @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)
  59069. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59070. */
  59071. 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>);
  59072. /**
  59073. * Get the current class name of the texture useful for serialization or dynamic coding.
  59074. * @returns "HDRCubeTexture"
  59075. */
  59076. getClassName(): string;
  59077. /**
  59078. * Occurs when the file is raw .hdr file.
  59079. */
  59080. private loadTexture;
  59081. clone(): HDRCubeTexture;
  59082. delayLoad(): void;
  59083. /**
  59084. * Get the texture reflection matrix used to rotate/transform the reflection.
  59085. * @returns the reflection matrix
  59086. */
  59087. getReflectionTextureMatrix(): Matrix;
  59088. /**
  59089. * Set the texture reflection matrix used to rotate/transform the reflection.
  59090. * @param value Define the reflection matrix to set
  59091. */
  59092. setReflectionTextureMatrix(value: Matrix): void;
  59093. /**
  59094. * Parses a JSON representation of an HDR Texture in order to create the texture
  59095. * @param parsedTexture Define the JSON representation
  59096. * @param scene Define the scene the texture should be created in
  59097. * @param rootUrl Define the root url in case we need to load relative dependencies
  59098. * @returns the newly created texture after parsing
  59099. */
  59100. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59101. serialize(): any;
  59102. }
  59103. }
  59104. declare module BABYLON {
  59105. /**
  59106. * Class used to control physics engine
  59107. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59108. */
  59109. export class PhysicsEngine implements IPhysicsEngine {
  59110. private _physicsPlugin;
  59111. /**
  59112. * Global value used to control the smallest number supported by the simulation
  59113. */
  59114. static Epsilon: number;
  59115. private _impostors;
  59116. private _joints;
  59117. private _subTimeStep;
  59118. /**
  59119. * Gets the gravity vector used by the simulation
  59120. */
  59121. gravity: Vector3;
  59122. /**
  59123. * Factory used to create the default physics plugin.
  59124. * @returns The default physics plugin
  59125. */
  59126. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59127. /**
  59128. * Creates a new Physics Engine
  59129. * @param gravity defines the gravity vector used by the simulation
  59130. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59131. */
  59132. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59133. /**
  59134. * Sets the gravity vector used by the simulation
  59135. * @param gravity defines the gravity vector to use
  59136. */
  59137. setGravity(gravity: Vector3): void;
  59138. /**
  59139. * Set the time step of the physics engine.
  59140. * Default is 1/60.
  59141. * To slow it down, enter 1/600 for example.
  59142. * To speed it up, 1/30
  59143. * @param newTimeStep defines the new timestep to apply to this world.
  59144. */
  59145. setTimeStep(newTimeStep?: number): void;
  59146. /**
  59147. * Get the time step of the physics engine.
  59148. * @returns the current time step
  59149. */
  59150. getTimeStep(): number;
  59151. /**
  59152. * Set the sub time step of the physics engine.
  59153. * Default is 0 meaning there is no sub steps
  59154. * To increase physics resolution precision, set a small value (like 1 ms)
  59155. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59156. */
  59157. setSubTimeStep(subTimeStep?: number): void;
  59158. /**
  59159. * Get the sub time step of the physics engine.
  59160. * @returns the current sub time step
  59161. */
  59162. getSubTimeStep(): number;
  59163. /**
  59164. * Release all resources
  59165. */
  59166. dispose(): void;
  59167. /**
  59168. * Gets the name of the current physics plugin
  59169. * @returns the name of the plugin
  59170. */
  59171. getPhysicsPluginName(): string;
  59172. /**
  59173. * Adding a new impostor for the impostor tracking.
  59174. * This will be done by the impostor itself.
  59175. * @param impostor the impostor to add
  59176. */
  59177. addImpostor(impostor: PhysicsImpostor): void;
  59178. /**
  59179. * Remove an impostor from the engine.
  59180. * This impostor and its mesh will not longer be updated by the physics engine.
  59181. * @param impostor the impostor to remove
  59182. */
  59183. removeImpostor(impostor: PhysicsImpostor): void;
  59184. /**
  59185. * Add a joint to the physics engine
  59186. * @param mainImpostor defines the main impostor to which the joint is added.
  59187. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59188. * @param joint defines the joint that will connect both impostors.
  59189. */
  59190. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59191. /**
  59192. * Removes a joint from the simulation
  59193. * @param mainImpostor defines the impostor used with the joint
  59194. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59195. * @param joint defines the joint to remove
  59196. */
  59197. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59198. /**
  59199. * Called by the scene. No need to call it.
  59200. * @param delta defines the timespam between frames
  59201. */
  59202. _step(delta: number): void;
  59203. /**
  59204. * Gets the current plugin used to run the simulation
  59205. * @returns current plugin
  59206. */
  59207. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59208. /**
  59209. * Gets the list of physic impostors
  59210. * @returns an array of PhysicsImpostor
  59211. */
  59212. getImpostors(): Array<PhysicsImpostor>;
  59213. /**
  59214. * Gets the impostor for a physics enabled object
  59215. * @param object defines the object impersonated by the impostor
  59216. * @returns the PhysicsImpostor or null if not found
  59217. */
  59218. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59219. /**
  59220. * Gets the impostor for a physics body object
  59221. * @param body defines physics body used by the impostor
  59222. * @returns the PhysicsImpostor or null if not found
  59223. */
  59224. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59225. /**
  59226. * Does a raycast in the physics world
  59227. * @param from when should the ray start?
  59228. * @param to when should the ray end?
  59229. * @returns PhysicsRaycastResult
  59230. */
  59231. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59232. }
  59233. }
  59234. declare module BABYLON {
  59235. /** @hidden */
  59236. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59237. private _useDeltaForWorldStep;
  59238. world: any;
  59239. name: string;
  59240. private _physicsMaterials;
  59241. private _fixedTimeStep;
  59242. private _cannonRaycastResult;
  59243. private _raycastResult;
  59244. private _physicsBodysToRemoveAfterStep;
  59245. private _firstFrame;
  59246. BJSCANNON: any;
  59247. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59248. setGravity(gravity: Vector3): void;
  59249. setTimeStep(timeStep: number): void;
  59250. getTimeStep(): number;
  59251. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59252. private _removeMarkedPhysicsBodiesFromWorld;
  59253. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59254. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59255. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59256. private _processChildMeshes;
  59257. removePhysicsBody(impostor: PhysicsImpostor): void;
  59258. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59259. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59260. private _addMaterial;
  59261. private _checkWithEpsilon;
  59262. private _createShape;
  59263. private _createHeightmap;
  59264. private _minus90X;
  59265. private _plus90X;
  59266. private _tmpPosition;
  59267. private _tmpDeltaPosition;
  59268. private _tmpUnityRotation;
  59269. private _updatePhysicsBodyTransformation;
  59270. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59271. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59272. isSupported(): boolean;
  59273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59278. getBodyMass(impostor: PhysicsImpostor): number;
  59279. getBodyFriction(impostor: PhysicsImpostor): number;
  59280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59281. getBodyRestitution(impostor: PhysicsImpostor): number;
  59282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59283. sleepBody(impostor: PhysicsImpostor): void;
  59284. wakeUpBody(impostor: PhysicsImpostor): void;
  59285. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59286. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59287. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59288. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59289. getRadius(impostor: PhysicsImpostor): number;
  59290. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59291. dispose(): void;
  59292. private _extendNamespace;
  59293. /**
  59294. * Does a raycast in the physics world
  59295. * @param from when should the ray start?
  59296. * @param to when should the ray end?
  59297. * @returns PhysicsRaycastResult
  59298. */
  59299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59300. }
  59301. }
  59302. declare module BABYLON {
  59303. /** @hidden */
  59304. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59305. private _useDeltaForWorldStep;
  59306. world: any;
  59307. name: string;
  59308. BJSOIMO: any;
  59309. private _raycastResult;
  59310. private _fixedTimeStep;
  59311. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59312. setGravity(gravity: Vector3): void;
  59313. setTimeStep(timeStep: number): void;
  59314. getTimeStep(): number;
  59315. private _tmpImpostorsArray;
  59316. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59317. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59318. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59319. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59320. private _tmpPositionVector;
  59321. removePhysicsBody(impostor: PhysicsImpostor): void;
  59322. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59323. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59324. isSupported(): boolean;
  59325. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59326. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59327. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59328. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59329. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59330. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59331. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59332. getBodyMass(impostor: PhysicsImpostor): number;
  59333. getBodyFriction(impostor: PhysicsImpostor): number;
  59334. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59335. getBodyRestitution(impostor: PhysicsImpostor): number;
  59336. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59337. sleepBody(impostor: PhysicsImpostor): void;
  59338. wakeUpBody(impostor: PhysicsImpostor): void;
  59339. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59340. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59341. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59342. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59343. getRadius(impostor: PhysicsImpostor): number;
  59344. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59345. dispose(): void;
  59346. /**
  59347. * Does a raycast in the physics world
  59348. * @param from when should the ray start?
  59349. * @param to when should the ray end?
  59350. * @returns PhysicsRaycastResult
  59351. */
  59352. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59353. }
  59354. }
  59355. declare module BABYLON {
  59356. /**
  59357. * Class containing static functions to help procedurally build meshes
  59358. */
  59359. export class RibbonBuilder {
  59360. /**
  59361. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59362. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59363. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59364. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59365. * * 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
  59366. * * 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
  59367. * * 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
  59368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59369. * * 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
  59370. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59371. * * 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
  59372. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59373. * * 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
  59374. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59376. * @param name defines the name of the mesh
  59377. * @param options defines the options used to create the mesh
  59378. * @param scene defines the hosting scene
  59379. * @returns the ribbon mesh
  59380. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59381. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59382. */
  59383. static CreateRibbon(name: string, options: {
  59384. pathArray: Vector3[][];
  59385. closeArray?: boolean;
  59386. closePath?: boolean;
  59387. offset?: number;
  59388. updatable?: boolean;
  59389. sideOrientation?: number;
  59390. frontUVs?: Vector4;
  59391. backUVs?: Vector4;
  59392. instance?: Mesh;
  59393. invertUV?: boolean;
  59394. uvs?: Vector2[];
  59395. colors?: Color4[];
  59396. }, scene?: Nullable<Scene>): Mesh;
  59397. }
  59398. }
  59399. declare module BABYLON {
  59400. /**
  59401. * Class containing static functions to help procedurally build meshes
  59402. */
  59403. export class ShapeBuilder {
  59404. /**
  59405. * 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.
  59406. * * 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.
  59407. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59408. * * 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.
  59409. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59410. * * 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
  59411. * * 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
  59412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59414. * * 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
  59415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59417. * @param name defines the name of the mesh
  59418. * @param options defines the options used to create the mesh
  59419. * @param scene defines the hosting scene
  59420. * @returns the extruded shape mesh
  59421. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59423. */
  59424. static ExtrudeShape(name: string, options: {
  59425. shape: Vector3[];
  59426. path: Vector3[];
  59427. scale?: number;
  59428. rotation?: number;
  59429. cap?: number;
  59430. updatable?: boolean;
  59431. sideOrientation?: number;
  59432. frontUVs?: Vector4;
  59433. backUVs?: Vector4;
  59434. instance?: Mesh;
  59435. invertUV?: boolean;
  59436. }, scene?: Nullable<Scene>): Mesh;
  59437. /**
  59438. * Creates an custom extruded shape mesh.
  59439. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59440. * * 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.
  59441. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59442. * * 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
  59443. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59444. * * 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
  59445. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59446. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59447. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59448. * * 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
  59449. * * 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
  59450. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59452. * * 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
  59453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59455. * @param name defines the name of the mesh
  59456. * @param options defines the options used to create the mesh
  59457. * @param scene defines the hosting scene
  59458. * @returns the custom extruded shape mesh
  59459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59460. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59462. */
  59463. static ExtrudeShapeCustom(name: string, options: {
  59464. shape: Vector3[];
  59465. path: Vector3[];
  59466. scaleFunction?: any;
  59467. rotationFunction?: any;
  59468. ribbonCloseArray?: boolean;
  59469. ribbonClosePath?: boolean;
  59470. cap?: number;
  59471. updatable?: boolean;
  59472. sideOrientation?: number;
  59473. frontUVs?: Vector4;
  59474. backUVs?: Vector4;
  59475. instance?: Mesh;
  59476. invertUV?: boolean;
  59477. }, scene?: Nullable<Scene>): Mesh;
  59478. private static _ExtrudeShapeGeneric;
  59479. }
  59480. }
  59481. declare module BABYLON {
  59482. /**
  59483. * AmmoJS Physics plugin
  59484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59485. * @see https://github.com/kripken/ammo.js/
  59486. */
  59487. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59488. private _useDeltaForWorldStep;
  59489. /**
  59490. * Reference to the Ammo library
  59491. */
  59492. bjsAMMO: any;
  59493. /**
  59494. * Created ammoJS world which physics bodies are added to
  59495. */
  59496. world: any;
  59497. /**
  59498. * Name of the plugin
  59499. */
  59500. name: string;
  59501. private _timeStep;
  59502. private _fixedTimeStep;
  59503. private _maxSteps;
  59504. private _tmpQuaternion;
  59505. private _tmpAmmoTransform;
  59506. private _tmpAmmoQuaternion;
  59507. private _tmpAmmoConcreteContactResultCallback;
  59508. private _collisionConfiguration;
  59509. private _dispatcher;
  59510. private _overlappingPairCache;
  59511. private _solver;
  59512. private _softBodySolver;
  59513. private _tmpAmmoVectorA;
  59514. private _tmpAmmoVectorB;
  59515. private _tmpAmmoVectorC;
  59516. private _tmpAmmoVectorD;
  59517. private _tmpContactCallbackResult;
  59518. private _tmpAmmoVectorRCA;
  59519. private _tmpAmmoVectorRCB;
  59520. private _raycastResult;
  59521. private static readonly DISABLE_COLLISION_FLAG;
  59522. private static readonly KINEMATIC_FLAG;
  59523. private static readonly DISABLE_DEACTIVATION_FLAG;
  59524. /**
  59525. * Initializes the ammoJS plugin
  59526. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59527. * @param ammoInjection can be used to inject your own ammo reference
  59528. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59529. */
  59530. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59531. /**
  59532. * Sets the gravity of the physics world (m/(s^2))
  59533. * @param gravity Gravity to set
  59534. */
  59535. setGravity(gravity: Vector3): void;
  59536. /**
  59537. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59538. * @param timeStep timestep to use in seconds
  59539. */
  59540. setTimeStep(timeStep: number): void;
  59541. /**
  59542. * 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)
  59543. * @param fixedTimeStep fixedTimeStep to use in seconds
  59544. */
  59545. setFixedTimeStep(fixedTimeStep: number): void;
  59546. /**
  59547. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59548. * @param maxSteps the maximum number of steps by the physics engine per frame
  59549. */
  59550. setMaxSteps(maxSteps: number): void;
  59551. /**
  59552. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59553. * @returns the current timestep in seconds
  59554. */
  59555. getTimeStep(): number;
  59556. /**
  59557. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59558. */
  59559. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59560. private _isImpostorInContact;
  59561. private _isImpostorPairInContact;
  59562. private _stepSimulation;
  59563. /**
  59564. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59565. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59566. * After the step the babylon meshes are set to the position of the physics imposters
  59567. * @param delta amount of time to step forward
  59568. * @param impostors array of imposters to update before/after the step
  59569. */
  59570. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59571. /**
  59572. * Update babylon mesh to match physics world object
  59573. * @param impostor imposter to match
  59574. */
  59575. private _afterSoftStep;
  59576. /**
  59577. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59578. * @param impostor imposter to match
  59579. */
  59580. private _ropeStep;
  59581. /**
  59582. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59583. * @param impostor imposter to match
  59584. */
  59585. private _softbodyOrClothStep;
  59586. private _tmpMatrix;
  59587. /**
  59588. * Applies an impulse on the imposter
  59589. * @param impostor imposter to apply impulse to
  59590. * @param force amount of force to be applied to the imposter
  59591. * @param contactPoint the location to apply the impulse on the imposter
  59592. */
  59593. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59594. /**
  59595. * Applies a force on the imposter
  59596. * @param impostor imposter to apply force
  59597. * @param force amount of force to be applied to the imposter
  59598. * @param contactPoint the location to apply the force on the imposter
  59599. */
  59600. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59601. /**
  59602. * Creates a physics body using the plugin
  59603. * @param impostor the imposter to create the physics body on
  59604. */
  59605. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59606. /**
  59607. * Removes the physics body from the imposter and disposes of the body's memory
  59608. * @param impostor imposter to remove the physics body from
  59609. */
  59610. removePhysicsBody(impostor: PhysicsImpostor): void;
  59611. /**
  59612. * Generates a joint
  59613. * @param impostorJoint the imposter joint to create the joint with
  59614. */
  59615. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59616. /**
  59617. * Removes a joint
  59618. * @param impostorJoint the imposter joint to remove the joint from
  59619. */
  59620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59621. private _addMeshVerts;
  59622. /**
  59623. * Initialise the soft body vertices to match its object's (mesh) vertices
  59624. * Softbody vertices (nodes) are in world space and to match this
  59625. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59626. * @param impostor to create the softbody for
  59627. */
  59628. private _softVertexData;
  59629. /**
  59630. * Create an impostor's soft body
  59631. * @param impostor to create the softbody for
  59632. */
  59633. private _createSoftbody;
  59634. /**
  59635. * Create cloth for an impostor
  59636. * @param impostor to create the softbody for
  59637. */
  59638. private _createCloth;
  59639. /**
  59640. * Create rope for an impostor
  59641. * @param impostor to create the softbody for
  59642. */
  59643. private _createRope;
  59644. /**
  59645. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59646. * @param impostor to create the custom physics shape for
  59647. */
  59648. private _createCustom;
  59649. private _addHullVerts;
  59650. private _createShape;
  59651. /**
  59652. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59653. * @param impostor imposter containing the physics body and babylon object
  59654. */
  59655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59656. /**
  59657. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59658. * @param impostor imposter containing the physics body and babylon object
  59659. * @param newPosition new position
  59660. * @param newRotation new rotation
  59661. */
  59662. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59663. /**
  59664. * If this plugin is supported
  59665. * @returns true if its supported
  59666. */
  59667. isSupported(): boolean;
  59668. /**
  59669. * Sets the linear velocity of the physics body
  59670. * @param impostor imposter to set the velocity on
  59671. * @param velocity velocity to set
  59672. */
  59673. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59674. /**
  59675. * Sets the angular velocity of the physics body
  59676. * @param impostor imposter to set the velocity on
  59677. * @param velocity velocity to set
  59678. */
  59679. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59680. /**
  59681. * gets the linear velocity
  59682. * @param impostor imposter to get linear velocity from
  59683. * @returns linear velocity
  59684. */
  59685. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59686. /**
  59687. * gets the angular velocity
  59688. * @param impostor imposter to get angular velocity from
  59689. * @returns angular velocity
  59690. */
  59691. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59692. /**
  59693. * Sets the mass of physics body
  59694. * @param impostor imposter to set the mass on
  59695. * @param mass mass to set
  59696. */
  59697. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59698. /**
  59699. * Gets the mass of the physics body
  59700. * @param impostor imposter to get the mass from
  59701. * @returns mass
  59702. */
  59703. getBodyMass(impostor: PhysicsImpostor): number;
  59704. /**
  59705. * Gets friction of the impostor
  59706. * @param impostor impostor to get friction from
  59707. * @returns friction value
  59708. */
  59709. getBodyFriction(impostor: PhysicsImpostor): number;
  59710. /**
  59711. * Sets friction of the impostor
  59712. * @param impostor impostor to set friction on
  59713. * @param friction friction value
  59714. */
  59715. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59716. /**
  59717. * Gets restitution of the impostor
  59718. * @param impostor impostor to get restitution from
  59719. * @returns restitution value
  59720. */
  59721. getBodyRestitution(impostor: PhysicsImpostor): number;
  59722. /**
  59723. * Sets resitution of the impostor
  59724. * @param impostor impostor to set resitution on
  59725. * @param restitution resitution value
  59726. */
  59727. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59728. /**
  59729. * Gets pressure inside the impostor
  59730. * @param impostor impostor to get pressure from
  59731. * @returns pressure value
  59732. */
  59733. getBodyPressure(impostor: PhysicsImpostor): number;
  59734. /**
  59735. * Sets pressure inside a soft body impostor
  59736. * Cloth and rope must remain 0 pressure
  59737. * @param impostor impostor to set pressure on
  59738. * @param pressure pressure value
  59739. */
  59740. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59741. /**
  59742. * Gets stiffness of the impostor
  59743. * @param impostor impostor to get stiffness from
  59744. * @returns pressure value
  59745. */
  59746. getBodyStiffness(impostor: PhysicsImpostor): number;
  59747. /**
  59748. * Sets stiffness of the impostor
  59749. * @param impostor impostor to set stiffness on
  59750. * @param stiffness stiffness value from 0 to 1
  59751. */
  59752. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59753. /**
  59754. * Gets velocityIterations of the impostor
  59755. * @param impostor impostor to get velocity iterations from
  59756. * @returns velocityIterations value
  59757. */
  59758. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59759. /**
  59760. * Sets velocityIterations of the impostor
  59761. * @param impostor impostor to set velocity iterations on
  59762. * @param velocityIterations velocityIterations value
  59763. */
  59764. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59765. /**
  59766. * Gets positionIterations of the impostor
  59767. * @param impostor impostor to get position iterations from
  59768. * @returns positionIterations value
  59769. */
  59770. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59771. /**
  59772. * Sets positionIterations of the impostor
  59773. * @param impostor impostor to set position on
  59774. * @param positionIterations positionIterations value
  59775. */
  59776. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59777. /**
  59778. * Append an anchor to a cloth object
  59779. * @param impostor is the cloth impostor to add anchor to
  59780. * @param otherImpostor is the rigid impostor to anchor to
  59781. * @param width ratio across width from 0 to 1
  59782. * @param height ratio up height from 0 to 1
  59783. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59784. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59785. */
  59786. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59787. /**
  59788. * Append an hook to a rope object
  59789. * @param impostor is the rope impostor to add hook to
  59790. * @param otherImpostor is the rigid impostor to hook to
  59791. * @param length ratio along the rope from 0 to 1
  59792. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59793. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59794. */
  59795. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59796. /**
  59797. * Sleeps the physics body and stops it from being active
  59798. * @param impostor impostor to sleep
  59799. */
  59800. sleepBody(impostor: PhysicsImpostor): void;
  59801. /**
  59802. * Activates the physics body
  59803. * @param impostor impostor to activate
  59804. */
  59805. wakeUpBody(impostor: PhysicsImpostor): void;
  59806. /**
  59807. * Updates the distance parameters of the joint
  59808. * @param joint joint to update
  59809. * @param maxDistance maximum distance of the joint
  59810. * @param minDistance minimum distance of the joint
  59811. */
  59812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59813. /**
  59814. * Sets a motor on the joint
  59815. * @param joint joint to set motor on
  59816. * @param speed speed of the motor
  59817. * @param maxForce maximum force of the motor
  59818. * @param motorIndex index of the motor
  59819. */
  59820. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59821. /**
  59822. * Sets the motors limit
  59823. * @param joint joint to set limit on
  59824. * @param upperLimit upper limit
  59825. * @param lowerLimit lower limit
  59826. */
  59827. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59828. /**
  59829. * Syncs the position and rotation of a mesh with the impostor
  59830. * @param mesh mesh to sync
  59831. * @param impostor impostor to update the mesh with
  59832. */
  59833. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59834. /**
  59835. * Gets the radius of the impostor
  59836. * @param impostor impostor to get radius from
  59837. * @returns the radius
  59838. */
  59839. getRadius(impostor: PhysicsImpostor): number;
  59840. /**
  59841. * Gets the box size of the impostor
  59842. * @param impostor impostor to get box size from
  59843. * @param result the resulting box size
  59844. */
  59845. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59846. /**
  59847. * Disposes of the impostor
  59848. */
  59849. dispose(): void;
  59850. /**
  59851. * Does a raycast in the physics world
  59852. * @param from when should the ray start?
  59853. * @param to when should the ray end?
  59854. * @returns PhysicsRaycastResult
  59855. */
  59856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59857. }
  59858. }
  59859. declare module BABYLON {
  59860. interface AbstractScene {
  59861. /**
  59862. * The list of reflection probes added to the scene
  59863. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59864. */
  59865. reflectionProbes: Array<ReflectionProbe>;
  59866. /**
  59867. * Removes the given reflection probe from this scene.
  59868. * @param toRemove The reflection probe to remove
  59869. * @returns The index of the removed reflection probe
  59870. */
  59871. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59872. /**
  59873. * Adds the given reflection probe to this scene.
  59874. * @param newReflectionProbe The reflection probe to add
  59875. */
  59876. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59877. }
  59878. /**
  59879. * Class used to generate realtime reflection / refraction cube textures
  59880. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59881. */
  59882. export class ReflectionProbe {
  59883. /** defines the name of the probe */
  59884. name: string;
  59885. private _scene;
  59886. private _renderTargetTexture;
  59887. private _projectionMatrix;
  59888. private _viewMatrix;
  59889. private _target;
  59890. private _add;
  59891. private _attachedMesh;
  59892. private _invertYAxis;
  59893. /** Gets or sets probe position (center of the cube map) */
  59894. position: Vector3;
  59895. /**
  59896. * Creates a new reflection probe
  59897. * @param name defines the name of the probe
  59898. * @param size defines the texture resolution (for each face)
  59899. * @param scene defines the hosting scene
  59900. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59901. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59902. */
  59903. constructor(
  59904. /** defines the name of the probe */
  59905. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59906. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59907. get samples(): number;
  59908. set samples(value: number);
  59909. /** Gets or sets the refresh rate to use (on every frame by default) */
  59910. get refreshRate(): number;
  59911. set refreshRate(value: number);
  59912. /**
  59913. * Gets the hosting scene
  59914. * @returns a Scene
  59915. */
  59916. getScene(): Scene;
  59917. /** Gets the internal CubeTexture used to render to */
  59918. get cubeTexture(): RenderTargetTexture;
  59919. /** Gets the list of meshes to render */
  59920. get renderList(): Nullable<AbstractMesh[]>;
  59921. /**
  59922. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59923. * @param mesh defines the mesh to attach to
  59924. */
  59925. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59926. /**
  59927. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59928. * @param renderingGroupId The rendering group id corresponding to its index
  59929. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59930. */
  59931. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59932. /**
  59933. * Clean all associated resources
  59934. */
  59935. dispose(): void;
  59936. /**
  59937. * Converts the reflection probe information to a readable string for debug purpose.
  59938. * @param fullDetails Supports for multiple levels of logging within scene loading
  59939. * @returns the human readable reflection probe info
  59940. */
  59941. toString(fullDetails?: boolean): string;
  59942. /**
  59943. * Get the class name of the relfection probe.
  59944. * @returns "ReflectionProbe"
  59945. */
  59946. getClassName(): string;
  59947. /**
  59948. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59949. * @returns The JSON representation of the texture
  59950. */
  59951. serialize(): any;
  59952. /**
  59953. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59954. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59955. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59956. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59957. * @returns The parsed reflection probe if successful
  59958. */
  59959. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59960. }
  59961. }
  59962. declare module BABYLON {
  59963. /** @hidden */
  59964. export var _BabylonLoaderRegistered: boolean;
  59965. /**
  59966. * Helps setting up some configuration for the babylon file loader.
  59967. */
  59968. export class BabylonFileLoaderConfiguration {
  59969. /**
  59970. * The loader does not allow injecting custom physix engine into the plugins.
  59971. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59972. * So you could set this variable to your engine import to make it work.
  59973. */
  59974. static LoaderInjectedPhysicsEngine: any;
  59975. }
  59976. }
  59977. declare module BABYLON {
  59978. /**
  59979. * The Physically based simple base material of BJS.
  59980. *
  59981. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59982. * It is used as the base class for both the specGloss and metalRough conventions.
  59983. */
  59984. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59985. /**
  59986. * Number of Simultaneous lights allowed on the material.
  59987. */
  59988. maxSimultaneousLights: number;
  59989. /**
  59990. * If sets to true, disables all the lights affecting the material.
  59991. */
  59992. disableLighting: boolean;
  59993. /**
  59994. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59995. */
  59996. environmentTexture: BaseTexture;
  59997. /**
  59998. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59999. */
  60000. invertNormalMapX: boolean;
  60001. /**
  60002. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60003. */
  60004. invertNormalMapY: boolean;
  60005. /**
  60006. * Normal map used in the model.
  60007. */
  60008. normalTexture: BaseTexture;
  60009. /**
  60010. * Emissivie color used to self-illuminate the model.
  60011. */
  60012. emissiveColor: Color3;
  60013. /**
  60014. * Emissivie texture used to self-illuminate the model.
  60015. */
  60016. emissiveTexture: BaseTexture;
  60017. /**
  60018. * Occlusion Channel Strenght.
  60019. */
  60020. occlusionStrength: number;
  60021. /**
  60022. * Occlusion Texture of the material (adding extra occlusion effects).
  60023. */
  60024. occlusionTexture: BaseTexture;
  60025. /**
  60026. * Defines the alpha limits in alpha test mode.
  60027. */
  60028. alphaCutOff: number;
  60029. /**
  60030. * Gets the current double sided mode.
  60031. */
  60032. get doubleSided(): boolean;
  60033. /**
  60034. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60035. */
  60036. set doubleSided(value: boolean);
  60037. /**
  60038. * Stores the pre-calculated light information of a mesh in a texture.
  60039. */
  60040. lightmapTexture: BaseTexture;
  60041. /**
  60042. * If true, the light map contains occlusion information instead of lighting info.
  60043. */
  60044. useLightmapAsShadowmap: boolean;
  60045. /**
  60046. * Instantiates a new PBRMaterial instance.
  60047. *
  60048. * @param name The material name
  60049. * @param scene The scene the material will be use in.
  60050. */
  60051. constructor(name: string, scene: Scene);
  60052. getClassName(): string;
  60053. }
  60054. }
  60055. declare module BABYLON {
  60056. /**
  60057. * The PBR material of BJS following the metal roughness convention.
  60058. *
  60059. * This fits to the PBR convention in the GLTF definition:
  60060. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60061. */
  60062. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60063. /**
  60064. * The base color has two different interpretations depending on the value of metalness.
  60065. * When the material is a metal, the base color is the specific measured reflectance value
  60066. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60067. * of the material.
  60068. */
  60069. baseColor: Color3;
  60070. /**
  60071. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60072. * well as opacity information in the alpha channel.
  60073. */
  60074. baseTexture: BaseTexture;
  60075. /**
  60076. * Specifies the metallic scalar value of the material.
  60077. * Can also be used to scale the metalness values of the metallic texture.
  60078. */
  60079. metallic: number;
  60080. /**
  60081. * Specifies the roughness scalar value of the material.
  60082. * Can also be used to scale the roughness values of the metallic texture.
  60083. */
  60084. roughness: number;
  60085. /**
  60086. * Texture containing both the metallic value in the B channel and the
  60087. * roughness value in the G channel to keep better precision.
  60088. */
  60089. metallicRoughnessTexture: BaseTexture;
  60090. /**
  60091. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60092. *
  60093. * @param name The material name
  60094. * @param scene The scene the material will be use in.
  60095. */
  60096. constructor(name: string, scene: Scene);
  60097. /**
  60098. * Return the currrent class name of the material.
  60099. */
  60100. getClassName(): string;
  60101. /**
  60102. * Makes a duplicate of the current material.
  60103. * @param name - name to use for the new material.
  60104. */
  60105. clone(name: string): PBRMetallicRoughnessMaterial;
  60106. /**
  60107. * Serialize the material to a parsable JSON object.
  60108. */
  60109. serialize(): any;
  60110. /**
  60111. * Parses a JSON object correponding to the serialize function.
  60112. */
  60113. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60114. }
  60115. }
  60116. declare module BABYLON {
  60117. /**
  60118. * The PBR material of BJS following the specular glossiness convention.
  60119. *
  60120. * This fits to the PBR convention in the GLTF definition:
  60121. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60122. */
  60123. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60124. /**
  60125. * Specifies the diffuse color of the material.
  60126. */
  60127. diffuseColor: Color3;
  60128. /**
  60129. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60130. * channel.
  60131. */
  60132. diffuseTexture: BaseTexture;
  60133. /**
  60134. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60135. */
  60136. specularColor: Color3;
  60137. /**
  60138. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60139. */
  60140. glossiness: number;
  60141. /**
  60142. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60143. */
  60144. specularGlossinessTexture: BaseTexture;
  60145. /**
  60146. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60147. *
  60148. * @param name The material name
  60149. * @param scene The scene the material will be use in.
  60150. */
  60151. constructor(name: string, scene: Scene);
  60152. /**
  60153. * Return the currrent class name of the material.
  60154. */
  60155. getClassName(): string;
  60156. /**
  60157. * Makes a duplicate of the current material.
  60158. * @param name - name to use for the new material.
  60159. */
  60160. clone(name: string): PBRSpecularGlossinessMaterial;
  60161. /**
  60162. * Serialize the material to a parsable JSON object.
  60163. */
  60164. serialize(): any;
  60165. /**
  60166. * Parses a JSON object correponding to the serialize function.
  60167. */
  60168. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60169. }
  60170. }
  60171. declare module BABYLON {
  60172. /**
  60173. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60174. * It can help converting any input color in a desired output one. This can then be used to create effects
  60175. * from sepia, black and white to sixties or futuristic rendering...
  60176. *
  60177. * The only supported format is currently 3dl.
  60178. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60179. */
  60180. export class ColorGradingTexture extends BaseTexture {
  60181. /**
  60182. * The texture URL.
  60183. */
  60184. url: string;
  60185. /**
  60186. * Empty line regex stored for GC.
  60187. */
  60188. private static _noneEmptyLineRegex;
  60189. private _textureMatrix;
  60190. private _onLoad;
  60191. /**
  60192. * Instantiates a ColorGradingTexture from the following parameters.
  60193. *
  60194. * @param url The location of the color gradind data (currently only supporting 3dl)
  60195. * @param sceneOrEngine The scene or engine the texture will be used in
  60196. * @param onLoad defines a callback triggered when the texture has been loaded
  60197. */
  60198. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60199. /**
  60200. * Fires the onload event from the constructor if requested.
  60201. */
  60202. private _triggerOnLoad;
  60203. /**
  60204. * Returns the texture matrix used in most of the material.
  60205. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60206. */
  60207. getTextureMatrix(): Matrix;
  60208. /**
  60209. * Occurs when the file being loaded is a .3dl LUT file.
  60210. */
  60211. private load3dlTexture;
  60212. /**
  60213. * Starts the loading process of the texture.
  60214. */
  60215. private loadTexture;
  60216. /**
  60217. * Clones the color gradind texture.
  60218. */
  60219. clone(): ColorGradingTexture;
  60220. /**
  60221. * Called during delayed load for textures.
  60222. */
  60223. delayLoad(): void;
  60224. /**
  60225. * Parses a color grading texture serialized by Babylon.
  60226. * @param parsedTexture The texture information being parsedTexture
  60227. * @param scene The scene to load the texture in
  60228. * @param rootUrl The root url of the data assets to load
  60229. * @return A color gradind texture
  60230. */
  60231. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60232. /**
  60233. * Serializes the LUT texture to json format.
  60234. */
  60235. serialize(): any;
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /**
  60240. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60241. */
  60242. export class EquiRectangularCubeTexture extends BaseTexture {
  60243. /** The six faces of the cube. */
  60244. private static _FacesMapping;
  60245. private _noMipmap;
  60246. private _onLoad;
  60247. private _onError;
  60248. /** The size of the cubemap. */
  60249. private _size;
  60250. /** The buffer of the image. */
  60251. private _buffer;
  60252. /** The width of the input image. */
  60253. private _width;
  60254. /** The height of the input image. */
  60255. private _height;
  60256. /** The URL to the image. */
  60257. url: string;
  60258. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60259. coordinatesMode: number;
  60260. /**
  60261. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60262. * @param url The location of the image
  60263. * @param scene The scene the texture will be used in
  60264. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60265. * @param noMipmap Forces to not generate the mipmap if true
  60266. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60267. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60268. * @param onLoad — defines a callback called when texture is loaded
  60269. * @param onError — defines a callback called if there is an error
  60270. */
  60271. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60272. /**
  60273. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60274. */
  60275. private loadImage;
  60276. /**
  60277. * Convert the image buffer into a cubemap and create a CubeTexture.
  60278. */
  60279. private loadTexture;
  60280. /**
  60281. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60282. * @param buffer The ArrayBuffer that should be converted.
  60283. * @returns The buffer as Float32Array.
  60284. */
  60285. private getFloat32ArrayFromArrayBuffer;
  60286. /**
  60287. * Get the current class name of the texture useful for serialization or dynamic coding.
  60288. * @returns "EquiRectangularCubeTexture"
  60289. */
  60290. getClassName(): string;
  60291. /**
  60292. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60293. * @returns A clone of the current EquiRectangularCubeTexture.
  60294. */
  60295. clone(): EquiRectangularCubeTexture;
  60296. }
  60297. }
  60298. declare module BABYLON {
  60299. /**
  60300. * Defines the options related to the creation of an HtmlElementTexture
  60301. */
  60302. export interface IHtmlElementTextureOptions {
  60303. /**
  60304. * Defines wether mip maps should be created or not.
  60305. */
  60306. generateMipMaps?: boolean;
  60307. /**
  60308. * Defines the sampling mode of the texture.
  60309. */
  60310. samplingMode?: number;
  60311. /**
  60312. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60313. */
  60314. engine: Nullable<ThinEngine>;
  60315. /**
  60316. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60317. */
  60318. scene: Nullable<Scene>;
  60319. }
  60320. /**
  60321. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60322. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60323. * is automatically managed.
  60324. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60325. * in your application.
  60326. *
  60327. * As the update is not automatic, you need to call them manually.
  60328. */
  60329. export class HtmlElementTexture extends BaseTexture {
  60330. /**
  60331. * The texture URL.
  60332. */
  60333. element: HTMLVideoElement | HTMLCanvasElement;
  60334. private static readonly DefaultOptions;
  60335. private _textureMatrix;
  60336. private _isVideo;
  60337. private _generateMipMaps;
  60338. private _samplingMode;
  60339. /**
  60340. * Instantiates a HtmlElementTexture from the following parameters.
  60341. *
  60342. * @param name Defines the name of the texture
  60343. * @param element Defines the video or canvas the texture is filled with
  60344. * @param options Defines the other none mandatory texture creation options
  60345. */
  60346. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60347. private _createInternalTexture;
  60348. /**
  60349. * Returns the texture matrix used in most of the material.
  60350. */
  60351. getTextureMatrix(): Matrix;
  60352. /**
  60353. * Updates the content of the texture.
  60354. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60355. */
  60356. update(invertY?: Nullable<boolean>): void;
  60357. }
  60358. }
  60359. declare module BABYLON {
  60360. /**
  60361. * Based on jsTGALoader - Javascript loader for TGA file
  60362. * By Vincent Thibault
  60363. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60364. */
  60365. export class TGATools {
  60366. private static _TYPE_INDEXED;
  60367. private static _TYPE_RGB;
  60368. private static _TYPE_GREY;
  60369. private static _TYPE_RLE_INDEXED;
  60370. private static _TYPE_RLE_RGB;
  60371. private static _TYPE_RLE_GREY;
  60372. private static _ORIGIN_MASK;
  60373. private static _ORIGIN_SHIFT;
  60374. private static _ORIGIN_BL;
  60375. private static _ORIGIN_BR;
  60376. private static _ORIGIN_UL;
  60377. private static _ORIGIN_UR;
  60378. /**
  60379. * Gets the header of a TGA file
  60380. * @param data defines the TGA data
  60381. * @returns the header
  60382. */
  60383. static GetTGAHeader(data: Uint8Array): any;
  60384. /**
  60385. * Uploads TGA content to a Babylon Texture
  60386. * @hidden
  60387. */
  60388. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60389. /** @hidden */
  60390. 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;
  60391. /** @hidden */
  60392. 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;
  60393. /** @hidden */
  60394. 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;
  60395. /** @hidden */
  60396. 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;
  60397. /** @hidden */
  60398. 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;
  60399. /** @hidden */
  60400. 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;
  60401. }
  60402. }
  60403. declare module BABYLON {
  60404. /**
  60405. * Implementation of the TGA Texture Loader.
  60406. * @hidden
  60407. */
  60408. export class _TGATextureLoader implements IInternalTextureLoader {
  60409. /**
  60410. * Defines wether the loader supports cascade loading the different faces.
  60411. */
  60412. readonly supportCascades: boolean;
  60413. /**
  60414. * This returns if the loader support the current file information.
  60415. * @param extension defines the file extension of the file being loaded
  60416. * @returns true if the loader can load the specified file
  60417. */
  60418. canLoad(extension: string): boolean;
  60419. /**
  60420. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60421. * @param data contains the texture data
  60422. * @param texture defines the BabylonJS internal texture
  60423. * @param createPolynomials will be true if polynomials have been requested
  60424. * @param onLoad defines the callback to trigger once the texture is ready
  60425. * @param onError defines the callback to trigger in case of error
  60426. */
  60427. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60428. /**
  60429. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60430. * @param data contains the texture data
  60431. * @param texture defines the BabylonJS internal texture
  60432. * @param callback defines the method to call once ready to upload
  60433. */
  60434. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60435. }
  60436. }
  60437. declare module BABYLON {
  60438. /**
  60439. * Info about the .basis files
  60440. */
  60441. class BasisFileInfo {
  60442. /**
  60443. * If the file has alpha
  60444. */
  60445. hasAlpha: boolean;
  60446. /**
  60447. * Info about each image of the basis file
  60448. */
  60449. images: Array<{
  60450. levels: Array<{
  60451. width: number;
  60452. height: number;
  60453. transcodedPixels: ArrayBufferView;
  60454. }>;
  60455. }>;
  60456. }
  60457. /**
  60458. * Result of transcoding a basis file
  60459. */
  60460. class TranscodeResult {
  60461. /**
  60462. * Info about the .basis file
  60463. */
  60464. fileInfo: BasisFileInfo;
  60465. /**
  60466. * Format to use when loading the file
  60467. */
  60468. format: number;
  60469. }
  60470. /**
  60471. * Configuration options for the Basis transcoder
  60472. */
  60473. export class BasisTranscodeConfiguration {
  60474. /**
  60475. * Supported compression formats used to determine the supported output format of the transcoder
  60476. */
  60477. supportedCompressionFormats?: {
  60478. /**
  60479. * etc1 compression format
  60480. */
  60481. etc1?: boolean;
  60482. /**
  60483. * s3tc compression format
  60484. */
  60485. s3tc?: boolean;
  60486. /**
  60487. * pvrtc compression format
  60488. */
  60489. pvrtc?: boolean;
  60490. /**
  60491. * etc2 compression format
  60492. */
  60493. etc2?: boolean;
  60494. };
  60495. /**
  60496. * If mipmap levels should be loaded for transcoded images (Default: true)
  60497. */
  60498. loadMipmapLevels?: boolean;
  60499. /**
  60500. * Index of a single image to load (Default: all images)
  60501. */
  60502. loadSingleImage?: number;
  60503. }
  60504. /**
  60505. * Used to load .Basis files
  60506. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60507. */
  60508. export class BasisTools {
  60509. private static _IgnoreSupportedFormats;
  60510. /**
  60511. * URL to use when loading the basis transcoder
  60512. */
  60513. static JSModuleURL: string;
  60514. /**
  60515. * URL to use when loading the wasm module for the transcoder
  60516. */
  60517. static WasmModuleURL: string;
  60518. /**
  60519. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60520. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60521. * @returns internal format corresponding to the Basis format
  60522. */
  60523. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60524. private static _WorkerPromise;
  60525. private static _Worker;
  60526. private static _actionId;
  60527. private static _CreateWorkerAsync;
  60528. /**
  60529. * Transcodes a loaded image file to compressed pixel data
  60530. * @param data image data to transcode
  60531. * @param config configuration options for the transcoding
  60532. * @returns a promise resulting in the transcoded image
  60533. */
  60534. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60535. /**
  60536. * Loads a texture from the transcode result
  60537. * @param texture texture load to
  60538. * @param transcodeResult the result of transcoding the basis file to load from
  60539. */
  60540. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60541. }
  60542. }
  60543. declare module BABYLON {
  60544. /**
  60545. * Loader for .basis file format
  60546. */
  60547. export class _BasisTextureLoader implements IInternalTextureLoader {
  60548. /**
  60549. * Defines whether the loader supports cascade loading the different faces.
  60550. */
  60551. readonly supportCascades: boolean;
  60552. /**
  60553. * This returns if the loader support the current file information.
  60554. * @param extension defines the file extension of the file being loaded
  60555. * @returns true if the loader can load the specified file
  60556. */
  60557. canLoad(extension: string): boolean;
  60558. /**
  60559. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60560. * @param data contains the texture data
  60561. * @param texture defines the BabylonJS internal texture
  60562. * @param createPolynomials will be true if polynomials have been requested
  60563. * @param onLoad defines the callback to trigger once the texture is ready
  60564. * @param onError defines the callback to trigger in case of error
  60565. */
  60566. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60567. /**
  60568. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60569. * @param data contains the texture data
  60570. * @param texture defines the BabylonJS internal texture
  60571. * @param callback defines the method to call once ready to upload
  60572. */
  60573. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60574. }
  60575. }
  60576. declare module BABYLON {
  60577. /**
  60578. * Defines the basic options interface of a TexturePacker Frame
  60579. */
  60580. export interface ITexturePackerFrame {
  60581. /**
  60582. * The frame ID
  60583. */
  60584. id: number;
  60585. /**
  60586. * The frames Scale
  60587. */
  60588. scale: Vector2;
  60589. /**
  60590. * The Frames offset
  60591. */
  60592. offset: Vector2;
  60593. }
  60594. /**
  60595. * This is a support class for frame Data on texture packer sets.
  60596. */
  60597. export class TexturePackerFrame implements ITexturePackerFrame {
  60598. /**
  60599. * The frame ID
  60600. */
  60601. id: number;
  60602. /**
  60603. * The frames Scale
  60604. */
  60605. scale: Vector2;
  60606. /**
  60607. * The Frames offset
  60608. */
  60609. offset: Vector2;
  60610. /**
  60611. * Initializes a texture package frame.
  60612. * @param id The numerical frame identifier
  60613. * @param scale Scalar Vector2 for UV frame
  60614. * @param offset Vector2 for the frame position in UV units.
  60615. * @returns TexturePackerFrame
  60616. */
  60617. constructor(id: number, scale: Vector2, offset: Vector2);
  60618. }
  60619. }
  60620. declare module BABYLON {
  60621. /**
  60622. * Defines the basic options interface of a TexturePacker
  60623. */
  60624. export interface ITexturePackerOptions {
  60625. /**
  60626. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60627. */
  60628. map?: string[];
  60629. /**
  60630. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60631. */
  60632. uvsIn?: string;
  60633. /**
  60634. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60635. */
  60636. uvsOut?: string;
  60637. /**
  60638. * number representing the layout style. Defaults to LAYOUT_STRIP
  60639. */
  60640. layout?: number;
  60641. /**
  60642. * number of columns if using custom column count layout(2). This defaults to 4.
  60643. */
  60644. colnum?: number;
  60645. /**
  60646. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60647. */
  60648. updateInputMeshes?: boolean;
  60649. /**
  60650. * boolean flag to dispose all the source textures. Defaults to true.
  60651. */
  60652. disposeSources?: boolean;
  60653. /**
  60654. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60655. */
  60656. fillBlanks?: boolean;
  60657. /**
  60658. * string value representing the context fill style color. Defaults to 'black'.
  60659. */
  60660. customFillColor?: string;
  60661. /**
  60662. * Width and Height Value of each Frame in the TexturePacker Sets
  60663. */
  60664. frameSize?: number;
  60665. /**
  60666. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60667. */
  60668. paddingRatio?: number;
  60669. /**
  60670. * Number that declares the fill method for the padding gutter.
  60671. */
  60672. paddingMode?: number;
  60673. /**
  60674. * If in SUBUV_COLOR padding mode what color to use.
  60675. */
  60676. paddingColor?: Color3 | Color4;
  60677. }
  60678. /**
  60679. * Defines the basic interface of a TexturePacker JSON File
  60680. */
  60681. export interface ITexturePackerJSON {
  60682. /**
  60683. * The frame ID
  60684. */
  60685. name: string;
  60686. /**
  60687. * The base64 channel data
  60688. */
  60689. sets: any;
  60690. /**
  60691. * The options of the Packer
  60692. */
  60693. options: ITexturePackerOptions;
  60694. /**
  60695. * The frame data of the Packer
  60696. */
  60697. frames: Array<number>;
  60698. }
  60699. /**
  60700. * This is a support class that generates a series of packed texture sets.
  60701. * @see https://doc.babylonjs.com/babylon101/materials
  60702. */
  60703. export class TexturePacker {
  60704. /** Packer Layout Constant 0 */
  60705. static readonly LAYOUT_STRIP: number;
  60706. /** Packer Layout Constant 1 */
  60707. static readonly LAYOUT_POWER2: number;
  60708. /** Packer Layout Constant 2 */
  60709. static readonly LAYOUT_COLNUM: number;
  60710. /** Packer Layout Constant 0 */
  60711. static readonly SUBUV_WRAP: number;
  60712. /** Packer Layout Constant 1 */
  60713. static readonly SUBUV_EXTEND: number;
  60714. /** Packer Layout Constant 2 */
  60715. static readonly SUBUV_COLOR: number;
  60716. /** The Name of the Texture Package */
  60717. name: string;
  60718. /** The scene scope of the TexturePacker */
  60719. scene: Scene;
  60720. /** The Meshes to target */
  60721. meshes: AbstractMesh[];
  60722. /** Arguments passed with the Constructor */
  60723. options: ITexturePackerOptions;
  60724. /** The promise that is started upon initialization */
  60725. promise: Nullable<Promise<TexturePacker | string>>;
  60726. /** The Container object for the channel sets that are generated */
  60727. sets: object;
  60728. /** The Container array for the frames that are generated */
  60729. frames: TexturePackerFrame[];
  60730. /** The expected number of textures the system is parsing. */
  60731. private _expecting;
  60732. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60733. private _paddingValue;
  60734. /**
  60735. * Initializes a texture package series from an array of meshes or a single mesh.
  60736. * @param name The name of the package
  60737. * @param meshes The target meshes to compose the package from
  60738. * @param options The arguments that texture packer should follow while building.
  60739. * @param scene The scene which the textures are scoped to.
  60740. * @returns TexturePacker
  60741. */
  60742. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60743. /**
  60744. * Starts the package process
  60745. * @param resolve The promises resolution function
  60746. * @returns TexturePacker
  60747. */
  60748. private _createFrames;
  60749. /**
  60750. * Calculates the Size of the Channel Sets
  60751. * @returns Vector2
  60752. */
  60753. private _calculateSize;
  60754. /**
  60755. * Calculates the UV data for the frames.
  60756. * @param baseSize the base frameSize
  60757. * @param padding the base frame padding
  60758. * @param dtSize size of the Dynamic Texture for that channel
  60759. * @param dtUnits is 1/dtSize
  60760. * @param update flag to update the input meshes
  60761. */
  60762. private _calculateMeshUVFrames;
  60763. /**
  60764. * Calculates the frames Offset.
  60765. * @param index of the frame
  60766. * @returns Vector2
  60767. */
  60768. private _getFrameOffset;
  60769. /**
  60770. * Updates a Mesh to the frame data
  60771. * @param mesh that is the target
  60772. * @param frameID or the frame index
  60773. */
  60774. private _updateMeshUV;
  60775. /**
  60776. * Updates a Meshes materials to use the texture packer channels
  60777. * @param m is the mesh to target
  60778. * @param force all channels on the packer to be set.
  60779. */
  60780. private _updateTextureReferences;
  60781. /**
  60782. * Public method to set a Mesh to a frame
  60783. * @param m that is the target
  60784. * @param frameID or the frame index
  60785. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60786. */
  60787. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60788. /**
  60789. * Starts the async promise to compile the texture packer.
  60790. * @returns Promise<void>
  60791. */
  60792. processAsync(): Promise<void>;
  60793. /**
  60794. * Disposes all textures associated with this packer
  60795. */
  60796. dispose(): void;
  60797. /**
  60798. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60799. * @param imageType is the image type to use.
  60800. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60801. */
  60802. download(imageType?: string, quality?: number): void;
  60803. /**
  60804. * Public method to load a texturePacker JSON file.
  60805. * @param data of the JSON file in string format.
  60806. */
  60807. updateFromJSON(data: string): void;
  60808. }
  60809. }
  60810. declare module BABYLON {
  60811. /**
  60812. * 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.
  60813. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60814. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60815. */
  60816. export class CustomProceduralTexture extends ProceduralTexture {
  60817. private _animate;
  60818. private _time;
  60819. private _config;
  60820. private _texturePath;
  60821. /**
  60822. * Instantiates a new Custom Procedural Texture.
  60823. * 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.
  60824. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60825. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60826. * @param name Define the name of the texture
  60827. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60828. * @param size Define the size of the texture to create
  60829. * @param scene Define the scene the texture belongs to
  60830. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60831. * @param generateMipMaps Define if the texture should creates mip maps or not
  60832. */
  60833. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60834. private _loadJson;
  60835. /**
  60836. * Is the texture ready to be used ? (rendered at least once)
  60837. * @returns true if ready, otherwise, false.
  60838. */
  60839. isReady(): boolean;
  60840. /**
  60841. * Render the texture to its associated render target.
  60842. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60843. */
  60844. render(useCameraPostProcess?: boolean): void;
  60845. /**
  60846. * Update the list of dependant textures samplers in the shader.
  60847. */
  60848. updateTextures(): void;
  60849. /**
  60850. * Update the uniform values of the procedural texture in the shader.
  60851. */
  60852. updateShaderUniforms(): void;
  60853. /**
  60854. * Define if the texture animates or not.
  60855. */
  60856. get animate(): boolean;
  60857. set animate(value: boolean);
  60858. }
  60859. }
  60860. declare module BABYLON {
  60861. /** @hidden */
  60862. export var noisePixelShader: {
  60863. name: string;
  60864. shader: string;
  60865. };
  60866. }
  60867. declare module BABYLON {
  60868. /**
  60869. * Class used to generate noise procedural textures
  60870. */
  60871. export class NoiseProceduralTexture extends ProceduralTexture {
  60872. private _time;
  60873. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60874. brightness: number;
  60875. /** Defines the number of octaves to process */
  60876. octaves: number;
  60877. /** Defines the level of persistence (0.8 by default) */
  60878. persistence: number;
  60879. /** Gets or sets animation speed factor (default is 1) */
  60880. animationSpeedFactor: number;
  60881. /**
  60882. * Creates a new NoiseProceduralTexture
  60883. * @param name defines the name fo the texture
  60884. * @param size defines the size of the texture (default is 256)
  60885. * @param scene defines the hosting scene
  60886. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60887. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60888. */
  60889. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60890. private _updateShaderUniforms;
  60891. protected _getDefines(): string;
  60892. /** Generate the current state of the procedural texture */
  60893. render(useCameraPostProcess?: boolean): void;
  60894. /**
  60895. * Serializes this noise procedural texture
  60896. * @returns a serialized noise procedural texture object
  60897. */
  60898. serialize(): any;
  60899. /**
  60900. * Clone the texture.
  60901. * @returns the cloned texture
  60902. */
  60903. clone(): NoiseProceduralTexture;
  60904. /**
  60905. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60906. * @param parsedTexture defines parsed texture data
  60907. * @param scene defines the current scene
  60908. * @param rootUrl defines the root URL containing noise procedural texture information
  60909. * @returns a parsed NoiseProceduralTexture
  60910. */
  60911. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60912. }
  60913. }
  60914. declare module BABYLON {
  60915. /**
  60916. * Raw cube texture where the raw buffers are passed in
  60917. */
  60918. export class RawCubeTexture extends CubeTexture {
  60919. /**
  60920. * Creates a cube texture where the raw buffers are passed in.
  60921. * @param scene defines the scene the texture is attached to
  60922. * @param data defines the array of data to use to create each face
  60923. * @param size defines the size of the textures
  60924. * @param format defines the format of the data
  60925. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60926. * @param generateMipMaps defines if the engine should generate the mip levels
  60927. * @param invertY defines if data must be stored with Y axis inverted
  60928. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60929. * @param compression defines the compression used (null by default)
  60930. */
  60931. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60932. /**
  60933. * Updates the raw cube texture.
  60934. * @param data defines the data to store
  60935. * @param format defines the data format
  60936. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60937. * @param invertY defines if data must be stored with Y axis inverted
  60938. * @param compression defines the compression used (null by default)
  60939. * @param level defines which level of the texture to update
  60940. */
  60941. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60942. /**
  60943. * Updates a raw cube texture with RGBD encoded data.
  60944. * @param data defines the array of data [mipmap][face] to use to create each face
  60945. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60946. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60947. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60948. * @returns a promsie that resolves when the operation is complete
  60949. */
  60950. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60951. /**
  60952. * Clones the raw cube texture.
  60953. * @return a new cube texture
  60954. */
  60955. clone(): CubeTexture;
  60956. /** @hidden */
  60957. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60958. }
  60959. }
  60960. declare module BABYLON {
  60961. /**
  60962. * Class used to store 2D array textures containing user data
  60963. */
  60964. export class RawTexture2DArray extends Texture {
  60965. /** Gets or sets the texture format to use */
  60966. format: number;
  60967. /**
  60968. * Create a new RawTexture2DArray
  60969. * @param data defines the data of the texture
  60970. * @param width defines the width of the texture
  60971. * @param height defines the height of the texture
  60972. * @param depth defines the number of layers of the texture
  60973. * @param format defines the texture format to use
  60974. * @param scene defines the hosting scene
  60975. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60976. * @param invertY defines if texture must be stored with Y axis inverted
  60977. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60978. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60979. */
  60980. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60981. /** Gets or sets the texture format to use */
  60982. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60983. /**
  60984. * Update the texture with new data
  60985. * @param data defines the data to store in the texture
  60986. */
  60987. update(data: ArrayBufferView): void;
  60988. }
  60989. }
  60990. declare module BABYLON {
  60991. /**
  60992. * Class used to store 3D textures containing user data
  60993. */
  60994. export class RawTexture3D extends Texture {
  60995. /** Gets or sets the texture format to use */
  60996. format: number;
  60997. /**
  60998. * Create a new RawTexture3D
  60999. * @param data defines the data of the texture
  61000. * @param width defines the width of the texture
  61001. * @param height defines the height of the texture
  61002. * @param depth defines the depth of the texture
  61003. * @param format defines the texture format to use
  61004. * @param scene defines the hosting scene
  61005. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61006. * @param invertY defines if texture must be stored with Y axis inverted
  61007. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61008. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61009. */
  61010. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61011. /** Gets or sets the texture format to use */
  61012. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61013. /**
  61014. * Update the texture with new data
  61015. * @param data defines the data to store in the texture
  61016. */
  61017. update(data: ArrayBufferView): void;
  61018. }
  61019. }
  61020. declare module BABYLON {
  61021. /**
  61022. * Creates a refraction texture used by refraction channel of the standard material.
  61023. * It is like a mirror but to see through a material.
  61024. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61025. */
  61026. export class RefractionTexture extends RenderTargetTexture {
  61027. /**
  61028. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61029. * 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.
  61030. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61031. */
  61032. refractionPlane: Plane;
  61033. /**
  61034. * Define how deep under the surface we should see.
  61035. */
  61036. depth: number;
  61037. /**
  61038. * Creates a refraction texture used by refraction channel of the standard material.
  61039. * It is like a mirror but to see through a material.
  61040. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61041. * @param name Define the texture name
  61042. * @param size Define the size of the underlying texture
  61043. * @param scene Define the scene the refraction belongs to
  61044. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61045. */
  61046. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61047. /**
  61048. * Clone the refraction texture.
  61049. * @returns the cloned texture
  61050. */
  61051. clone(): RefractionTexture;
  61052. /**
  61053. * Serialize the texture to a JSON representation you could use in Parse later on
  61054. * @returns the serialized JSON representation
  61055. */
  61056. serialize(): any;
  61057. }
  61058. }
  61059. declare module BABYLON {
  61060. /**
  61061. * Block used to add support for vertex skinning (bones)
  61062. */
  61063. export class BonesBlock extends NodeMaterialBlock {
  61064. /**
  61065. * Creates a new BonesBlock
  61066. * @param name defines the block name
  61067. */
  61068. constructor(name: string);
  61069. /**
  61070. * Initialize the block and prepare the context for build
  61071. * @param state defines the state that will be used for the build
  61072. */
  61073. initialize(state: NodeMaterialBuildState): void;
  61074. /**
  61075. * Gets the current class name
  61076. * @returns the class name
  61077. */
  61078. getClassName(): string;
  61079. /**
  61080. * Gets the matrix indices input component
  61081. */
  61082. get matricesIndices(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Gets the matrix weights input component
  61085. */
  61086. get matricesWeights(): NodeMaterialConnectionPoint;
  61087. /**
  61088. * Gets the extra matrix indices input component
  61089. */
  61090. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61091. /**
  61092. * Gets the extra matrix weights input component
  61093. */
  61094. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the world input component
  61097. */
  61098. get world(): NodeMaterialConnectionPoint;
  61099. /**
  61100. * Gets the output component
  61101. */
  61102. get output(): NodeMaterialConnectionPoint;
  61103. autoConfigure(material: NodeMaterial): void;
  61104. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61105. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61107. protected _buildBlock(state: NodeMaterialBuildState): this;
  61108. }
  61109. }
  61110. declare module BABYLON {
  61111. /**
  61112. * Block used to add support for instances
  61113. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61114. */
  61115. export class InstancesBlock extends NodeMaterialBlock {
  61116. /**
  61117. * Creates a new InstancesBlock
  61118. * @param name defines the block name
  61119. */
  61120. constructor(name: string);
  61121. /**
  61122. * Gets the current class name
  61123. * @returns the class name
  61124. */
  61125. getClassName(): string;
  61126. /**
  61127. * Gets the first world row input component
  61128. */
  61129. get world0(): NodeMaterialConnectionPoint;
  61130. /**
  61131. * Gets the second world row input component
  61132. */
  61133. get world1(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the third world row input component
  61136. */
  61137. get world2(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the forth world row input component
  61140. */
  61141. get world3(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the world input component
  61144. */
  61145. get world(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the output component
  61148. */
  61149. get output(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Gets the isntanceID component
  61152. */
  61153. get instanceID(): NodeMaterialConnectionPoint;
  61154. autoConfigure(material: NodeMaterial): void;
  61155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61156. protected _buildBlock(state: NodeMaterialBuildState): this;
  61157. }
  61158. }
  61159. declare module BABYLON {
  61160. /**
  61161. * Block used to add morph targets support to vertex shader
  61162. */
  61163. export class MorphTargetsBlock extends NodeMaterialBlock {
  61164. private _repeatableContentAnchor;
  61165. /**
  61166. * Create a new MorphTargetsBlock
  61167. * @param name defines the block name
  61168. */
  61169. constructor(name: string);
  61170. /**
  61171. * Gets the current class name
  61172. * @returns the class name
  61173. */
  61174. getClassName(): string;
  61175. /**
  61176. * Gets the position input component
  61177. */
  61178. get position(): NodeMaterialConnectionPoint;
  61179. /**
  61180. * Gets the normal input component
  61181. */
  61182. get normal(): NodeMaterialConnectionPoint;
  61183. /**
  61184. * Gets the tangent input component
  61185. */
  61186. get tangent(): NodeMaterialConnectionPoint;
  61187. /**
  61188. * Gets the tangent input component
  61189. */
  61190. get uv(): NodeMaterialConnectionPoint;
  61191. /**
  61192. * Gets the position output component
  61193. */
  61194. get positionOutput(): NodeMaterialConnectionPoint;
  61195. /**
  61196. * Gets the normal output component
  61197. */
  61198. get normalOutput(): NodeMaterialConnectionPoint;
  61199. /**
  61200. * Gets the tangent output component
  61201. */
  61202. get tangentOutput(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the tangent output component
  61205. */
  61206. get uvOutput(): NodeMaterialConnectionPoint;
  61207. initialize(state: NodeMaterialBuildState): void;
  61208. autoConfigure(material: NodeMaterial): void;
  61209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61210. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61211. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61212. protected _buildBlock(state: NodeMaterialBuildState): this;
  61213. }
  61214. }
  61215. declare module BABYLON {
  61216. /**
  61217. * Block used to get data information from a light
  61218. */
  61219. export class LightInformationBlock extends NodeMaterialBlock {
  61220. private _lightDataUniformName;
  61221. private _lightColorUniformName;
  61222. private _lightTypeDefineName;
  61223. /**
  61224. * Gets or sets the light associated with this block
  61225. */
  61226. light: Nullable<Light>;
  61227. /**
  61228. * Creates a new LightInformationBlock
  61229. * @param name defines the block name
  61230. */
  61231. constructor(name: string);
  61232. /**
  61233. * Gets the current class name
  61234. * @returns the class name
  61235. */
  61236. getClassName(): string;
  61237. /**
  61238. * Gets the world position input component
  61239. */
  61240. get worldPosition(): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Gets the direction output component
  61243. */
  61244. get direction(): NodeMaterialConnectionPoint;
  61245. /**
  61246. * Gets the direction output component
  61247. */
  61248. get color(): NodeMaterialConnectionPoint;
  61249. /**
  61250. * Gets the direction output component
  61251. */
  61252. get intensity(): NodeMaterialConnectionPoint;
  61253. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61254. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61255. protected _buildBlock(state: NodeMaterialBuildState): this;
  61256. serialize(): any;
  61257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61258. }
  61259. }
  61260. declare module BABYLON {
  61261. /**
  61262. * Block used to add image processing support to fragment shader
  61263. */
  61264. export class ImageProcessingBlock extends NodeMaterialBlock {
  61265. /**
  61266. * Create a new ImageProcessingBlock
  61267. * @param name defines the block name
  61268. */
  61269. constructor(name: string);
  61270. /**
  61271. * Gets the current class name
  61272. * @returns the class name
  61273. */
  61274. getClassName(): string;
  61275. /**
  61276. * Gets the color input component
  61277. */
  61278. get color(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Gets the output component
  61281. */
  61282. get output(): NodeMaterialConnectionPoint;
  61283. /**
  61284. * Initialize the block and prepare the context for build
  61285. * @param state defines the state that will be used for the build
  61286. */
  61287. initialize(state: NodeMaterialBuildState): void;
  61288. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61290. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61291. protected _buildBlock(state: NodeMaterialBuildState): this;
  61292. }
  61293. }
  61294. declare module BABYLON {
  61295. /**
  61296. * Block used to pertub normals based on a normal map
  61297. */
  61298. export class PerturbNormalBlock extends NodeMaterialBlock {
  61299. private _tangentSpaceParameterName;
  61300. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61301. invertX: boolean;
  61302. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61303. invertY: boolean;
  61304. /**
  61305. * Create a new PerturbNormalBlock
  61306. * @param name defines the block name
  61307. */
  61308. constructor(name: string);
  61309. /**
  61310. * Gets the current class name
  61311. * @returns the class name
  61312. */
  61313. getClassName(): string;
  61314. /**
  61315. * Gets the world position input component
  61316. */
  61317. get worldPosition(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the world normal input component
  61320. */
  61321. get worldNormal(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the world tangent input component
  61324. */
  61325. get worldTangent(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the uv input component
  61328. */
  61329. get uv(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the normal map color input component
  61332. */
  61333. get normalMapColor(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the strength input component
  61336. */
  61337. get strength(): NodeMaterialConnectionPoint;
  61338. /**
  61339. * Gets the output component
  61340. */
  61341. get output(): NodeMaterialConnectionPoint;
  61342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61344. autoConfigure(material: NodeMaterial): void;
  61345. protected _buildBlock(state: NodeMaterialBuildState): this;
  61346. protected _dumpPropertiesCode(): string;
  61347. serialize(): any;
  61348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61349. }
  61350. }
  61351. declare module BABYLON {
  61352. /**
  61353. * Block used to discard a pixel if a value is smaller than a cutoff
  61354. */
  61355. export class DiscardBlock extends NodeMaterialBlock {
  61356. /**
  61357. * Create a new DiscardBlock
  61358. * @param name defines the block name
  61359. */
  61360. constructor(name: string);
  61361. /**
  61362. * Gets the current class name
  61363. * @returns the class name
  61364. */
  61365. getClassName(): string;
  61366. /**
  61367. * Gets the color input component
  61368. */
  61369. get value(): NodeMaterialConnectionPoint;
  61370. /**
  61371. * Gets the cutoff input component
  61372. */
  61373. get cutoff(): NodeMaterialConnectionPoint;
  61374. protected _buildBlock(state: NodeMaterialBuildState): this;
  61375. }
  61376. }
  61377. declare module BABYLON {
  61378. /**
  61379. * Block used to test if the fragment shader is front facing
  61380. */
  61381. export class FrontFacingBlock extends NodeMaterialBlock {
  61382. /**
  61383. * Creates a new FrontFacingBlock
  61384. * @param name defines the block name
  61385. */
  61386. constructor(name: string);
  61387. /**
  61388. * Gets the current class name
  61389. * @returns the class name
  61390. */
  61391. getClassName(): string;
  61392. /**
  61393. * Gets the output component
  61394. */
  61395. get output(): NodeMaterialConnectionPoint;
  61396. protected _buildBlock(state: NodeMaterialBuildState): this;
  61397. }
  61398. }
  61399. declare module BABYLON {
  61400. /**
  61401. * Block used to get the derivative value on x and y of a given input
  61402. */
  61403. export class DerivativeBlock extends NodeMaterialBlock {
  61404. /**
  61405. * Create a new DerivativeBlock
  61406. * @param name defines the block name
  61407. */
  61408. constructor(name: string);
  61409. /**
  61410. * Gets the current class name
  61411. * @returns the class name
  61412. */
  61413. getClassName(): string;
  61414. /**
  61415. * Gets the input component
  61416. */
  61417. get input(): NodeMaterialConnectionPoint;
  61418. /**
  61419. * Gets the derivative output on x
  61420. */
  61421. get dx(): NodeMaterialConnectionPoint;
  61422. /**
  61423. * Gets the derivative output on y
  61424. */
  61425. get dy(): NodeMaterialConnectionPoint;
  61426. protected _buildBlock(state: NodeMaterialBuildState): this;
  61427. }
  61428. }
  61429. declare module BABYLON {
  61430. /**
  61431. * Block used to make gl_FragCoord available
  61432. */
  61433. export class FragCoordBlock extends NodeMaterialBlock {
  61434. /**
  61435. * Creates a new FragCoordBlock
  61436. * @param name defines the block name
  61437. */
  61438. constructor(name: string);
  61439. /**
  61440. * Gets the current class name
  61441. * @returns the class name
  61442. */
  61443. getClassName(): string;
  61444. /**
  61445. * Gets the xy component
  61446. */
  61447. get xy(): NodeMaterialConnectionPoint;
  61448. /**
  61449. * Gets the xyz component
  61450. */
  61451. get xyz(): NodeMaterialConnectionPoint;
  61452. /**
  61453. * Gets the xyzw component
  61454. */
  61455. get xyzw(): NodeMaterialConnectionPoint;
  61456. /**
  61457. * Gets the x component
  61458. */
  61459. get x(): NodeMaterialConnectionPoint;
  61460. /**
  61461. * Gets the y component
  61462. */
  61463. get y(): NodeMaterialConnectionPoint;
  61464. /**
  61465. * Gets the z component
  61466. */
  61467. get z(): NodeMaterialConnectionPoint;
  61468. /**
  61469. * Gets the w component
  61470. */
  61471. get output(): NodeMaterialConnectionPoint;
  61472. protected writeOutputs(state: NodeMaterialBuildState): string;
  61473. protected _buildBlock(state: NodeMaterialBuildState): this;
  61474. }
  61475. }
  61476. declare module BABYLON {
  61477. /**
  61478. * Block used to get the screen sizes
  61479. */
  61480. export class ScreenSizeBlock extends NodeMaterialBlock {
  61481. private _varName;
  61482. private _scene;
  61483. /**
  61484. * Creates a new ScreenSizeBlock
  61485. * @param name defines the block name
  61486. */
  61487. constructor(name: string);
  61488. /**
  61489. * Gets the current class name
  61490. * @returns the class name
  61491. */
  61492. getClassName(): string;
  61493. /**
  61494. * Gets the xy component
  61495. */
  61496. get xy(): NodeMaterialConnectionPoint;
  61497. /**
  61498. * Gets the x component
  61499. */
  61500. get x(): NodeMaterialConnectionPoint;
  61501. /**
  61502. * Gets the y component
  61503. */
  61504. get y(): NodeMaterialConnectionPoint;
  61505. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61506. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61507. protected _buildBlock(state: NodeMaterialBuildState): this;
  61508. }
  61509. }
  61510. declare module BABYLON {
  61511. /**
  61512. * Block used to add support for scene fog
  61513. */
  61514. export class FogBlock extends NodeMaterialBlock {
  61515. private _fogDistanceName;
  61516. private _fogParameters;
  61517. /**
  61518. * Create a new FogBlock
  61519. * @param name defines the block name
  61520. */
  61521. constructor(name: string);
  61522. /**
  61523. * Gets the current class name
  61524. * @returns the class name
  61525. */
  61526. getClassName(): string;
  61527. /**
  61528. * Gets the world position input component
  61529. */
  61530. get worldPosition(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the view input component
  61533. */
  61534. get view(): NodeMaterialConnectionPoint;
  61535. /**
  61536. * Gets the color input component
  61537. */
  61538. get input(): NodeMaterialConnectionPoint;
  61539. /**
  61540. * Gets the fog color input component
  61541. */
  61542. get fogColor(): NodeMaterialConnectionPoint;
  61543. /**
  61544. * Gets the output component
  61545. */
  61546. get output(): NodeMaterialConnectionPoint;
  61547. autoConfigure(material: NodeMaterial): void;
  61548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61549. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61550. protected _buildBlock(state: NodeMaterialBuildState): this;
  61551. }
  61552. }
  61553. declare module BABYLON {
  61554. /**
  61555. * Block used to add light in the fragment shader
  61556. */
  61557. export class LightBlock extends NodeMaterialBlock {
  61558. private _lightId;
  61559. /**
  61560. * Gets or sets the light associated with this block
  61561. */
  61562. light: Nullable<Light>;
  61563. /**
  61564. * Create a new LightBlock
  61565. * @param name defines the block name
  61566. */
  61567. constructor(name: string);
  61568. /**
  61569. * Gets the current class name
  61570. * @returns the class name
  61571. */
  61572. getClassName(): string;
  61573. /**
  61574. * Gets the world position input component
  61575. */
  61576. get worldPosition(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the world normal input component
  61579. */
  61580. get worldNormal(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the camera (or eye) position component
  61583. */
  61584. get cameraPosition(): NodeMaterialConnectionPoint;
  61585. /**
  61586. * Gets the glossiness component
  61587. */
  61588. get glossiness(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the glossinness power component
  61591. */
  61592. get glossPower(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the diffuse color component
  61595. */
  61596. get diffuseColor(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the specular color component
  61599. */
  61600. get specularColor(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the diffuse output component
  61603. */
  61604. get diffuseOutput(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the specular output component
  61607. */
  61608. get specularOutput(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the shadow output component
  61611. */
  61612. get shadow(): NodeMaterialConnectionPoint;
  61613. autoConfigure(material: NodeMaterial): void;
  61614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61615. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61616. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61617. private _injectVertexCode;
  61618. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61619. serialize(): any;
  61620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * Block used to read a reflection texture from a sampler
  61626. */
  61627. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61628. /**
  61629. * Create a new ReflectionTextureBlock
  61630. * @param name defines the block name
  61631. */
  61632. constructor(name: string);
  61633. /**
  61634. * Gets the current class name
  61635. * @returns the class name
  61636. */
  61637. getClassName(): string;
  61638. /**
  61639. * Gets the world position input component
  61640. */
  61641. get position(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the world position input component
  61644. */
  61645. get worldPosition(): NodeMaterialConnectionPoint;
  61646. /**
  61647. * Gets the world normal input component
  61648. */
  61649. get worldNormal(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the world input component
  61652. */
  61653. get world(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the camera (or eye) position component
  61656. */
  61657. get cameraPosition(): NodeMaterialConnectionPoint;
  61658. /**
  61659. * Gets the view input component
  61660. */
  61661. get view(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the rgb output component
  61664. */
  61665. get rgb(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the r output component
  61668. */
  61669. get r(): NodeMaterialConnectionPoint;
  61670. /**
  61671. * Gets the g output component
  61672. */
  61673. get g(): NodeMaterialConnectionPoint;
  61674. /**
  61675. * Gets the b output component
  61676. */
  61677. get b(): NodeMaterialConnectionPoint;
  61678. autoConfigure(material: NodeMaterial): void;
  61679. protected _buildBlock(state: NodeMaterialBuildState): this;
  61680. }
  61681. }
  61682. declare module BABYLON {
  61683. /**
  61684. * Block used to add 2 vectors
  61685. */
  61686. export class AddBlock extends NodeMaterialBlock {
  61687. /**
  61688. * Creates a new AddBlock
  61689. * @param name defines the block name
  61690. */
  61691. constructor(name: string);
  61692. /**
  61693. * Gets the current class name
  61694. * @returns the class name
  61695. */
  61696. getClassName(): string;
  61697. /**
  61698. * Gets the left operand input component
  61699. */
  61700. get left(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the right operand input component
  61703. */
  61704. get right(): NodeMaterialConnectionPoint;
  61705. /**
  61706. * Gets the output component
  61707. */
  61708. get output(): NodeMaterialConnectionPoint;
  61709. protected _buildBlock(state: NodeMaterialBuildState): this;
  61710. }
  61711. }
  61712. declare module BABYLON {
  61713. /**
  61714. * Block used to scale a vector by a float
  61715. */
  61716. export class ScaleBlock extends NodeMaterialBlock {
  61717. /**
  61718. * Creates a new ScaleBlock
  61719. * @param name defines the block name
  61720. */
  61721. constructor(name: string);
  61722. /**
  61723. * Gets the current class name
  61724. * @returns the class name
  61725. */
  61726. getClassName(): string;
  61727. /**
  61728. * Gets the input component
  61729. */
  61730. get input(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the factor input component
  61733. */
  61734. get factor(): NodeMaterialConnectionPoint;
  61735. /**
  61736. * Gets the output component
  61737. */
  61738. get output(): NodeMaterialConnectionPoint;
  61739. protected _buildBlock(state: NodeMaterialBuildState): this;
  61740. }
  61741. }
  61742. declare module BABYLON {
  61743. /**
  61744. * Block used to clamp a float
  61745. */
  61746. export class ClampBlock extends NodeMaterialBlock {
  61747. /** Gets or sets the minimum range */
  61748. minimum: number;
  61749. /** Gets or sets the maximum range */
  61750. maximum: number;
  61751. /**
  61752. * Creates a new ClampBlock
  61753. * @param name defines the block name
  61754. */
  61755. constructor(name: string);
  61756. /**
  61757. * Gets the current class name
  61758. * @returns the class name
  61759. */
  61760. getClassName(): string;
  61761. /**
  61762. * Gets the value input component
  61763. */
  61764. get value(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the output component
  61767. */
  61768. get output(): NodeMaterialConnectionPoint;
  61769. protected _buildBlock(state: NodeMaterialBuildState): this;
  61770. protected _dumpPropertiesCode(): string;
  61771. serialize(): any;
  61772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61773. }
  61774. }
  61775. declare module BABYLON {
  61776. /**
  61777. * Block used to apply a cross product between 2 vectors
  61778. */
  61779. export class CrossBlock extends NodeMaterialBlock {
  61780. /**
  61781. * Creates a new CrossBlock
  61782. * @param name defines the block name
  61783. */
  61784. constructor(name: string);
  61785. /**
  61786. * Gets the current class name
  61787. * @returns the class name
  61788. */
  61789. getClassName(): string;
  61790. /**
  61791. * Gets the left operand input component
  61792. */
  61793. get left(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the right operand input component
  61796. */
  61797. get right(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the output component
  61800. */
  61801. get output(): NodeMaterialConnectionPoint;
  61802. protected _buildBlock(state: NodeMaterialBuildState): this;
  61803. }
  61804. }
  61805. declare module BABYLON {
  61806. /**
  61807. * Block used to apply a dot product between 2 vectors
  61808. */
  61809. export class DotBlock extends NodeMaterialBlock {
  61810. /**
  61811. * Creates a new DotBlock
  61812. * @param name defines the block name
  61813. */
  61814. constructor(name: string);
  61815. /**
  61816. * Gets the current class name
  61817. * @returns the class name
  61818. */
  61819. getClassName(): string;
  61820. /**
  61821. * Gets the left operand input component
  61822. */
  61823. get left(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the right operand input component
  61826. */
  61827. get right(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the output component
  61830. */
  61831. get output(): NodeMaterialConnectionPoint;
  61832. protected _buildBlock(state: NodeMaterialBuildState): this;
  61833. }
  61834. }
  61835. declare module BABYLON {
  61836. /**
  61837. * Block used to normalize a vector
  61838. */
  61839. export class NormalizeBlock extends NodeMaterialBlock {
  61840. /**
  61841. * Creates a new NormalizeBlock
  61842. * @param name defines the block name
  61843. */
  61844. constructor(name: string);
  61845. /**
  61846. * Gets the current class name
  61847. * @returns the class name
  61848. */
  61849. getClassName(): string;
  61850. /**
  61851. * Gets the input component
  61852. */
  61853. get input(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the output component
  61856. */
  61857. get output(): NodeMaterialConnectionPoint;
  61858. protected _buildBlock(state: NodeMaterialBuildState): this;
  61859. }
  61860. }
  61861. declare module BABYLON {
  61862. /**
  61863. * Operations supported by the Trigonometry block
  61864. */
  61865. export enum TrigonometryBlockOperations {
  61866. /** Cos */
  61867. Cos = 0,
  61868. /** Sin */
  61869. Sin = 1,
  61870. /** Abs */
  61871. Abs = 2,
  61872. /** Exp */
  61873. Exp = 3,
  61874. /** Exp2 */
  61875. Exp2 = 4,
  61876. /** Round */
  61877. Round = 5,
  61878. /** Floor */
  61879. Floor = 6,
  61880. /** Ceiling */
  61881. Ceiling = 7,
  61882. /** Square root */
  61883. Sqrt = 8,
  61884. /** Log */
  61885. Log = 9,
  61886. /** Tangent */
  61887. Tan = 10,
  61888. /** Arc tangent */
  61889. ArcTan = 11,
  61890. /** Arc cosinus */
  61891. ArcCos = 12,
  61892. /** Arc sinus */
  61893. ArcSin = 13,
  61894. /** Fraction */
  61895. Fract = 14,
  61896. /** Sign */
  61897. Sign = 15,
  61898. /** To radians (from degrees) */
  61899. Radians = 16,
  61900. /** To degrees (from radians) */
  61901. Degrees = 17
  61902. }
  61903. /**
  61904. * Block used to apply trigonometry operation to floats
  61905. */
  61906. export class TrigonometryBlock extends NodeMaterialBlock {
  61907. /**
  61908. * Gets or sets the operation applied by the block
  61909. */
  61910. operation: TrigonometryBlockOperations;
  61911. /**
  61912. * Creates a new TrigonometryBlock
  61913. * @param name defines the block name
  61914. */
  61915. constructor(name: string);
  61916. /**
  61917. * Gets the current class name
  61918. * @returns the class name
  61919. */
  61920. getClassName(): string;
  61921. /**
  61922. * Gets the input component
  61923. */
  61924. get input(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the output component
  61927. */
  61928. get output(): NodeMaterialConnectionPoint;
  61929. protected _buildBlock(state: NodeMaterialBuildState): this;
  61930. serialize(): any;
  61931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61932. protected _dumpPropertiesCode(): string;
  61933. }
  61934. }
  61935. declare module BABYLON {
  61936. /**
  61937. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61938. */
  61939. export class ColorMergerBlock extends NodeMaterialBlock {
  61940. /**
  61941. * Create a new ColorMergerBlock
  61942. * @param name defines the block name
  61943. */
  61944. constructor(name: string);
  61945. /**
  61946. * Gets the current class name
  61947. * @returns the class name
  61948. */
  61949. getClassName(): string;
  61950. /**
  61951. * Gets the rgb component (input)
  61952. */
  61953. get rgbIn(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the r component (input)
  61956. */
  61957. get r(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the g component (input)
  61960. */
  61961. get g(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the b component (input)
  61964. */
  61965. get b(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the a component (input)
  61968. */
  61969. get a(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the rgba component (output)
  61972. */
  61973. get rgba(): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Gets the rgb component (output)
  61976. */
  61977. get rgbOut(): NodeMaterialConnectionPoint;
  61978. /**
  61979. * Gets the rgb component (output)
  61980. * @deprecated Please use rgbOut instead.
  61981. */
  61982. get rgb(): NodeMaterialConnectionPoint;
  61983. protected _buildBlock(state: NodeMaterialBuildState): this;
  61984. }
  61985. }
  61986. declare module BABYLON {
  61987. /**
  61988. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61989. */
  61990. export class VectorSplitterBlock extends NodeMaterialBlock {
  61991. /**
  61992. * Create a new VectorSplitterBlock
  61993. * @param name defines the block name
  61994. */
  61995. constructor(name: string);
  61996. /**
  61997. * Gets the current class name
  61998. * @returns the class name
  61999. */
  62000. getClassName(): string;
  62001. /**
  62002. * Gets the xyzw component (input)
  62003. */
  62004. get xyzw(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the xyz component (input)
  62007. */
  62008. get xyzIn(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the xy component (input)
  62011. */
  62012. get xyIn(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the xyz component (output)
  62015. */
  62016. get xyzOut(): NodeMaterialConnectionPoint;
  62017. /**
  62018. * Gets the xy component (output)
  62019. */
  62020. get xyOut(): NodeMaterialConnectionPoint;
  62021. /**
  62022. * Gets the x component (output)
  62023. */
  62024. get x(): NodeMaterialConnectionPoint;
  62025. /**
  62026. * Gets the y component (output)
  62027. */
  62028. get y(): NodeMaterialConnectionPoint;
  62029. /**
  62030. * Gets the z component (output)
  62031. */
  62032. get z(): NodeMaterialConnectionPoint;
  62033. /**
  62034. * Gets the w component (output)
  62035. */
  62036. get w(): NodeMaterialConnectionPoint;
  62037. protected _inputRename(name: string): string;
  62038. protected _outputRename(name: string): string;
  62039. protected _buildBlock(state: NodeMaterialBuildState): this;
  62040. }
  62041. }
  62042. declare module BABYLON {
  62043. /**
  62044. * Block used to lerp between 2 values
  62045. */
  62046. export class LerpBlock extends NodeMaterialBlock {
  62047. /**
  62048. * Creates a new LerpBlock
  62049. * @param name defines the block name
  62050. */
  62051. constructor(name: string);
  62052. /**
  62053. * Gets the current class name
  62054. * @returns the class name
  62055. */
  62056. getClassName(): string;
  62057. /**
  62058. * Gets the left operand input component
  62059. */
  62060. get left(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the right operand input component
  62063. */
  62064. get right(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the gradient operand input component
  62067. */
  62068. get gradient(): NodeMaterialConnectionPoint;
  62069. /**
  62070. * Gets the output component
  62071. */
  62072. get output(): NodeMaterialConnectionPoint;
  62073. protected _buildBlock(state: NodeMaterialBuildState): this;
  62074. }
  62075. }
  62076. declare module BABYLON {
  62077. /**
  62078. * Block used to divide 2 vectors
  62079. */
  62080. export class DivideBlock extends NodeMaterialBlock {
  62081. /**
  62082. * Creates a new DivideBlock
  62083. * @param name defines the block name
  62084. */
  62085. constructor(name: string);
  62086. /**
  62087. * Gets the current class name
  62088. * @returns the class name
  62089. */
  62090. getClassName(): string;
  62091. /**
  62092. * Gets the left operand input component
  62093. */
  62094. get left(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the right operand input component
  62097. */
  62098. get right(): NodeMaterialConnectionPoint;
  62099. /**
  62100. * Gets the output component
  62101. */
  62102. get output(): NodeMaterialConnectionPoint;
  62103. protected _buildBlock(state: NodeMaterialBuildState): this;
  62104. }
  62105. }
  62106. declare module BABYLON {
  62107. /**
  62108. * Block used to subtract 2 vectors
  62109. */
  62110. export class SubtractBlock extends NodeMaterialBlock {
  62111. /**
  62112. * Creates a new SubtractBlock
  62113. * @param name defines the block name
  62114. */
  62115. constructor(name: string);
  62116. /**
  62117. * Gets the current class name
  62118. * @returns the class name
  62119. */
  62120. getClassName(): string;
  62121. /**
  62122. * Gets the left operand input component
  62123. */
  62124. get left(): NodeMaterialConnectionPoint;
  62125. /**
  62126. * Gets the right operand input component
  62127. */
  62128. get right(): NodeMaterialConnectionPoint;
  62129. /**
  62130. * Gets the output component
  62131. */
  62132. get output(): NodeMaterialConnectionPoint;
  62133. protected _buildBlock(state: NodeMaterialBuildState): this;
  62134. }
  62135. }
  62136. declare module BABYLON {
  62137. /**
  62138. * Block used to step a value
  62139. */
  62140. export class StepBlock extends NodeMaterialBlock {
  62141. /**
  62142. * Creates a new StepBlock
  62143. * @param name defines the block name
  62144. */
  62145. constructor(name: string);
  62146. /**
  62147. * Gets the current class name
  62148. * @returns the class name
  62149. */
  62150. getClassName(): string;
  62151. /**
  62152. * Gets the value operand input component
  62153. */
  62154. get value(): NodeMaterialConnectionPoint;
  62155. /**
  62156. * Gets the edge operand input component
  62157. */
  62158. get edge(): NodeMaterialConnectionPoint;
  62159. /**
  62160. * Gets the output component
  62161. */
  62162. get output(): NodeMaterialConnectionPoint;
  62163. protected _buildBlock(state: NodeMaterialBuildState): this;
  62164. }
  62165. }
  62166. declare module BABYLON {
  62167. /**
  62168. * Block used to get the opposite (1 - x) of a value
  62169. */
  62170. export class OneMinusBlock extends NodeMaterialBlock {
  62171. /**
  62172. * Creates a new OneMinusBlock
  62173. * @param name defines the block name
  62174. */
  62175. constructor(name: string);
  62176. /**
  62177. * Gets the current class name
  62178. * @returns the class name
  62179. */
  62180. getClassName(): string;
  62181. /**
  62182. * Gets the input component
  62183. */
  62184. get input(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the output component
  62187. */
  62188. get output(): NodeMaterialConnectionPoint;
  62189. protected _buildBlock(state: NodeMaterialBuildState): this;
  62190. }
  62191. }
  62192. declare module BABYLON {
  62193. /**
  62194. * Block used to get the view direction
  62195. */
  62196. export class ViewDirectionBlock extends NodeMaterialBlock {
  62197. /**
  62198. * Creates a new ViewDirectionBlock
  62199. * @param name defines the block name
  62200. */
  62201. constructor(name: string);
  62202. /**
  62203. * Gets the current class name
  62204. * @returns the class name
  62205. */
  62206. getClassName(): string;
  62207. /**
  62208. * Gets the world position component
  62209. */
  62210. get worldPosition(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the camera position component
  62213. */
  62214. get cameraPosition(): NodeMaterialConnectionPoint;
  62215. /**
  62216. * Gets the output component
  62217. */
  62218. get output(): NodeMaterialConnectionPoint;
  62219. autoConfigure(material: NodeMaterial): void;
  62220. protected _buildBlock(state: NodeMaterialBuildState): this;
  62221. }
  62222. }
  62223. declare module BABYLON {
  62224. /**
  62225. * Block used to compute fresnel value
  62226. */
  62227. export class FresnelBlock extends NodeMaterialBlock {
  62228. /**
  62229. * Create a new FresnelBlock
  62230. * @param name defines the block name
  62231. */
  62232. constructor(name: string);
  62233. /**
  62234. * Gets the current class name
  62235. * @returns the class name
  62236. */
  62237. getClassName(): string;
  62238. /**
  62239. * Gets the world normal input component
  62240. */
  62241. get worldNormal(): NodeMaterialConnectionPoint;
  62242. /**
  62243. * Gets the view direction input component
  62244. */
  62245. get viewDirection(): NodeMaterialConnectionPoint;
  62246. /**
  62247. * Gets the bias input component
  62248. */
  62249. get bias(): NodeMaterialConnectionPoint;
  62250. /**
  62251. * Gets the camera (or eye) position component
  62252. */
  62253. get power(): NodeMaterialConnectionPoint;
  62254. /**
  62255. * Gets the fresnel output component
  62256. */
  62257. get fresnel(): NodeMaterialConnectionPoint;
  62258. autoConfigure(material: NodeMaterial): void;
  62259. protected _buildBlock(state: NodeMaterialBuildState): this;
  62260. }
  62261. }
  62262. declare module BABYLON {
  62263. /**
  62264. * Block used to get the max of 2 values
  62265. */
  62266. export class MaxBlock extends NodeMaterialBlock {
  62267. /**
  62268. * Creates a new MaxBlock
  62269. * @param name defines the block name
  62270. */
  62271. constructor(name: string);
  62272. /**
  62273. * Gets the current class name
  62274. * @returns the class name
  62275. */
  62276. getClassName(): string;
  62277. /**
  62278. * Gets the left operand input component
  62279. */
  62280. get left(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the right operand input component
  62283. */
  62284. get right(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the output component
  62287. */
  62288. get output(): NodeMaterialConnectionPoint;
  62289. protected _buildBlock(state: NodeMaterialBuildState): this;
  62290. }
  62291. }
  62292. declare module BABYLON {
  62293. /**
  62294. * Block used to get the min of 2 values
  62295. */
  62296. export class MinBlock extends NodeMaterialBlock {
  62297. /**
  62298. * Creates a new MinBlock
  62299. * @param name defines the block name
  62300. */
  62301. constructor(name: string);
  62302. /**
  62303. * Gets the current class name
  62304. * @returns the class name
  62305. */
  62306. getClassName(): string;
  62307. /**
  62308. * Gets the left operand input component
  62309. */
  62310. get left(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the right operand input component
  62313. */
  62314. get right(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the output component
  62317. */
  62318. get output(): NodeMaterialConnectionPoint;
  62319. protected _buildBlock(state: NodeMaterialBuildState): this;
  62320. }
  62321. }
  62322. declare module BABYLON {
  62323. /**
  62324. * Block used to get the distance between 2 values
  62325. */
  62326. export class DistanceBlock extends NodeMaterialBlock {
  62327. /**
  62328. * Creates a new DistanceBlock
  62329. * @param name defines the block name
  62330. */
  62331. constructor(name: string);
  62332. /**
  62333. * Gets the current class name
  62334. * @returns the class name
  62335. */
  62336. getClassName(): string;
  62337. /**
  62338. * Gets the left operand input component
  62339. */
  62340. get left(): NodeMaterialConnectionPoint;
  62341. /**
  62342. * Gets the right operand input component
  62343. */
  62344. get right(): NodeMaterialConnectionPoint;
  62345. /**
  62346. * Gets the output component
  62347. */
  62348. get output(): NodeMaterialConnectionPoint;
  62349. protected _buildBlock(state: NodeMaterialBuildState): this;
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. /**
  62354. * Block used to get the length of a vector
  62355. */
  62356. export class LengthBlock extends NodeMaterialBlock {
  62357. /**
  62358. * Creates a new LengthBlock
  62359. * @param name defines the block name
  62360. */
  62361. constructor(name: string);
  62362. /**
  62363. * Gets the current class name
  62364. * @returns the class name
  62365. */
  62366. getClassName(): string;
  62367. /**
  62368. * Gets the value input component
  62369. */
  62370. get value(): NodeMaterialConnectionPoint;
  62371. /**
  62372. * Gets the output component
  62373. */
  62374. get output(): NodeMaterialConnectionPoint;
  62375. protected _buildBlock(state: NodeMaterialBuildState): this;
  62376. }
  62377. }
  62378. declare module BABYLON {
  62379. /**
  62380. * Block used to get negative version of a value (i.e. x * -1)
  62381. */
  62382. export class NegateBlock extends NodeMaterialBlock {
  62383. /**
  62384. * Creates a new NegateBlock
  62385. * @param name defines the block name
  62386. */
  62387. constructor(name: string);
  62388. /**
  62389. * Gets the current class name
  62390. * @returns the class name
  62391. */
  62392. getClassName(): string;
  62393. /**
  62394. * Gets the value input component
  62395. */
  62396. get value(): NodeMaterialConnectionPoint;
  62397. /**
  62398. * Gets the output component
  62399. */
  62400. get output(): NodeMaterialConnectionPoint;
  62401. protected _buildBlock(state: NodeMaterialBuildState): this;
  62402. }
  62403. }
  62404. declare module BABYLON {
  62405. /**
  62406. * Block used to get the value of the first parameter raised to the power of the second
  62407. */
  62408. export class PowBlock extends NodeMaterialBlock {
  62409. /**
  62410. * Creates a new PowBlock
  62411. * @param name defines the block name
  62412. */
  62413. constructor(name: string);
  62414. /**
  62415. * Gets the current class name
  62416. * @returns the class name
  62417. */
  62418. getClassName(): string;
  62419. /**
  62420. * Gets the value operand input component
  62421. */
  62422. get value(): NodeMaterialConnectionPoint;
  62423. /**
  62424. * Gets the power operand input component
  62425. */
  62426. get power(): NodeMaterialConnectionPoint;
  62427. /**
  62428. * Gets the output component
  62429. */
  62430. get output(): NodeMaterialConnectionPoint;
  62431. protected _buildBlock(state: NodeMaterialBuildState): this;
  62432. }
  62433. }
  62434. declare module BABYLON {
  62435. /**
  62436. * Block used to get a random number
  62437. */
  62438. export class RandomNumberBlock extends NodeMaterialBlock {
  62439. /**
  62440. * Creates a new RandomNumberBlock
  62441. * @param name defines the block name
  62442. */
  62443. constructor(name: string);
  62444. /**
  62445. * Gets the current class name
  62446. * @returns the class name
  62447. */
  62448. getClassName(): string;
  62449. /**
  62450. * Gets the seed input component
  62451. */
  62452. get seed(): NodeMaterialConnectionPoint;
  62453. /**
  62454. * Gets the output component
  62455. */
  62456. get output(): NodeMaterialConnectionPoint;
  62457. protected _buildBlock(state: NodeMaterialBuildState): this;
  62458. }
  62459. }
  62460. declare module BABYLON {
  62461. /**
  62462. * Block used to compute arc tangent of 2 values
  62463. */
  62464. export class ArcTan2Block extends NodeMaterialBlock {
  62465. /**
  62466. * Creates a new ArcTan2Block
  62467. * @param name defines the block name
  62468. */
  62469. constructor(name: string);
  62470. /**
  62471. * Gets the current class name
  62472. * @returns the class name
  62473. */
  62474. getClassName(): string;
  62475. /**
  62476. * Gets the x operand input component
  62477. */
  62478. get x(): NodeMaterialConnectionPoint;
  62479. /**
  62480. * Gets the y operand input component
  62481. */
  62482. get y(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the output component
  62485. */
  62486. get output(): NodeMaterialConnectionPoint;
  62487. protected _buildBlock(state: NodeMaterialBuildState): this;
  62488. }
  62489. }
  62490. declare module BABYLON {
  62491. /**
  62492. * Block used to smooth step a value
  62493. */
  62494. export class SmoothStepBlock extends NodeMaterialBlock {
  62495. /**
  62496. * Creates a new SmoothStepBlock
  62497. * @param name defines the block name
  62498. */
  62499. constructor(name: string);
  62500. /**
  62501. * Gets the current class name
  62502. * @returns the class name
  62503. */
  62504. getClassName(): string;
  62505. /**
  62506. * Gets the value operand input component
  62507. */
  62508. get value(): NodeMaterialConnectionPoint;
  62509. /**
  62510. * Gets the first edge operand input component
  62511. */
  62512. get edge0(): NodeMaterialConnectionPoint;
  62513. /**
  62514. * Gets the second edge operand input component
  62515. */
  62516. get edge1(): NodeMaterialConnectionPoint;
  62517. /**
  62518. * Gets the output component
  62519. */
  62520. get output(): NodeMaterialConnectionPoint;
  62521. protected _buildBlock(state: NodeMaterialBuildState): this;
  62522. }
  62523. }
  62524. declare module BABYLON {
  62525. /**
  62526. * Block used to get the reciprocal (1 / x) of a value
  62527. */
  62528. export class ReciprocalBlock extends NodeMaterialBlock {
  62529. /**
  62530. * Creates a new ReciprocalBlock
  62531. * @param name defines the block name
  62532. */
  62533. constructor(name: string);
  62534. /**
  62535. * Gets the current class name
  62536. * @returns the class name
  62537. */
  62538. getClassName(): string;
  62539. /**
  62540. * Gets the input component
  62541. */
  62542. get input(): NodeMaterialConnectionPoint;
  62543. /**
  62544. * Gets the output component
  62545. */
  62546. get output(): NodeMaterialConnectionPoint;
  62547. protected _buildBlock(state: NodeMaterialBuildState): this;
  62548. }
  62549. }
  62550. declare module BABYLON {
  62551. /**
  62552. * Block used to replace a color by another one
  62553. */
  62554. export class ReplaceColorBlock extends NodeMaterialBlock {
  62555. /**
  62556. * Creates a new ReplaceColorBlock
  62557. * @param name defines the block name
  62558. */
  62559. constructor(name: string);
  62560. /**
  62561. * Gets the current class name
  62562. * @returns the class name
  62563. */
  62564. getClassName(): string;
  62565. /**
  62566. * Gets the value input component
  62567. */
  62568. get value(): NodeMaterialConnectionPoint;
  62569. /**
  62570. * Gets the reference input component
  62571. */
  62572. get reference(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the distance input component
  62575. */
  62576. get distance(): NodeMaterialConnectionPoint;
  62577. /**
  62578. * Gets the replacement input component
  62579. */
  62580. get replacement(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the output component
  62583. */
  62584. get output(): NodeMaterialConnectionPoint;
  62585. protected _buildBlock(state: NodeMaterialBuildState): this;
  62586. }
  62587. }
  62588. declare module BABYLON {
  62589. /**
  62590. * Block used to posterize a value
  62591. * @see https://en.wikipedia.org/wiki/Posterization
  62592. */
  62593. export class PosterizeBlock extends NodeMaterialBlock {
  62594. /**
  62595. * Creates a new PosterizeBlock
  62596. * @param name defines the block name
  62597. */
  62598. constructor(name: string);
  62599. /**
  62600. * Gets the current class name
  62601. * @returns the class name
  62602. */
  62603. getClassName(): string;
  62604. /**
  62605. * Gets the value input component
  62606. */
  62607. get value(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the steps input component
  62610. */
  62611. get steps(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the output component
  62614. */
  62615. get output(): NodeMaterialConnectionPoint;
  62616. protected _buildBlock(state: NodeMaterialBuildState): this;
  62617. }
  62618. }
  62619. declare module BABYLON {
  62620. /**
  62621. * Operations supported by the Wave block
  62622. */
  62623. export enum WaveBlockKind {
  62624. /** SawTooth */
  62625. SawTooth = 0,
  62626. /** Square */
  62627. Square = 1,
  62628. /** Triangle */
  62629. Triangle = 2
  62630. }
  62631. /**
  62632. * Block used to apply wave operation to floats
  62633. */
  62634. export class WaveBlock extends NodeMaterialBlock {
  62635. /**
  62636. * Gets or sets the kibnd of wave to be applied by the block
  62637. */
  62638. kind: WaveBlockKind;
  62639. /**
  62640. * Creates a new WaveBlock
  62641. * @param name defines the block name
  62642. */
  62643. constructor(name: string);
  62644. /**
  62645. * Gets the current class name
  62646. * @returns the class name
  62647. */
  62648. getClassName(): string;
  62649. /**
  62650. * Gets the input component
  62651. */
  62652. get input(): NodeMaterialConnectionPoint;
  62653. /**
  62654. * Gets the output component
  62655. */
  62656. get output(): NodeMaterialConnectionPoint;
  62657. protected _buildBlock(state: NodeMaterialBuildState): this;
  62658. serialize(): any;
  62659. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62660. }
  62661. }
  62662. declare module BABYLON {
  62663. /**
  62664. * Class used to store a color step for the GradientBlock
  62665. */
  62666. export class GradientBlockColorStep {
  62667. /**
  62668. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62669. */
  62670. step: number;
  62671. /**
  62672. * Gets or sets the color associated with this step
  62673. */
  62674. color: Color3;
  62675. /**
  62676. * Creates a new GradientBlockColorStep
  62677. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62678. * @param color defines the color associated with this step
  62679. */
  62680. constructor(
  62681. /**
  62682. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62683. */
  62684. step: number,
  62685. /**
  62686. * Gets or sets the color associated with this step
  62687. */
  62688. color: Color3);
  62689. }
  62690. /**
  62691. * Block used to return a color from a gradient based on an input value between 0 and 1
  62692. */
  62693. export class GradientBlock extends NodeMaterialBlock {
  62694. /**
  62695. * Gets or sets the list of color steps
  62696. */
  62697. colorSteps: GradientBlockColorStep[];
  62698. /**
  62699. * Creates a new GradientBlock
  62700. * @param name defines the block name
  62701. */
  62702. constructor(name: string);
  62703. /**
  62704. * Gets the current class name
  62705. * @returns the class name
  62706. */
  62707. getClassName(): string;
  62708. /**
  62709. * Gets the gradient input component
  62710. */
  62711. get gradient(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the output component
  62714. */
  62715. get output(): NodeMaterialConnectionPoint;
  62716. private _writeColorConstant;
  62717. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62718. serialize(): any;
  62719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62720. protected _dumpPropertiesCode(): string;
  62721. }
  62722. }
  62723. declare module BABYLON {
  62724. /**
  62725. * Block used to normalize lerp between 2 values
  62726. */
  62727. export class NLerpBlock extends NodeMaterialBlock {
  62728. /**
  62729. * Creates a new NLerpBlock
  62730. * @param name defines the block name
  62731. */
  62732. constructor(name: string);
  62733. /**
  62734. * Gets the current class name
  62735. * @returns the class name
  62736. */
  62737. getClassName(): string;
  62738. /**
  62739. * Gets the left operand input component
  62740. */
  62741. get left(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the right operand input component
  62744. */
  62745. get right(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the gradient operand input component
  62748. */
  62749. get gradient(): NodeMaterialConnectionPoint;
  62750. /**
  62751. * Gets the output component
  62752. */
  62753. get output(): NodeMaterialConnectionPoint;
  62754. protected _buildBlock(state: NodeMaterialBuildState): this;
  62755. }
  62756. }
  62757. declare module BABYLON {
  62758. /**
  62759. * block used to Generate a Worley Noise 3D Noise Pattern
  62760. */
  62761. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62762. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62763. manhattanDistance: boolean;
  62764. /**
  62765. * Creates a new WorleyNoise3DBlock
  62766. * @param name defines the block name
  62767. */
  62768. constructor(name: string);
  62769. /**
  62770. * Gets the current class name
  62771. * @returns the class name
  62772. */
  62773. getClassName(): string;
  62774. /**
  62775. * Gets the seed input component
  62776. */
  62777. get seed(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the jitter input component
  62780. */
  62781. get jitter(): NodeMaterialConnectionPoint;
  62782. /**
  62783. * Gets the output component
  62784. */
  62785. get output(): NodeMaterialConnectionPoint;
  62786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62787. /**
  62788. * Exposes the properties to the UI?
  62789. */
  62790. protected _dumpPropertiesCode(): string;
  62791. /**
  62792. * Exposes the properties to the Seralize?
  62793. */
  62794. serialize(): any;
  62795. /**
  62796. * Exposes the properties to the deseralize?
  62797. */
  62798. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62799. }
  62800. }
  62801. declare module BABYLON {
  62802. /**
  62803. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62804. */
  62805. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62806. /**
  62807. * Creates a new SimplexPerlin3DBlock
  62808. * @param name defines the block name
  62809. */
  62810. constructor(name: string);
  62811. /**
  62812. * Gets the current class name
  62813. * @returns the class name
  62814. */
  62815. getClassName(): string;
  62816. /**
  62817. * Gets the seed operand input component
  62818. */
  62819. get seed(): NodeMaterialConnectionPoint;
  62820. /**
  62821. * Gets the output component
  62822. */
  62823. get output(): NodeMaterialConnectionPoint;
  62824. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62825. }
  62826. }
  62827. declare module BABYLON {
  62828. /**
  62829. * Block used to blend normals
  62830. */
  62831. export class NormalBlendBlock extends NodeMaterialBlock {
  62832. /**
  62833. * Creates a new NormalBlendBlock
  62834. * @param name defines the block name
  62835. */
  62836. constructor(name: string);
  62837. /**
  62838. * Gets the current class name
  62839. * @returns the class name
  62840. */
  62841. getClassName(): string;
  62842. /**
  62843. * Gets the first input component
  62844. */
  62845. get normalMap0(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the second input component
  62848. */
  62849. get normalMap1(): NodeMaterialConnectionPoint;
  62850. /**
  62851. * Gets the output component
  62852. */
  62853. get output(): NodeMaterialConnectionPoint;
  62854. protected _buildBlock(state: NodeMaterialBuildState): this;
  62855. }
  62856. }
  62857. declare module BABYLON {
  62858. /**
  62859. * Block used to rotate a 2d vector by a given angle
  62860. */
  62861. export class Rotate2dBlock extends NodeMaterialBlock {
  62862. /**
  62863. * Creates a new Rotate2dBlock
  62864. * @param name defines the block name
  62865. */
  62866. constructor(name: string);
  62867. /**
  62868. * Gets the current class name
  62869. * @returns the class name
  62870. */
  62871. getClassName(): string;
  62872. /**
  62873. * Gets the input vector
  62874. */
  62875. get input(): NodeMaterialConnectionPoint;
  62876. /**
  62877. * Gets the input angle
  62878. */
  62879. get angle(): NodeMaterialConnectionPoint;
  62880. /**
  62881. * Gets the output component
  62882. */
  62883. get output(): NodeMaterialConnectionPoint;
  62884. autoConfigure(material: NodeMaterial): void;
  62885. protected _buildBlock(state: NodeMaterialBuildState): this;
  62886. }
  62887. }
  62888. declare module BABYLON {
  62889. /**
  62890. * Block used to get the reflected vector from a direction and a normal
  62891. */
  62892. export class ReflectBlock extends NodeMaterialBlock {
  62893. /**
  62894. * Creates a new ReflectBlock
  62895. * @param name defines the block name
  62896. */
  62897. constructor(name: string);
  62898. /**
  62899. * Gets the current class name
  62900. * @returns the class name
  62901. */
  62902. getClassName(): string;
  62903. /**
  62904. * Gets the incident component
  62905. */
  62906. get incident(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the normal component
  62909. */
  62910. get normal(): NodeMaterialConnectionPoint;
  62911. /**
  62912. * Gets the output component
  62913. */
  62914. get output(): NodeMaterialConnectionPoint;
  62915. protected _buildBlock(state: NodeMaterialBuildState): this;
  62916. }
  62917. }
  62918. declare module BABYLON {
  62919. /**
  62920. * Block used to get the refracted vector from a direction and a normal
  62921. */
  62922. export class RefractBlock extends NodeMaterialBlock {
  62923. /**
  62924. * Creates a new RefractBlock
  62925. * @param name defines the block name
  62926. */
  62927. constructor(name: string);
  62928. /**
  62929. * Gets the current class name
  62930. * @returns the class name
  62931. */
  62932. getClassName(): string;
  62933. /**
  62934. * Gets the incident component
  62935. */
  62936. get incident(): NodeMaterialConnectionPoint;
  62937. /**
  62938. * Gets the normal component
  62939. */
  62940. get normal(): NodeMaterialConnectionPoint;
  62941. /**
  62942. * Gets the index of refraction component
  62943. */
  62944. get ior(): NodeMaterialConnectionPoint;
  62945. /**
  62946. * Gets the output component
  62947. */
  62948. get output(): NodeMaterialConnectionPoint;
  62949. protected _buildBlock(state: NodeMaterialBuildState): this;
  62950. }
  62951. }
  62952. declare module BABYLON {
  62953. /**
  62954. * Block used to desaturate a color
  62955. */
  62956. export class DesaturateBlock extends NodeMaterialBlock {
  62957. /**
  62958. * Creates a new DesaturateBlock
  62959. * @param name defines the block name
  62960. */
  62961. constructor(name: string);
  62962. /**
  62963. * Gets the current class name
  62964. * @returns the class name
  62965. */
  62966. getClassName(): string;
  62967. /**
  62968. * Gets the color operand input component
  62969. */
  62970. get color(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the level operand input component
  62973. */
  62974. get level(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the output component
  62977. */
  62978. get output(): NodeMaterialConnectionPoint;
  62979. protected _buildBlock(state: NodeMaterialBuildState): this;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * Block used to implement the ambient occlusion module of the PBR material
  62985. */
  62986. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62987. /**
  62988. * Create a new AmbientOcclusionBlock
  62989. * @param name defines the block name
  62990. */
  62991. constructor(name: string);
  62992. /**
  62993. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62994. */
  62995. useAmbientInGrayScale: boolean;
  62996. /**
  62997. * Initialize the block and prepare the context for build
  62998. * @param state defines the state that will be used for the build
  62999. */
  63000. initialize(state: NodeMaterialBuildState): void;
  63001. /**
  63002. * Gets the current class name
  63003. * @returns the class name
  63004. */
  63005. getClassName(): string;
  63006. /**
  63007. * Gets the texture input component
  63008. */
  63009. get texture(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the texture intensity component
  63012. */
  63013. get intensity(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the direct light intensity input component
  63016. */
  63017. get directLightIntensity(): NodeMaterialConnectionPoint;
  63018. /**
  63019. * Gets the ambient occlusion object output component
  63020. */
  63021. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the main code of the block (fragment side)
  63024. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63025. * @returns the shader code
  63026. */
  63027. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63029. protected _buildBlock(state: NodeMaterialBuildState): this;
  63030. protected _dumpPropertiesCode(): string;
  63031. serialize(): any;
  63032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63033. }
  63034. }
  63035. declare module BABYLON {
  63036. /**
  63037. * Block used to implement the reflection module of the PBR material
  63038. */
  63039. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63040. /** @hidden */
  63041. _defineLODReflectionAlpha: string;
  63042. /** @hidden */
  63043. _defineLinearSpecularReflection: string;
  63044. private _vEnvironmentIrradianceName;
  63045. /** @hidden */
  63046. _vReflectionMicrosurfaceInfosName: string;
  63047. /** @hidden */
  63048. _vReflectionInfosName: string;
  63049. /** @hidden */
  63050. _vReflectionFilteringInfoName: string;
  63051. private _scene;
  63052. /**
  63053. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63054. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63055. * It's less burden on the user side in the editor part.
  63056. */
  63057. /** @hidden */
  63058. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63059. /** @hidden */
  63060. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63061. /** @hidden */
  63062. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63063. /**
  63064. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63065. * diffuse part of the IBL.
  63066. */
  63067. useSphericalHarmonics: boolean;
  63068. /**
  63069. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63070. */
  63071. forceIrradianceInFragment: boolean;
  63072. /**
  63073. * Create a new ReflectionBlock
  63074. * @param name defines the block name
  63075. */
  63076. constructor(name: string);
  63077. /**
  63078. * Gets the current class name
  63079. * @returns the class name
  63080. */
  63081. getClassName(): string;
  63082. /**
  63083. * Gets the position input component
  63084. */
  63085. get position(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the world position input component
  63088. */
  63089. get worldPosition(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the world normal input component
  63092. */
  63093. get worldNormal(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the world input component
  63096. */
  63097. get world(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the camera (or eye) position component
  63100. */
  63101. get cameraPosition(): NodeMaterialConnectionPoint;
  63102. /**
  63103. * Gets the view input component
  63104. */
  63105. get view(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Gets the color input component
  63108. */
  63109. get color(): NodeMaterialConnectionPoint;
  63110. /**
  63111. * Gets the reflection object output component
  63112. */
  63113. get reflection(): NodeMaterialConnectionPoint;
  63114. /**
  63115. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63116. */
  63117. get hasTexture(): boolean;
  63118. /**
  63119. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63120. */
  63121. get reflectionColor(): string;
  63122. protected _getTexture(): Nullable<BaseTexture>;
  63123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63125. /**
  63126. * Gets the code to inject in the vertex shader
  63127. * @param state current state of the node material building
  63128. * @returns the shader code
  63129. */
  63130. handleVertexSide(state: NodeMaterialBuildState): string;
  63131. /**
  63132. * Gets the main code of the block (fragment side)
  63133. * @param state current state of the node material building
  63134. * @param normalVarName name of the existing variable corresponding to the normal
  63135. * @returns the shader code
  63136. */
  63137. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63138. protected _buildBlock(state: NodeMaterialBuildState): this;
  63139. protected _dumpPropertiesCode(): string;
  63140. serialize(): any;
  63141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63142. }
  63143. }
  63144. declare module BABYLON {
  63145. /**
  63146. * Block used to implement the sheen module of the PBR material
  63147. */
  63148. export class SheenBlock extends NodeMaterialBlock {
  63149. /**
  63150. * Create a new SheenBlock
  63151. * @param name defines the block name
  63152. */
  63153. constructor(name: string);
  63154. /**
  63155. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63156. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63157. * making it easier to setup and tweak the effect
  63158. */
  63159. albedoScaling: boolean;
  63160. /**
  63161. * Defines if the sheen is linked to the sheen color.
  63162. */
  63163. linkSheenWithAlbedo: boolean;
  63164. /**
  63165. * Initialize the block and prepare the context for build
  63166. * @param state defines the state that will be used for the build
  63167. */
  63168. initialize(state: NodeMaterialBuildState): void;
  63169. /**
  63170. * Gets the current class name
  63171. * @returns the class name
  63172. */
  63173. getClassName(): string;
  63174. /**
  63175. * Gets the intensity input component
  63176. */
  63177. get intensity(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the color input component
  63180. */
  63181. get color(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the roughness input component
  63184. */
  63185. get roughness(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the sheen object output component
  63188. */
  63189. get sheen(): NodeMaterialConnectionPoint;
  63190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63191. /**
  63192. * Gets the main code of the block (fragment side)
  63193. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63194. * @returns the shader code
  63195. */
  63196. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63197. protected _buildBlock(state: NodeMaterialBuildState): this;
  63198. protected _dumpPropertiesCode(): string;
  63199. serialize(): any;
  63200. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63201. }
  63202. }
  63203. declare module BABYLON {
  63204. /**
  63205. * Block used to implement the reflectivity module of the PBR material
  63206. */
  63207. export class ReflectivityBlock extends NodeMaterialBlock {
  63208. private _metallicReflectanceColor;
  63209. private _metallicF0Factor;
  63210. /** @hidden */
  63211. _vMetallicReflectanceFactorsName: string;
  63212. /**
  63213. * The property below is set by the main PBR block prior to calling methods of this class.
  63214. */
  63215. /** @hidden */
  63216. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63217. /**
  63218. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63219. */
  63220. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63221. /**
  63222. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63223. */
  63224. useMetallnessFromMetallicTextureBlue: boolean;
  63225. /**
  63226. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63227. */
  63228. useRoughnessFromMetallicTextureAlpha: boolean;
  63229. /**
  63230. * Specifies if the metallic texture contains the roughness information in its green channel.
  63231. */
  63232. useRoughnessFromMetallicTextureGreen: boolean;
  63233. /**
  63234. * Create a new ReflectivityBlock
  63235. * @param name defines the block name
  63236. */
  63237. constructor(name: string);
  63238. /**
  63239. * Initialize the block and prepare the context for build
  63240. * @param state defines the state that will be used for the build
  63241. */
  63242. initialize(state: NodeMaterialBuildState): void;
  63243. /**
  63244. * Gets the current class name
  63245. * @returns the class name
  63246. */
  63247. getClassName(): string;
  63248. /**
  63249. * Gets the metallic input component
  63250. */
  63251. get metallic(): NodeMaterialConnectionPoint;
  63252. /**
  63253. * Gets the roughness input component
  63254. */
  63255. get roughness(): NodeMaterialConnectionPoint;
  63256. /**
  63257. * Gets the texture input component
  63258. */
  63259. get texture(): NodeMaterialConnectionPoint;
  63260. /**
  63261. * Gets the reflectivity object output component
  63262. */
  63263. get reflectivity(): NodeMaterialConnectionPoint;
  63264. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63265. /**
  63266. * Gets the main code of the block (fragment side)
  63267. * @param state current state of the node material building
  63268. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63269. * @returns the shader code
  63270. */
  63271. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63273. protected _buildBlock(state: NodeMaterialBuildState): this;
  63274. protected _dumpPropertiesCode(): string;
  63275. serialize(): any;
  63276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63277. }
  63278. }
  63279. declare module BABYLON {
  63280. /**
  63281. * Block used to implement the anisotropy module of the PBR material
  63282. */
  63283. export class AnisotropyBlock extends NodeMaterialBlock {
  63284. /**
  63285. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63286. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63287. * It's less burden on the user side in the editor part.
  63288. */
  63289. /** @hidden */
  63290. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63291. /** @hidden */
  63292. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63293. /**
  63294. * Create a new AnisotropyBlock
  63295. * @param name defines the block name
  63296. */
  63297. constructor(name: string);
  63298. /**
  63299. * Initialize the block and prepare the context for build
  63300. * @param state defines the state that will be used for the build
  63301. */
  63302. initialize(state: NodeMaterialBuildState): void;
  63303. /**
  63304. * Gets the current class name
  63305. * @returns the class name
  63306. */
  63307. getClassName(): string;
  63308. /**
  63309. * Gets the intensity input component
  63310. */
  63311. get intensity(): NodeMaterialConnectionPoint;
  63312. /**
  63313. * Gets the direction input component
  63314. */
  63315. get direction(): NodeMaterialConnectionPoint;
  63316. /**
  63317. * Gets the texture input component
  63318. */
  63319. get texture(): NodeMaterialConnectionPoint;
  63320. /**
  63321. * Gets the uv input component
  63322. */
  63323. get uv(): NodeMaterialConnectionPoint;
  63324. /**
  63325. * Gets the worldTangent input component
  63326. */
  63327. get worldTangent(): NodeMaterialConnectionPoint;
  63328. /**
  63329. * Gets the anisotropy object output component
  63330. */
  63331. get anisotropy(): NodeMaterialConnectionPoint;
  63332. private _generateTBNSpace;
  63333. /**
  63334. * Gets the main code of the block (fragment side)
  63335. * @param state current state of the node material building
  63336. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63337. * @returns the shader code
  63338. */
  63339. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63340. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63341. protected _buildBlock(state: NodeMaterialBuildState): this;
  63342. }
  63343. }
  63344. declare module BABYLON {
  63345. /**
  63346. * Block used to implement the clear coat module of the PBR material
  63347. */
  63348. export class ClearCoatBlock extends NodeMaterialBlock {
  63349. private _scene;
  63350. /**
  63351. * Create a new ClearCoatBlock
  63352. * @param name defines the block name
  63353. */
  63354. constructor(name: string);
  63355. /**
  63356. * Initialize the block and prepare the context for build
  63357. * @param state defines the state that will be used for the build
  63358. */
  63359. initialize(state: NodeMaterialBuildState): void;
  63360. /**
  63361. * Gets the current class name
  63362. * @returns the class name
  63363. */
  63364. getClassName(): string;
  63365. /**
  63366. * Gets the intensity input component
  63367. */
  63368. get intensity(): NodeMaterialConnectionPoint;
  63369. /**
  63370. * Gets the roughness input component
  63371. */
  63372. get roughness(): NodeMaterialConnectionPoint;
  63373. /**
  63374. * Gets the ior input component
  63375. */
  63376. get ior(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the texture input component
  63379. */
  63380. get texture(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the bump texture input component
  63383. */
  63384. get bumpTexture(): NodeMaterialConnectionPoint;
  63385. /**
  63386. * Gets the uv input component
  63387. */
  63388. get uv(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the tint color input component
  63391. */
  63392. get tintColor(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the tint "at distance" input component
  63395. */
  63396. get tintAtDistance(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the tint thickness input component
  63399. */
  63400. get tintThickness(): NodeMaterialConnectionPoint;
  63401. /**
  63402. * Gets the world tangent input component
  63403. */
  63404. get worldTangent(): NodeMaterialConnectionPoint;
  63405. /**
  63406. * Gets the clear coat object output component
  63407. */
  63408. get clearcoat(): NodeMaterialConnectionPoint;
  63409. autoConfigure(material: NodeMaterial): void;
  63410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63412. private _generateTBNSpace;
  63413. /**
  63414. * Gets the main code of the block (fragment side)
  63415. * @param state current state of the node material building
  63416. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63417. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63418. * @param worldPosVarName name of the variable holding the world position
  63419. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63420. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63421. * @param worldNormalVarName name of the variable holding the world normal
  63422. * @returns the shader code
  63423. */
  63424. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63425. protected _buildBlock(state: NodeMaterialBuildState): this;
  63426. }
  63427. }
  63428. declare module BABYLON {
  63429. /**
  63430. * Block used to implement the sub surface module of the PBR material
  63431. */
  63432. export class SubSurfaceBlock extends NodeMaterialBlock {
  63433. /**
  63434. * Create a new SubSurfaceBlock
  63435. * @param name defines the block name
  63436. */
  63437. constructor(name: string);
  63438. /**
  63439. * Stores the intensity of the different subsurface effects in the thickness texture.
  63440. * * the green channel is the translucency intensity.
  63441. * * the blue channel is the scattering intensity.
  63442. * * the alpha channel is the refraction intensity.
  63443. */
  63444. useMaskFromThicknessTexture: boolean;
  63445. /**
  63446. * Initialize the block and prepare the context for build
  63447. * @param state defines the state that will be used for the build
  63448. */
  63449. initialize(state: NodeMaterialBuildState): void;
  63450. /**
  63451. * Gets the current class name
  63452. * @returns the class name
  63453. */
  63454. getClassName(): string;
  63455. /**
  63456. * Gets the min thickness input component
  63457. */
  63458. get minThickness(): NodeMaterialConnectionPoint;
  63459. /**
  63460. * Gets the max thickness input component
  63461. */
  63462. get maxThickness(): NodeMaterialConnectionPoint;
  63463. /**
  63464. * Gets the thickness texture component
  63465. */
  63466. get thicknessTexture(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the tint color input component
  63469. */
  63470. get tintColor(): NodeMaterialConnectionPoint;
  63471. /**
  63472. * Gets the translucency intensity input component
  63473. */
  63474. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63475. /**
  63476. * Gets the translucency diffusion distance input component
  63477. */
  63478. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the refraction object parameters
  63481. */
  63482. get refraction(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the sub surface object output component
  63485. */
  63486. get subsurface(): NodeMaterialConnectionPoint;
  63487. autoConfigure(material: NodeMaterial): void;
  63488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63489. /**
  63490. * Gets the main code of the block (fragment side)
  63491. * @param state current state of the node material building
  63492. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63493. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63494. * @param worldPosVarName name of the variable holding the world position
  63495. * @returns the shader code
  63496. */
  63497. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63498. protected _buildBlock(state: NodeMaterialBuildState): this;
  63499. }
  63500. }
  63501. declare module BABYLON {
  63502. /**
  63503. * Block used to implement the PBR metallic/roughness model
  63504. */
  63505. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63506. /**
  63507. * Gets or sets the light associated with this block
  63508. */
  63509. light: Nullable<Light>;
  63510. private _lightId;
  63511. private _scene;
  63512. private _environmentBRDFTexture;
  63513. private _environmentBrdfSamplerName;
  63514. private _vNormalWName;
  63515. private _invertNormalName;
  63516. /**
  63517. * Create a new ReflectionBlock
  63518. * @param name defines the block name
  63519. */
  63520. constructor(name: string);
  63521. /**
  63522. * Intensity of the direct lights e.g. the four lights available in your scene.
  63523. * This impacts both the direct diffuse and specular highlights.
  63524. */
  63525. directIntensity: number;
  63526. /**
  63527. * Intensity of the environment e.g. how much the environment will light the object
  63528. * either through harmonics for rough material or through the refelction for shiny ones.
  63529. */
  63530. environmentIntensity: number;
  63531. /**
  63532. * This is a special control allowing the reduction of the specular highlights coming from the
  63533. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63534. */
  63535. specularIntensity: number;
  63536. /**
  63537. * Defines the falloff type used in this material.
  63538. * It by default is Physical.
  63539. */
  63540. lightFalloff: number;
  63541. /**
  63542. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63543. */
  63544. useAlphaFromAlbedoTexture: boolean;
  63545. /**
  63546. * Specifies that alpha test should be used
  63547. */
  63548. useAlphaTest: boolean;
  63549. /**
  63550. * Defines the alpha limits in alpha test mode.
  63551. */
  63552. alphaTestCutoff: number;
  63553. /**
  63554. * Specifies that alpha blending should be used
  63555. */
  63556. useAlphaBlending: boolean;
  63557. /**
  63558. * Defines if the alpha value should be determined via the rgb values.
  63559. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63560. */
  63561. opacityRGB: boolean;
  63562. /**
  63563. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63564. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63565. */
  63566. useRadianceOverAlpha: boolean;
  63567. /**
  63568. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63569. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63570. */
  63571. useSpecularOverAlpha: boolean;
  63572. /**
  63573. * Enables specular anti aliasing in the PBR shader.
  63574. * It will both interacts on the Geometry for analytical and IBL lighting.
  63575. * It also prefilter the roughness map based on the bump values.
  63576. */
  63577. enableSpecularAntiAliasing: boolean;
  63578. /**
  63579. * Enables realtime filtering on the texture.
  63580. */
  63581. realTimeFiltering: boolean;
  63582. /**
  63583. * Quality switch for realtime filtering
  63584. */
  63585. realTimeFilteringQuality: number;
  63586. /**
  63587. * Defines if the material uses energy conservation.
  63588. */
  63589. useEnergyConservation: boolean;
  63590. /**
  63591. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63592. * too much the area relying on ambient texture to define their ambient occlusion.
  63593. */
  63594. useRadianceOcclusion: boolean;
  63595. /**
  63596. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63597. * makes the reflect vector face the model (under horizon).
  63598. */
  63599. useHorizonOcclusion: boolean;
  63600. /**
  63601. * If set to true, no lighting calculations will be applied.
  63602. */
  63603. unlit: boolean;
  63604. /**
  63605. * Force normal to face away from face.
  63606. */
  63607. forceNormalForward: boolean;
  63608. /**
  63609. * Defines the material debug mode.
  63610. * It helps seeing only some components of the material while troubleshooting.
  63611. */
  63612. debugMode: number;
  63613. /**
  63614. * Specify from where on screen the debug mode should start.
  63615. * The value goes from -1 (full screen) to 1 (not visible)
  63616. * It helps with side by side comparison against the final render
  63617. * This defaults to 0
  63618. */
  63619. debugLimit: number;
  63620. /**
  63621. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63622. * You can use the factor to better multiply the final value.
  63623. */
  63624. debugFactor: number;
  63625. /**
  63626. * Initialize the block and prepare the context for build
  63627. * @param state defines the state that will be used for the build
  63628. */
  63629. initialize(state: NodeMaterialBuildState): void;
  63630. /**
  63631. * Gets the current class name
  63632. * @returns the class name
  63633. */
  63634. getClassName(): string;
  63635. /**
  63636. * Gets the world position input component
  63637. */
  63638. get worldPosition(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the world normal input component
  63641. */
  63642. get worldNormal(): NodeMaterialConnectionPoint;
  63643. /**
  63644. * Gets the perturbed normal input component
  63645. */
  63646. get perturbedNormal(): NodeMaterialConnectionPoint;
  63647. /**
  63648. * Gets the camera position input component
  63649. */
  63650. get cameraPosition(): NodeMaterialConnectionPoint;
  63651. /**
  63652. * Gets the base color input component
  63653. */
  63654. get baseColor(): NodeMaterialConnectionPoint;
  63655. /**
  63656. * Gets the opacity texture input component
  63657. */
  63658. get opacityTexture(): NodeMaterialConnectionPoint;
  63659. /**
  63660. * Gets the ambient color input component
  63661. */
  63662. get ambientColor(): NodeMaterialConnectionPoint;
  63663. /**
  63664. * Gets the reflectivity object parameters
  63665. */
  63666. get reflectivity(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the ambient occlusion object parameters
  63669. */
  63670. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63671. /**
  63672. * Gets the reflection object parameters
  63673. */
  63674. get reflection(): NodeMaterialConnectionPoint;
  63675. /**
  63676. * Gets the sheen object parameters
  63677. */
  63678. get sheen(): NodeMaterialConnectionPoint;
  63679. /**
  63680. * Gets the clear coat object parameters
  63681. */
  63682. get clearcoat(): NodeMaterialConnectionPoint;
  63683. /**
  63684. * Gets the sub surface object parameters
  63685. */
  63686. get subsurface(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the anisotropy object parameters
  63689. */
  63690. get anisotropy(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the ambient output component
  63693. */
  63694. get ambient(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the diffuse output component
  63697. */
  63698. get diffuse(): NodeMaterialConnectionPoint;
  63699. /**
  63700. * Gets the specular output component
  63701. */
  63702. get specular(): NodeMaterialConnectionPoint;
  63703. /**
  63704. * Gets the sheen output component
  63705. */
  63706. get sheenDir(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Gets the clear coat output component
  63709. */
  63710. get clearcoatDir(): NodeMaterialConnectionPoint;
  63711. /**
  63712. * Gets the indirect diffuse output component
  63713. */
  63714. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63715. /**
  63716. * Gets the indirect specular output component
  63717. */
  63718. get specularIndirect(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the indirect sheen output component
  63721. */
  63722. get sheenIndirect(): NodeMaterialConnectionPoint;
  63723. /**
  63724. * Gets the indirect clear coat output component
  63725. */
  63726. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the refraction output component
  63729. */
  63730. get refraction(): NodeMaterialConnectionPoint;
  63731. /**
  63732. * Gets the global lighting output component
  63733. */
  63734. get lighting(): NodeMaterialConnectionPoint;
  63735. /**
  63736. * Gets the shadow output component
  63737. */
  63738. get shadow(): NodeMaterialConnectionPoint;
  63739. /**
  63740. * Gets the alpha output component
  63741. */
  63742. get alpha(): NodeMaterialConnectionPoint;
  63743. autoConfigure(material: NodeMaterial): void;
  63744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63745. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63747. private _injectVertexCode;
  63748. /**
  63749. * Gets the code corresponding to the albedo/opacity module
  63750. * @returns the shader code
  63751. */
  63752. getAlbedoOpacityCode(): string;
  63753. protected _buildBlock(state: NodeMaterialBuildState): this;
  63754. protected _dumpPropertiesCode(): string;
  63755. serialize(): any;
  63756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63757. }
  63758. }
  63759. declare module BABYLON {
  63760. /**
  63761. * Block used to compute value of one parameter modulo another
  63762. */
  63763. export class ModBlock extends NodeMaterialBlock {
  63764. /**
  63765. * Creates a new ModBlock
  63766. * @param name defines the block name
  63767. */
  63768. constructor(name: string);
  63769. /**
  63770. * Gets the current class name
  63771. * @returns the class name
  63772. */
  63773. getClassName(): string;
  63774. /**
  63775. * Gets the left operand input component
  63776. */
  63777. get left(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Gets the right operand input component
  63780. */
  63781. get right(): NodeMaterialConnectionPoint;
  63782. /**
  63783. * Gets the output component
  63784. */
  63785. get output(): NodeMaterialConnectionPoint;
  63786. protected _buildBlock(state: NodeMaterialBuildState): this;
  63787. }
  63788. }
  63789. declare module BABYLON {
  63790. /**
  63791. * Helper class to push actions to a pool of workers.
  63792. */
  63793. export class WorkerPool implements IDisposable {
  63794. private _workerInfos;
  63795. private _pendingActions;
  63796. /**
  63797. * Constructor
  63798. * @param workers Array of workers to use for actions
  63799. */
  63800. constructor(workers: Array<Worker>);
  63801. /**
  63802. * Terminates all workers and clears any pending actions.
  63803. */
  63804. dispose(): void;
  63805. /**
  63806. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63807. * pended until a worker has completed its action.
  63808. * @param action The action to perform. Call onComplete when the action is complete.
  63809. */
  63810. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63811. private _execute;
  63812. }
  63813. }
  63814. declare module BABYLON {
  63815. /**
  63816. * Configuration for Draco compression
  63817. */
  63818. export interface IDracoCompressionConfiguration {
  63819. /**
  63820. * Configuration for the decoder.
  63821. */
  63822. decoder: {
  63823. /**
  63824. * The url to the WebAssembly module.
  63825. */
  63826. wasmUrl?: string;
  63827. /**
  63828. * The url to the WebAssembly binary.
  63829. */
  63830. wasmBinaryUrl?: string;
  63831. /**
  63832. * The url to the fallback JavaScript module.
  63833. */
  63834. fallbackUrl?: string;
  63835. };
  63836. }
  63837. /**
  63838. * Draco compression (https://google.github.io/draco/)
  63839. *
  63840. * This class wraps the Draco module.
  63841. *
  63842. * **Encoder**
  63843. *
  63844. * The encoder is not currently implemented.
  63845. *
  63846. * **Decoder**
  63847. *
  63848. * 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.
  63849. *
  63850. * To update the configuration, use the following code:
  63851. * ```javascript
  63852. * DracoCompression.Configuration = {
  63853. * decoder: {
  63854. * wasmUrl: "<url to the WebAssembly library>",
  63855. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63856. * fallbackUrl: "<url to the fallback JavaScript library>",
  63857. * }
  63858. * };
  63859. * ```
  63860. *
  63861. * 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.
  63862. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63863. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63864. *
  63865. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63866. * ```javascript
  63867. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63868. * ```
  63869. *
  63870. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63871. */
  63872. export class DracoCompression implements IDisposable {
  63873. private _workerPoolPromise?;
  63874. private _decoderModulePromise?;
  63875. /**
  63876. * The configuration. Defaults to the following urls:
  63877. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63878. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63879. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63880. */
  63881. static Configuration: IDracoCompressionConfiguration;
  63882. /**
  63883. * Returns true if the decoder configuration is available.
  63884. */
  63885. static get DecoderAvailable(): boolean;
  63886. /**
  63887. * Default number of workers to create when creating the draco compression object.
  63888. */
  63889. static DefaultNumWorkers: number;
  63890. private static GetDefaultNumWorkers;
  63891. private static _Default;
  63892. /**
  63893. * Default instance for the draco compression object.
  63894. */
  63895. static get Default(): DracoCompression;
  63896. /**
  63897. * Constructor
  63898. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63899. */
  63900. constructor(numWorkers?: number);
  63901. /**
  63902. * Stop all async operations and release resources.
  63903. */
  63904. dispose(): void;
  63905. /**
  63906. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63907. * @returns a promise that resolves when ready
  63908. */
  63909. whenReadyAsync(): Promise<void>;
  63910. /**
  63911. * Decode Draco compressed mesh data to vertex data.
  63912. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63913. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63914. * @returns A promise that resolves with the decoded vertex data
  63915. */
  63916. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63917. [kind: string]: number;
  63918. }): Promise<VertexData>;
  63919. }
  63920. }
  63921. declare module BABYLON {
  63922. /**
  63923. * Class for building Constructive Solid Geometry
  63924. */
  63925. export class CSG {
  63926. private polygons;
  63927. /**
  63928. * The world matrix
  63929. */
  63930. matrix: Matrix;
  63931. /**
  63932. * Stores the position
  63933. */
  63934. position: Vector3;
  63935. /**
  63936. * Stores the rotation
  63937. */
  63938. rotation: Vector3;
  63939. /**
  63940. * Stores the rotation quaternion
  63941. */
  63942. rotationQuaternion: Nullable<Quaternion>;
  63943. /**
  63944. * Stores the scaling vector
  63945. */
  63946. scaling: Vector3;
  63947. /**
  63948. * Convert the Mesh to CSG
  63949. * @param mesh The Mesh to convert to CSG
  63950. * @returns A new CSG from the Mesh
  63951. */
  63952. static FromMesh(mesh: Mesh): CSG;
  63953. /**
  63954. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63955. * @param polygons Polygons used to construct a CSG solid
  63956. */
  63957. private static FromPolygons;
  63958. /**
  63959. * Clones, or makes a deep copy, of the CSG
  63960. * @returns A new CSG
  63961. */
  63962. clone(): CSG;
  63963. /**
  63964. * Unions this CSG with another CSG
  63965. * @param csg The CSG to union against this CSG
  63966. * @returns The unioned CSG
  63967. */
  63968. union(csg: CSG): CSG;
  63969. /**
  63970. * Unions this CSG with another CSG in place
  63971. * @param csg The CSG to union against this CSG
  63972. */
  63973. unionInPlace(csg: CSG): void;
  63974. /**
  63975. * Subtracts this CSG with another CSG
  63976. * @param csg The CSG to subtract against this CSG
  63977. * @returns A new CSG
  63978. */
  63979. subtract(csg: CSG): CSG;
  63980. /**
  63981. * Subtracts this CSG with another CSG in place
  63982. * @param csg The CSG to subtact against this CSG
  63983. */
  63984. subtractInPlace(csg: CSG): void;
  63985. /**
  63986. * Intersect this CSG with another CSG
  63987. * @param csg The CSG to intersect against this CSG
  63988. * @returns A new CSG
  63989. */
  63990. intersect(csg: CSG): CSG;
  63991. /**
  63992. * Intersects this CSG with another CSG in place
  63993. * @param csg The CSG to intersect against this CSG
  63994. */
  63995. intersectInPlace(csg: CSG): void;
  63996. /**
  63997. * Return a new CSG solid with solid and empty space switched. This solid is
  63998. * not modified.
  63999. * @returns A new CSG solid with solid and empty space switched
  64000. */
  64001. inverse(): CSG;
  64002. /**
  64003. * Inverses the CSG in place
  64004. */
  64005. inverseInPlace(): void;
  64006. /**
  64007. * This is used to keep meshes transformations so they can be restored
  64008. * when we build back a Babylon Mesh
  64009. * NB : All CSG operations are performed in world coordinates
  64010. * @param csg The CSG to copy the transform attributes from
  64011. * @returns This CSG
  64012. */
  64013. copyTransformAttributes(csg: CSG): CSG;
  64014. /**
  64015. * Build Raw mesh from CSG
  64016. * Coordinates here are in world space
  64017. * @param name The name of the mesh geometry
  64018. * @param scene The Scene
  64019. * @param keepSubMeshes Specifies if the submeshes should be kept
  64020. * @returns A new Mesh
  64021. */
  64022. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64023. /**
  64024. * Build Mesh from CSG taking material and transforms into account
  64025. * @param name The name of the Mesh
  64026. * @param material The material of the Mesh
  64027. * @param scene The Scene
  64028. * @param keepSubMeshes Specifies if submeshes should be kept
  64029. * @returns The new Mesh
  64030. */
  64031. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64032. }
  64033. }
  64034. declare module BABYLON {
  64035. /**
  64036. * Class used to create a trail following a mesh
  64037. */
  64038. export class TrailMesh extends Mesh {
  64039. private _generator;
  64040. private _autoStart;
  64041. private _running;
  64042. private _diameter;
  64043. private _length;
  64044. private _sectionPolygonPointsCount;
  64045. private _sectionVectors;
  64046. private _sectionNormalVectors;
  64047. private _beforeRenderObserver;
  64048. /**
  64049. * @constructor
  64050. * @param name The value used by scene.getMeshByName() to do a lookup.
  64051. * @param generator The mesh or transform node to generate a trail.
  64052. * @param scene The scene to add this mesh to.
  64053. * @param diameter Diameter of trailing mesh. Default is 1.
  64054. * @param length Length of trailing mesh. Default is 60.
  64055. * @param autoStart Automatically start trailing mesh. Default true.
  64056. */
  64057. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64058. /**
  64059. * "TrailMesh"
  64060. * @returns "TrailMesh"
  64061. */
  64062. getClassName(): string;
  64063. private _createMesh;
  64064. /**
  64065. * Start trailing mesh.
  64066. */
  64067. start(): void;
  64068. /**
  64069. * Stop trailing mesh.
  64070. */
  64071. stop(): void;
  64072. /**
  64073. * Update trailing mesh geometry.
  64074. */
  64075. update(): void;
  64076. /**
  64077. * Returns a new TrailMesh object.
  64078. * @param name is a string, the name given to the new mesh
  64079. * @param newGenerator use new generator object for cloned trail mesh
  64080. * @returns a new mesh
  64081. */
  64082. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64083. /**
  64084. * Serializes this trail mesh
  64085. * @param serializationObject object to write serialization to
  64086. */
  64087. serialize(serializationObject: any): void;
  64088. /**
  64089. * Parses a serialized trail mesh
  64090. * @param parsedMesh the serialized mesh
  64091. * @param scene the scene to create the trail mesh in
  64092. * @returns the created trail mesh
  64093. */
  64094. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * Class containing static functions to help procedurally build meshes
  64100. */
  64101. export class TiledBoxBuilder {
  64102. /**
  64103. * Creates a box mesh
  64104. * 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)
  64105. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64107. * * 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
  64108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64109. * @param name defines the name of the mesh
  64110. * @param options defines the options used to create the mesh
  64111. * @param scene defines the hosting scene
  64112. * @returns the box mesh
  64113. */
  64114. static CreateTiledBox(name: string, options: {
  64115. pattern?: number;
  64116. width?: number;
  64117. height?: number;
  64118. depth?: number;
  64119. tileSize?: number;
  64120. tileWidth?: number;
  64121. tileHeight?: number;
  64122. alignHorizontal?: number;
  64123. alignVertical?: number;
  64124. faceUV?: Vector4[];
  64125. faceColors?: Color4[];
  64126. sideOrientation?: number;
  64127. updatable?: boolean;
  64128. }, scene?: Nullable<Scene>): Mesh;
  64129. }
  64130. }
  64131. declare module BABYLON {
  64132. /**
  64133. * Class containing static functions to help procedurally build meshes
  64134. */
  64135. export class TorusKnotBuilder {
  64136. /**
  64137. * Creates a torus knot mesh
  64138. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64139. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64140. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64141. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64143. * * 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
  64144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64145. * @param name defines the name of the mesh
  64146. * @param options defines the options used to create the mesh
  64147. * @param scene defines the hosting scene
  64148. * @returns the torus knot mesh
  64149. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64150. */
  64151. static CreateTorusKnot(name: string, options: {
  64152. radius?: number;
  64153. tube?: number;
  64154. radialSegments?: number;
  64155. tubularSegments?: number;
  64156. p?: number;
  64157. q?: number;
  64158. updatable?: boolean;
  64159. sideOrientation?: number;
  64160. frontUVs?: Vector4;
  64161. backUVs?: Vector4;
  64162. }, scene: any): Mesh;
  64163. }
  64164. }
  64165. declare module BABYLON {
  64166. /**
  64167. * Polygon
  64168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64169. */
  64170. export class Polygon {
  64171. /**
  64172. * Creates a rectangle
  64173. * @param xmin bottom X coord
  64174. * @param ymin bottom Y coord
  64175. * @param xmax top X coord
  64176. * @param ymax top Y coord
  64177. * @returns points that make the resulting rectation
  64178. */
  64179. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64180. /**
  64181. * Creates a circle
  64182. * @param radius radius of circle
  64183. * @param cx scale in x
  64184. * @param cy scale in y
  64185. * @param numberOfSides number of sides that make up the circle
  64186. * @returns points that make the resulting circle
  64187. */
  64188. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64189. /**
  64190. * Creates a polygon from input string
  64191. * @param input Input polygon data
  64192. * @returns the parsed points
  64193. */
  64194. static Parse(input: string): Vector2[];
  64195. /**
  64196. * Starts building a polygon from x and y coordinates
  64197. * @param x x coordinate
  64198. * @param y y coordinate
  64199. * @returns the started path2
  64200. */
  64201. static StartingAt(x: number, y: number): Path2;
  64202. }
  64203. /**
  64204. * Builds a polygon
  64205. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64206. */
  64207. export class PolygonMeshBuilder {
  64208. private _points;
  64209. private _outlinepoints;
  64210. private _holes;
  64211. private _name;
  64212. private _scene;
  64213. private _epoints;
  64214. private _eholes;
  64215. private _addToepoint;
  64216. /**
  64217. * Babylon reference to the earcut plugin.
  64218. */
  64219. bjsEarcut: any;
  64220. /**
  64221. * Creates a PolygonMeshBuilder
  64222. * @param name name of the builder
  64223. * @param contours Path of the polygon
  64224. * @param scene scene to add to when creating the mesh
  64225. * @param earcutInjection can be used to inject your own earcut reference
  64226. */
  64227. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64228. /**
  64229. * Adds a whole within the polygon
  64230. * @param hole Array of points defining the hole
  64231. * @returns this
  64232. */
  64233. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64234. /**
  64235. * Creates the polygon
  64236. * @param updatable If the mesh should be updatable
  64237. * @param depth The depth of the mesh created
  64238. * @returns the created mesh
  64239. */
  64240. build(updatable?: boolean, depth?: number): Mesh;
  64241. /**
  64242. * Creates the polygon
  64243. * @param depth The depth of the mesh created
  64244. * @returns the created VertexData
  64245. */
  64246. buildVertexData(depth?: number): VertexData;
  64247. /**
  64248. * Adds a side to the polygon
  64249. * @param positions points that make the polygon
  64250. * @param normals normals of the polygon
  64251. * @param uvs uvs of the polygon
  64252. * @param indices indices of the polygon
  64253. * @param bounds bounds of the polygon
  64254. * @param points points of the polygon
  64255. * @param depth depth of the polygon
  64256. * @param flip flip of the polygon
  64257. */
  64258. private addSide;
  64259. }
  64260. }
  64261. declare module BABYLON {
  64262. /**
  64263. * Class containing static functions to help procedurally build meshes
  64264. */
  64265. export class PolygonBuilder {
  64266. /**
  64267. * Creates a polygon mesh
  64268. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64269. * * 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
  64270. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64272. * * 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)
  64273. * * Remember you can only change the shape positions, not their number when updating a polygon
  64274. * @param name defines the name of the mesh
  64275. * @param options defines the options used to create the mesh
  64276. * @param scene defines the hosting scene
  64277. * @param earcutInjection can be used to inject your own earcut reference
  64278. * @returns the polygon mesh
  64279. */
  64280. static CreatePolygon(name: string, options: {
  64281. shape: Vector3[];
  64282. holes?: Vector3[][];
  64283. depth?: number;
  64284. faceUV?: Vector4[];
  64285. faceColors?: Color4[];
  64286. updatable?: boolean;
  64287. sideOrientation?: number;
  64288. frontUVs?: Vector4;
  64289. backUVs?: Vector4;
  64290. wrap?: boolean;
  64291. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64292. /**
  64293. * Creates an extruded polygon mesh, with depth in the Y direction.
  64294. * * 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)
  64295. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64296. * @param name defines the name of the mesh
  64297. * @param options defines the options used to create the mesh
  64298. * @param scene defines the hosting scene
  64299. * @param earcutInjection can be used to inject your own earcut reference
  64300. * @returns the polygon mesh
  64301. */
  64302. static ExtrudePolygon(name: string, options: {
  64303. shape: Vector3[];
  64304. holes?: Vector3[][];
  64305. depth?: number;
  64306. faceUV?: Vector4[];
  64307. faceColors?: Color4[];
  64308. updatable?: boolean;
  64309. sideOrientation?: number;
  64310. frontUVs?: Vector4;
  64311. backUVs?: Vector4;
  64312. wrap?: boolean;
  64313. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64314. }
  64315. }
  64316. declare module BABYLON {
  64317. /**
  64318. * Class containing static functions to help procedurally build meshes
  64319. */
  64320. export class LatheBuilder {
  64321. /**
  64322. * Creates lathe mesh.
  64323. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64324. * * 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
  64325. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64326. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64327. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64328. * * 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
  64329. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64330. * * 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
  64331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64332. * * 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
  64333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64335. * @param name defines the name of the mesh
  64336. * @param options defines the options used to create the mesh
  64337. * @param scene defines the hosting scene
  64338. * @returns the lathe mesh
  64339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64340. */
  64341. static CreateLathe(name: string, options: {
  64342. shape: Vector3[];
  64343. radius?: number;
  64344. tessellation?: number;
  64345. clip?: number;
  64346. arc?: number;
  64347. closed?: boolean;
  64348. updatable?: boolean;
  64349. sideOrientation?: number;
  64350. frontUVs?: Vector4;
  64351. backUVs?: Vector4;
  64352. cap?: number;
  64353. invertUV?: boolean;
  64354. }, scene?: Nullable<Scene>): Mesh;
  64355. }
  64356. }
  64357. declare module BABYLON {
  64358. /**
  64359. * Class containing static functions to help procedurally build meshes
  64360. */
  64361. export class TiledPlaneBuilder {
  64362. /**
  64363. * Creates a tiled plane mesh
  64364. * * The parameter `pattern` will, depending on value, do nothing or
  64365. * * * flip (reflect about central vertical) alternate tiles across and up
  64366. * * * flip every tile on alternate rows
  64367. * * * rotate (180 degs) alternate tiles across and up
  64368. * * * rotate every tile on alternate rows
  64369. * * * flip and rotate alternate tiles across and up
  64370. * * * flip and rotate every tile on alternate rows
  64371. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64372. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64373. * * 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
  64374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64375. * * 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)
  64376. * * 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)
  64377. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64378. * @param name defines the name of the mesh
  64379. * @param options defines the options used to create the mesh
  64380. * @param scene defines the hosting scene
  64381. * @returns the box mesh
  64382. */
  64383. static CreateTiledPlane(name: string, options: {
  64384. pattern?: number;
  64385. tileSize?: number;
  64386. tileWidth?: number;
  64387. tileHeight?: number;
  64388. size?: number;
  64389. width?: number;
  64390. height?: number;
  64391. alignHorizontal?: number;
  64392. alignVertical?: number;
  64393. sideOrientation?: number;
  64394. frontUVs?: Vector4;
  64395. backUVs?: Vector4;
  64396. updatable?: boolean;
  64397. }, scene?: Nullable<Scene>): Mesh;
  64398. }
  64399. }
  64400. declare module BABYLON {
  64401. /**
  64402. * Class containing static functions to help procedurally build meshes
  64403. */
  64404. export class TubeBuilder {
  64405. /**
  64406. * Creates a tube mesh.
  64407. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64408. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64409. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64410. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64411. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64412. * * 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)
  64413. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64414. * * 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
  64415. * * 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
  64416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64417. * * 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
  64418. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64420. * @param name defines the name of the mesh
  64421. * @param options defines the options used to create the mesh
  64422. * @param scene defines the hosting scene
  64423. * @returns the tube mesh
  64424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64425. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64426. */
  64427. static CreateTube(name: string, options: {
  64428. path: Vector3[];
  64429. radius?: number;
  64430. tessellation?: number;
  64431. radiusFunction?: {
  64432. (i: number, distance: number): number;
  64433. };
  64434. cap?: number;
  64435. arc?: number;
  64436. updatable?: boolean;
  64437. sideOrientation?: number;
  64438. frontUVs?: Vector4;
  64439. backUVs?: Vector4;
  64440. instance?: Mesh;
  64441. invertUV?: boolean;
  64442. }, scene?: Nullable<Scene>): Mesh;
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. /**
  64447. * Class containing static functions to help procedurally build meshes
  64448. */
  64449. export class IcoSphereBuilder {
  64450. /**
  64451. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64452. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64453. * * 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`)
  64454. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64455. * * 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
  64456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64457. * * 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
  64458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64459. * @param name defines the name of the mesh
  64460. * @param options defines the options used to create the mesh
  64461. * @param scene defines the hosting scene
  64462. * @returns the icosahedron mesh
  64463. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64464. */
  64465. static CreateIcoSphere(name: string, options: {
  64466. radius?: number;
  64467. radiusX?: number;
  64468. radiusY?: number;
  64469. radiusZ?: number;
  64470. flat?: boolean;
  64471. subdivisions?: number;
  64472. sideOrientation?: number;
  64473. frontUVs?: Vector4;
  64474. backUVs?: Vector4;
  64475. updatable?: boolean;
  64476. }, scene?: Nullable<Scene>): Mesh;
  64477. }
  64478. }
  64479. declare module BABYLON {
  64480. /**
  64481. * Class containing static functions to help procedurally build meshes
  64482. */
  64483. export class DecalBuilder {
  64484. /**
  64485. * Creates a decal mesh.
  64486. * 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
  64487. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64488. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64489. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64490. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64491. * @param name defines the name of the mesh
  64492. * @param sourceMesh defines the mesh where the decal must be applied
  64493. * @param options defines the options used to create the mesh
  64494. * @param scene defines the hosting scene
  64495. * @returns the decal mesh
  64496. * @see https://doc.babylonjs.com/how_to/decals
  64497. */
  64498. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64499. position?: Vector3;
  64500. normal?: Vector3;
  64501. size?: Vector3;
  64502. angle?: number;
  64503. }): Mesh;
  64504. }
  64505. }
  64506. declare module BABYLON {
  64507. /**
  64508. * Class containing static functions to help procedurally build meshes
  64509. */
  64510. export class MeshBuilder {
  64511. /**
  64512. * Creates a box mesh
  64513. * * The parameter `size` sets the size (float) of each box side (default 1)
  64514. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64515. * * 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)
  64516. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64518. * * 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
  64519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64520. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64521. * @param name defines the name of the mesh
  64522. * @param options defines the options used to create the mesh
  64523. * @param scene defines the hosting scene
  64524. * @returns the box mesh
  64525. */
  64526. static CreateBox(name: string, options: {
  64527. size?: number;
  64528. width?: number;
  64529. height?: number;
  64530. depth?: number;
  64531. faceUV?: Vector4[];
  64532. faceColors?: Color4[];
  64533. sideOrientation?: number;
  64534. frontUVs?: Vector4;
  64535. backUVs?: Vector4;
  64536. wrap?: boolean;
  64537. topBaseAt?: number;
  64538. bottomBaseAt?: number;
  64539. updatable?: boolean;
  64540. }, scene?: Nullable<Scene>): Mesh;
  64541. /**
  64542. * Creates a tiled box mesh
  64543. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64545. * @param name defines the name of the mesh
  64546. * @param options defines the options used to create the mesh
  64547. * @param scene defines the hosting scene
  64548. * @returns the tiled box mesh
  64549. */
  64550. static CreateTiledBox(name: string, options: {
  64551. pattern?: number;
  64552. size?: number;
  64553. width?: number;
  64554. height?: number;
  64555. depth: number;
  64556. tileSize?: number;
  64557. tileWidth?: number;
  64558. tileHeight?: number;
  64559. faceUV?: Vector4[];
  64560. faceColors?: Color4[];
  64561. alignHorizontal?: number;
  64562. alignVertical?: number;
  64563. sideOrientation?: number;
  64564. updatable?: boolean;
  64565. }, scene?: Nullable<Scene>): Mesh;
  64566. /**
  64567. * Creates a sphere mesh
  64568. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64569. * * 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`)
  64570. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64571. * * 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
  64572. * * 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)
  64573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64574. * * 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
  64575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64576. * @param name defines the name of the mesh
  64577. * @param options defines the options used to create the mesh
  64578. * @param scene defines the hosting scene
  64579. * @returns the sphere mesh
  64580. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64581. */
  64582. static CreateSphere(name: string, options: {
  64583. segments?: number;
  64584. diameter?: number;
  64585. diameterX?: number;
  64586. diameterY?: number;
  64587. diameterZ?: number;
  64588. arc?: number;
  64589. slice?: number;
  64590. sideOrientation?: number;
  64591. frontUVs?: Vector4;
  64592. backUVs?: Vector4;
  64593. updatable?: boolean;
  64594. }, scene?: Nullable<Scene>): Mesh;
  64595. /**
  64596. * Creates a plane polygonal mesh. By default, this is a disc
  64597. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64598. * * 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
  64599. * * 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
  64600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64601. * * 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
  64602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64603. * @param name defines the name of the mesh
  64604. * @param options defines the options used to create the mesh
  64605. * @param scene defines the hosting scene
  64606. * @returns the plane polygonal mesh
  64607. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64608. */
  64609. static CreateDisc(name: string, options: {
  64610. radius?: number;
  64611. tessellation?: number;
  64612. arc?: number;
  64613. updatable?: boolean;
  64614. sideOrientation?: number;
  64615. frontUVs?: Vector4;
  64616. backUVs?: Vector4;
  64617. }, scene?: Nullable<Scene>): Mesh;
  64618. /**
  64619. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64620. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64621. * * 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`)
  64622. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64623. * * 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
  64624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64625. * * 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
  64626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64627. * @param name defines the name of the mesh
  64628. * @param options defines the options used to create the mesh
  64629. * @param scene defines the hosting scene
  64630. * @returns the icosahedron mesh
  64631. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64632. */
  64633. static CreateIcoSphere(name: string, options: {
  64634. radius?: number;
  64635. radiusX?: number;
  64636. radiusY?: number;
  64637. radiusZ?: number;
  64638. flat?: boolean;
  64639. subdivisions?: number;
  64640. sideOrientation?: number;
  64641. frontUVs?: Vector4;
  64642. backUVs?: Vector4;
  64643. updatable?: boolean;
  64644. }, scene?: Nullable<Scene>): Mesh;
  64645. /**
  64646. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64647. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64648. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64649. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64650. * * 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
  64651. * * 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
  64652. * * 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
  64653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64654. * * 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
  64655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64656. * * 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
  64657. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64658. * * 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
  64659. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64661. * @param name defines the name of the mesh
  64662. * @param options defines the options used to create the mesh
  64663. * @param scene defines the hosting scene
  64664. * @returns the ribbon mesh
  64665. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64666. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64667. */
  64668. static CreateRibbon(name: string, options: {
  64669. pathArray: Vector3[][];
  64670. closeArray?: boolean;
  64671. closePath?: boolean;
  64672. offset?: number;
  64673. updatable?: boolean;
  64674. sideOrientation?: number;
  64675. frontUVs?: Vector4;
  64676. backUVs?: Vector4;
  64677. instance?: Mesh;
  64678. invertUV?: boolean;
  64679. uvs?: Vector2[];
  64680. colors?: Color4[];
  64681. }, scene?: Nullable<Scene>): Mesh;
  64682. /**
  64683. * Creates a cylinder or a cone mesh
  64684. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64685. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64686. * * 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.
  64687. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64688. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64689. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64690. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64691. * * 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).
  64692. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64693. * * 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).
  64694. * * 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
  64695. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64696. * * 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
  64697. * * 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.
  64698. * * If `enclose` is false, a ring surface is one element.
  64699. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64700. * * 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
  64701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64702. * * 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
  64703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64704. * @param name defines the name of the mesh
  64705. * @param options defines the options used to create the mesh
  64706. * @param scene defines the hosting scene
  64707. * @returns the cylinder mesh
  64708. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64709. */
  64710. static CreateCylinder(name: string, options: {
  64711. height?: number;
  64712. diameterTop?: number;
  64713. diameterBottom?: number;
  64714. diameter?: number;
  64715. tessellation?: number;
  64716. subdivisions?: number;
  64717. arc?: number;
  64718. faceColors?: Color4[];
  64719. faceUV?: Vector4[];
  64720. updatable?: boolean;
  64721. hasRings?: boolean;
  64722. enclose?: boolean;
  64723. cap?: number;
  64724. sideOrientation?: number;
  64725. frontUVs?: Vector4;
  64726. backUVs?: Vector4;
  64727. }, scene?: Nullable<Scene>): Mesh;
  64728. /**
  64729. * Creates a torus mesh
  64730. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64731. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64732. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64734. * * 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
  64735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64736. * @param name defines the name of the mesh
  64737. * @param options defines the options used to create the mesh
  64738. * @param scene defines the hosting scene
  64739. * @returns the torus mesh
  64740. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64741. */
  64742. static CreateTorus(name: string, options: {
  64743. diameter?: number;
  64744. thickness?: number;
  64745. tessellation?: number;
  64746. updatable?: boolean;
  64747. sideOrientation?: number;
  64748. frontUVs?: Vector4;
  64749. backUVs?: Vector4;
  64750. }, scene?: Nullable<Scene>): Mesh;
  64751. /**
  64752. * Creates a torus knot mesh
  64753. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64754. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64755. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64756. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64758. * * 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
  64759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64760. * @param name defines the name of the mesh
  64761. * @param options defines the options used to create the mesh
  64762. * @param scene defines the hosting scene
  64763. * @returns the torus knot mesh
  64764. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64765. */
  64766. static CreateTorusKnot(name: string, options: {
  64767. radius?: number;
  64768. tube?: number;
  64769. radialSegments?: number;
  64770. tubularSegments?: number;
  64771. p?: number;
  64772. q?: number;
  64773. updatable?: boolean;
  64774. sideOrientation?: number;
  64775. frontUVs?: Vector4;
  64776. backUVs?: Vector4;
  64777. }, scene?: Nullable<Scene>): Mesh;
  64778. /**
  64779. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64780. * * 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
  64781. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64782. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64783. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64784. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64785. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64786. * * 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
  64787. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64790. * @param name defines the name of the new line system
  64791. * @param options defines the options used to create the line system
  64792. * @param scene defines the hosting scene
  64793. * @returns a new line system mesh
  64794. */
  64795. static CreateLineSystem(name: string, options: {
  64796. lines: Vector3[][];
  64797. updatable?: boolean;
  64798. instance?: Nullable<LinesMesh>;
  64799. colors?: Nullable<Color4[][]>;
  64800. useVertexAlpha?: boolean;
  64801. }, scene: Nullable<Scene>): LinesMesh;
  64802. /**
  64803. * Creates a line mesh
  64804. * 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
  64805. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64806. * * The parameter `points` is an array successive Vector3
  64807. * * 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
  64808. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64809. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64810. * * When updating an instance, remember that only point positions can change, not the number of points
  64811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64813. * @param name defines the name of the new line system
  64814. * @param options defines the options used to create the line system
  64815. * @param scene defines the hosting scene
  64816. * @returns a new line mesh
  64817. */
  64818. static CreateLines(name: string, options: {
  64819. points: Vector3[];
  64820. updatable?: boolean;
  64821. instance?: Nullable<LinesMesh>;
  64822. colors?: Color4[];
  64823. useVertexAlpha?: boolean;
  64824. }, scene?: Nullable<Scene>): LinesMesh;
  64825. /**
  64826. * Creates a dashed line mesh
  64827. * * 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
  64828. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64829. * * The parameter `points` is an array successive Vector3
  64830. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64831. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64832. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64833. * * 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
  64834. * * When updating an instance, remember that only point positions can change, not the number of points
  64835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64836. * @param name defines the name of the mesh
  64837. * @param options defines the options used to create the mesh
  64838. * @param scene defines the hosting scene
  64839. * @returns the dashed line mesh
  64840. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64841. */
  64842. static CreateDashedLines(name: string, options: {
  64843. points: Vector3[];
  64844. dashSize?: number;
  64845. gapSize?: number;
  64846. dashNb?: number;
  64847. updatable?: boolean;
  64848. instance?: LinesMesh;
  64849. }, scene?: Nullable<Scene>): LinesMesh;
  64850. /**
  64851. * 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.
  64852. * * 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.
  64853. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64854. * * 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.
  64855. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64856. * * 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
  64857. * * 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
  64858. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64860. * * 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
  64861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64863. * @param name defines the name of the mesh
  64864. * @param options defines the options used to create the mesh
  64865. * @param scene defines the hosting scene
  64866. * @returns the extruded shape mesh
  64867. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64868. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64869. */
  64870. static ExtrudeShape(name: string, options: {
  64871. shape: Vector3[];
  64872. path: Vector3[];
  64873. scale?: number;
  64874. rotation?: number;
  64875. cap?: number;
  64876. updatable?: boolean;
  64877. sideOrientation?: number;
  64878. frontUVs?: Vector4;
  64879. backUVs?: Vector4;
  64880. instance?: Mesh;
  64881. invertUV?: boolean;
  64882. }, scene?: Nullable<Scene>): Mesh;
  64883. /**
  64884. * Creates an custom extruded shape mesh.
  64885. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64886. * * 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.
  64887. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64888. * * 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
  64889. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64890. * * 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
  64891. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64892. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64893. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64894. * * 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
  64895. * * 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
  64896. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64901. * @param name defines the name of the mesh
  64902. * @param options defines the options used to create the mesh
  64903. * @param scene defines the hosting scene
  64904. * @returns the custom extruded shape mesh
  64905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64908. */
  64909. static ExtrudeShapeCustom(name: string, options: {
  64910. shape: Vector3[];
  64911. path: Vector3[];
  64912. scaleFunction?: any;
  64913. rotationFunction?: any;
  64914. ribbonCloseArray?: boolean;
  64915. ribbonClosePath?: boolean;
  64916. cap?: number;
  64917. updatable?: boolean;
  64918. sideOrientation?: number;
  64919. frontUVs?: Vector4;
  64920. backUVs?: Vector4;
  64921. instance?: Mesh;
  64922. invertUV?: boolean;
  64923. }, scene?: Nullable<Scene>): Mesh;
  64924. /**
  64925. * Creates lathe mesh.
  64926. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64927. * * 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
  64928. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64929. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64930. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64931. * * 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
  64932. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64933. * * 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
  64934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64935. * * 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
  64936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64938. * @param name defines the name of the mesh
  64939. * @param options defines the options used to create the mesh
  64940. * @param scene defines the hosting scene
  64941. * @returns the lathe mesh
  64942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64943. */
  64944. static CreateLathe(name: string, options: {
  64945. shape: Vector3[];
  64946. radius?: number;
  64947. tessellation?: number;
  64948. clip?: number;
  64949. arc?: number;
  64950. closed?: boolean;
  64951. updatable?: boolean;
  64952. sideOrientation?: number;
  64953. frontUVs?: Vector4;
  64954. backUVs?: Vector4;
  64955. cap?: number;
  64956. invertUV?: boolean;
  64957. }, scene?: Nullable<Scene>): Mesh;
  64958. /**
  64959. * Creates a tiled plane mesh
  64960. * * You can set a limited pattern arrangement with the tiles
  64961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64962. * * 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
  64963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64964. * @param name defines the name of the mesh
  64965. * @param options defines the options used to create the mesh
  64966. * @param scene defines the hosting scene
  64967. * @returns the plane mesh
  64968. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64969. */
  64970. static CreateTiledPlane(name: string, options: {
  64971. pattern?: number;
  64972. tileSize?: number;
  64973. tileWidth?: number;
  64974. tileHeight?: number;
  64975. size?: number;
  64976. width?: number;
  64977. height?: number;
  64978. alignHorizontal?: number;
  64979. alignVertical?: number;
  64980. sideOrientation?: number;
  64981. frontUVs?: Vector4;
  64982. backUVs?: Vector4;
  64983. updatable?: boolean;
  64984. }, scene?: Nullable<Scene>): Mesh;
  64985. /**
  64986. * Creates a plane mesh
  64987. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64988. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64989. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64991. * * 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
  64992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64993. * @param name defines the name of the mesh
  64994. * @param options defines the options used to create the mesh
  64995. * @param scene defines the hosting scene
  64996. * @returns the plane mesh
  64997. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64998. */
  64999. static CreatePlane(name: string, options: {
  65000. size?: number;
  65001. width?: number;
  65002. height?: number;
  65003. sideOrientation?: number;
  65004. frontUVs?: Vector4;
  65005. backUVs?: Vector4;
  65006. updatable?: boolean;
  65007. sourcePlane?: Plane;
  65008. }, scene?: Nullable<Scene>): Mesh;
  65009. /**
  65010. * Creates a ground mesh
  65011. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65012. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65014. * @param name defines the name of the mesh
  65015. * @param options defines the options used to create the mesh
  65016. * @param scene defines the hosting scene
  65017. * @returns the ground mesh
  65018. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65019. */
  65020. static CreateGround(name: string, options: {
  65021. width?: number;
  65022. height?: number;
  65023. subdivisions?: number;
  65024. subdivisionsX?: number;
  65025. subdivisionsY?: number;
  65026. updatable?: boolean;
  65027. }, scene?: Nullable<Scene>): Mesh;
  65028. /**
  65029. * Creates a tiled ground mesh
  65030. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65031. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65032. * * 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
  65033. * * 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
  65034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65035. * @param name defines the name of the mesh
  65036. * @param options defines the options used to create the mesh
  65037. * @param scene defines the hosting scene
  65038. * @returns the tiled ground mesh
  65039. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65040. */
  65041. static CreateTiledGround(name: string, options: {
  65042. xmin: number;
  65043. zmin: number;
  65044. xmax: number;
  65045. zmax: number;
  65046. subdivisions?: {
  65047. w: number;
  65048. h: number;
  65049. };
  65050. precision?: {
  65051. w: number;
  65052. h: number;
  65053. };
  65054. updatable?: boolean;
  65055. }, scene?: Nullable<Scene>): Mesh;
  65056. /**
  65057. * Creates a ground mesh from a height map
  65058. * * The parameter `url` sets the URL of the height map image resource.
  65059. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65060. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65061. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65062. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65063. * * 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.
  65064. * * 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).
  65065. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65067. * @param name defines the name of the mesh
  65068. * @param url defines the url to the height map
  65069. * @param options defines the options used to create the mesh
  65070. * @param scene defines the hosting scene
  65071. * @returns the ground mesh
  65072. * @see https://doc.babylonjs.com/babylon101/height_map
  65073. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65074. */
  65075. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65076. width?: number;
  65077. height?: number;
  65078. subdivisions?: number;
  65079. minHeight?: number;
  65080. maxHeight?: number;
  65081. colorFilter?: Color3;
  65082. alphaFilter?: number;
  65083. updatable?: boolean;
  65084. onReady?: (mesh: GroundMesh) => void;
  65085. }, scene?: Nullable<Scene>): GroundMesh;
  65086. /**
  65087. * Creates a polygon mesh
  65088. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65089. * * 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
  65090. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65092. * * 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)
  65093. * * Remember you can only change the shape positions, not their number when updating a polygon
  65094. * @param name defines the name of the mesh
  65095. * @param options defines the options used to create the mesh
  65096. * @param scene defines the hosting scene
  65097. * @param earcutInjection can be used to inject your own earcut reference
  65098. * @returns the polygon mesh
  65099. */
  65100. static CreatePolygon(name: string, options: {
  65101. shape: Vector3[];
  65102. holes?: Vector3[][];
  65103. depth?: number;
  65104. faceUV?: Vector4[];
  65105. faceColors?: Color4[];
  65106. updatable?: boolean;
  65107. sideOrientation?: number;
  65108. frontUVs?: Vector4;
  65109. backUVs?: Vector4;
  65110. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65111. /**
  65112. * Creates an extruded polygon mesh, with depth in the Y direction.
  65113. * * 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)
  65114. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65115. * @param name defines the name of the mesh
  65116. * @param options defines the options used to create the mesh
  65117. * @param scene defines the hosting scene
  65118. * @param earcutInjection can be used to inject your own earcut reference
  65119. * @returns the polygon mesh
  65120. */
  65121. static ExtrudePolygon(name: string, options: {
  65122. shape: Vector3[];
  65123. holes?: Vector3[][];
  65124. depth?: number;
  65125. faceUV?: Vector4[];
  65126. faceColors?: Color4[];
  65127. updatable?: boolean;
  65128. sideOrientation?: number;
  65129. frontUVs?: Vector4;
  65130. backUVs?: Vector4;
  65131. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65132. /**
  65133. * Creates a tube mesh.
  65134. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65135. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65136. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65137. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65138. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65139. * * 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)
  65140. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65141. * * 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
  65142. * * 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
  65143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65144. * * 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
  65145. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65147. * @param name defines the name of the mesh
  65148. * @param options defines the options used to create the mesh
  65149. * @param scene defines the hosting scene
  65150. * @returns the tube mesh
  65151. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65152. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65153. */
  65154. static CreateTube(name: string, options: {
  65155. path: Vector3[];
  65156. radius?: number;
  65157. tessellation?: number;
  65158. radiusFunction?: {
  65159. (i: number, distance: number): number;
  65160. };
  65161. cap?: number;
  65162. arc?: number;
  65163. updatable?: boolean;
  65164. sideOrientation?: number;
  65165. frontUVs?: Vector4;
  65166. backUVs?: Vector4;
  65167. instance?: Mesh;
  65168. invertUV?: boolean;
  65169. }, scene?: Nullable<Scene>): Mesh;
  65170. /**
  65171. * Creates a polyhedron mesh
  65172. * * 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
  65173. * * The parameter `size` (positive float, default 1) sets the polygon size
  65174. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65175. * * 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`
  65176. * * 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
  65177. * * 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)`)
  65178. * * 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
  65179. * * 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
  65180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65183. * @param name defines the name of the mesh
  65184. * @param options defines the options used to create the mesh
  65185. * @param scene defines the hosting scene
  65186. * @returns the polyhedron mesh
  65187. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65188. */
  65189. static CreatePolyhedron(name: string, options: {
  65190. type?: number;
  65191. size?: number;
  65192. sizeX?: number;
  65193. sizeY?: number;
  65194. sizeZ?: number;
  65195. custom?: any;
  65196. faceUV?: Vector4[];
  65197. faceColors?: Color4[];
  65198. flat?: boolean;
  65199. updatable?: boolean;
  65200. sideOrientation?: number;
  65201. frontUVs?: Vector4;
  65202. backUVs?: Vector4;
  65203. }, scene?: Nullable<Scene>): Mesh;
  65204. /**
  65205. * Creates a decal mesh.
  65206. * 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
  65207. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65208. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65209. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65210. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65211. * @param name defines the name of the mesh
  65212. * @param sourceMesh defines the mesh where the decal must be applied
  65213. * @param options defines the options used to create the mesh
  65214. * @param scene defines the hosting scene
  65215. * @returns the decal mesh
  65216. * @see https://doc.babylonjs.com/how_to/decals
  65217. */
  65218. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65219. position?: Vector3;
  65220. normal?: Vector3;
  65221. size?: Vector3;
  65222. angle?: number;
  65223. }): Mesh;
  65224. }
  65225. }
  65226. declare module BABYLON {
  65227. /**
  65228. * A simplifier interface for future simplification implementations
  65229. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65230. */
  65231. export interface ISimplifier {
  65232. /**
  65233. * Simplification of a given mesh according to the given settings.
  65234. * Since this requires computation, it is assumed that the function runs async.
  65235. * @param settings The settings of the simplification, including quality and distance
  65236. * @param successCallback A callback that will be called after the mesh was simplified.
  65237. * @param errorCallback in case of an error, this callback will be called. optional.
  65238. */
  65239. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65240. }
  65241. /**
  65242. * Expected simplification settings.
  65243. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65244. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65245. */
  65246. export interface ISimplificationSettings {
  65247. /**
  65248. * Gets or sets the expected quality
  65249. */
  65250. quality: number;
  65251. /**
  65252. * Gets or sets the distance when this optimized version should be used
  65253. */
  65254. distance: number;
  65255. /**
  65256. * Gets an already optimized mesh
  65257. */
  65258. optimizeMesh?: boolean;
  65259. }
  65260. /**
  65261. * Class used to specify simplification options
  65262. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65263. */
  65264. export class SimplificationSettings implements ISimplificationSettings {
  65265. /** expected quality */
  65266. quality: number;
  65267. /** distance when this optimized version should be used */
  65268. distance: number;
  65269. /** already optimized mesh */
  65270. optimizeMesh?: boolean | undefined;
  65271. /**
  65272. * Creates a SimplificationSettings
  65273. * @param quality expected quality
  65274. * @param distance distance when this optimized version should be used
  65275. * @param optimizeMesh already optimized mesh
  65276. */
  65277. constructor(
  65278. /** expected quality */
  65279. quality: number,
  65280. /** distance when this optimized version should be used */
  65281. distance: number,
  65282. /** already optimized mesh */
  65283. optimizeMesh?: boolean | undefined);
  65284. }
  65285. /**
  65286. * Interface used to define a simplification task
  65287. */
  65288. export interface ISimplificationTask {
  65289. /**
  65290. * Array of settings
  65291. */
  65292. settings: Array<ISimplificationSettings>;
  65293. /**
  65294. * Simplification type
  65295. */
  65296. simplificationType: SimplificationType;
  65297. /**
  65298. * Mesh to simplify
  65299. */
  65300. mesh: Mesh;
  65301. /**
  65302. * Callback called on success
  65303. */
  65304. successCallback?: () => void;
  65305. /**
  65306. * Defines if parallel processing can be used
  65307. */
  65308. parallelProcessing: boolean;
  65309. }
  65310. /**
  65311. * Queue used to order the simplification tasks
  65312. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65313. */
  65314. export class SimplificationQueue {
  65315. private _simplificationArray;
  65316. /**
  65317. * Gets a boolean indicating that the process is still running
  65318. */
  65319. running: boolean;
  65320. /**
  65321. * Creates a new queue
  65322. */
  65323. constructor();
  65324. /**
  65325. * Adds a new simplification task
  65326. * @param task defines a task to add
  65327. */
  65328. addTask(task: ISimplificationTask): void;
  65329. /**
  65330. * Execute next task
  65331. */
  65332. executeNext(): void;
  65333. /**
  65334. * Execute a simplification task
  65335. * @param task defines the task to run
  65336. */
  65337. runSimplification(task: ISimplificationTask): void;
  65338. private getSimplifier;
  65339. }
  65340. /**
  65341. * The implemented types of simplification
  65342. * At the moment only Quadratic Error Decimation is implemented
  65343. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65344. */
  65345. export enum SimplificationType {
  65346. /** Quadratic error decimation */
  65347. QUADRATIC = 0
  65348. }
  65349. /**
  65350. * An implementation of the Quadratic Error simplification algorithm.
  65351. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65352. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65353. * @author RaananW
  65354. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65355. */
  65356. export class QuadraticErrorSimplification implements ISimplifier {
  65357. private _mesh;
  65358. private triangles;
  65359. private vertices;
  65360. private references;
  65361. private _reconstructedMesh;
  65362. /** Gets or sets the number pf sync interations */
  65363. syncIterations: number;
  65364. /** Gets or sets the aggressiveness of the simplifier */
  65365. aggressiveness: number;
  65366. /** Gets or sets the number of allowed iterations for decimation */
  65367. decimationIterations: number;
  65368. /** Gets or sets the espilon to use for bounding box computation */
  65369. boundingBoxEpsilon: number;
  65370. /**
  65371. * Creates a new QuadraticErrorSimplification
  65372. * @param _mesh defines the target mesh
  65373. */
  65374. constructor(_mesh: Mesh);
  65375. /**
  65376. * Simplification of a given mesh according to the given settings.
  65377. * Since this requires computation, it is assumed that the function runs async.
  65378. * @param settings The settings of the simplification, including quality and distance
  65379. * @param successCallback A callback that will be called after the mesh was simplified.
  65380. */
  65381. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65382. private runDecimation;
  65383. private initWithMesh;
  65384. private init;
  65385. private reconstructMesh;
  65386. private initDecimatedMesh;
  65387. private isFlipped;
  65388. private updateTriangles;
  65389. private identifyBorder;
  65390. private updateMesh;
  65391. private vertexError;
  65392. private calculateError;
  65393. }
  65394. }
  65395. declare module BABYLON {
  65396. interface Scene {
  65397. /** @hidden (Backing field) */
  65398. _simplificationQueue: SimplificationQueue;
  65399. /**
  65400. * Gets or sets the simplification queue attached to the scene
  65401. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65402. */
  65403. simplificationQueue: SimplificationQueue;
  65404. }
  65405. interface Mesh {
  65406. /**
  65407. * Simplify the mesh according to the given array of settings.
  65408. * Function will return immediately and will simplify async
  65409. * @param settings a collection of simplification settings
  65410. * @param parallelProcessing should all levels calculate parallel or one after the other
  65411. * @param simplificationType the type of simplification to run
  65412. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65413. * @returns the current mesh
  65414. */
  65415. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65416. }
  65417. /**
  65418. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65419. * created in a scene
  65420. */
  65421. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65422. /**
  65423. * The component name helpfull to identify the component in the list of scene components.
  65424. */
  65425. readonly name: string;
  65426. /**
  65427. * The scene the component belongs to.
  65428. */
  65429. scene: Scene;
  65430. /**
  65431. * Creates a new instance of the component for the given scene
  65432. * @param scene Defines the scene to register the component in
  65433. */
  65434. constructor(scene: Scene);
  65435. /**
  65436. * Registers the component in a given scene
  65437. */
  65438. register(): void;
  65439. /**
  65440. * Rebuilds the elements related to this component in case of
  65441. * context lost for instance.
  65442. */
  65443. rebuild(): void;
  65444. /**
  65445. * Disposes the component and the associated ressources
  65446. */
  65447. dispose(): void;
  65448. private _beforeCameraUpdate;
  65449. }
  65450. }
  65451. declare module BABYLON {
  65452. interface Mesh {
  65453. /**
  65454. * Creates a new thin instance
  65455. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65456. * @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
  65457. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65458. */
  65459. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65460. /**
  65461. * Adds the transformation (matrix) of the current mesh as a thin instance
  65462. * @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
  65463. * @returns the thin instance index number
  65464. */
  65465. thinInstanceAddSelf(refresh: boolean): number;
  65466. /**
  65467. * Registers a custom attribute to be used with thin instances
  65468. * @param kind name of the attribute
  65469. * @param stride size in floats of the attribute
  65470. */
  65471. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65472. /**
  65473. * Sets the matrix of a thin instance
  65474. * @param index index of the thin instance
  65475. * @param matrix matrix to set
  65476. * @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
  65477. */
  65478. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65479. /**
  65480. * Sets the value of a custom attribute for a thin instance
  65481. * @param kind name of the attribute
  65482. * @param index index of the thin instance
  65483. * @param value value to set
  65484. * @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
  65485. */
  65486. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65487. /**
  65488. * 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.
  65489. */
  65490. thinInstanceCount: number;
  65491. /**
  65492. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65493. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65494. * @param buffer buffer to set
  65495. * @param stride size in floats of each value of the buffer
  65496. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65497. */
  65498. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65499. /**
  65500. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65501. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65502. */
  65503. thinInstanceBufferUpdated(kind: string): void;
  65504. /**
  65505. * Refreshes the bounding info, taking into account all the thin instances defined
  65506. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65507. */
  65508. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65509. /** @hidden */
  65510. _thinInstanceInitializeUserStorage(): void;
  65511. /** @hidden */
  65512. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65513. /** @hidden */
  65514. _userThinInstanceBuffersStorage: {
  65515. data: {
  65516. [key: string]: Float32Array;
  65517. };
  65518. sizes: {
  65519. [key: string]: number;
  65520. };
  65521. vertexBuffers: {
  65522. [key: string]: Nullable<VertexBuffer>;
  65523. };
  65524. strides: {
  65525. [key: string]: number;
  65526. };
  65527. };
  65528. }
  65529. }
  65530. declare module BABYLON {
  65531. /**
  65532. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65533. */
  65534. export interface INavigationEnginePlugin {
  65535. /**
  65536. * plugin name
  65537. */
  65538. name: string;
  65539. /**
  65540. * Creates a navigation mesh
  65541. * @param meshes array of all the geometry used to compute the navigatio mesh
  65542. * @param parameters bunch of parameters used to filter geometry
  65543. */
  65544. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65545. /**
  65546. * Create a navigation mesh debug mesh
  65547. * @param scene is where the mesh will be added
  65548. * @returns debug display mesh
  65549. */
  65550. createDebugNavMesh(scene: Scene): Mesh;
  65551. /**
  65552. * Get a navigation mesh constrained position, closest to the parameter position
  65553. * @param position world position
  65554. * @returns the closest point to position constrained by the navigation mesh
  65555. */
  65556. getClosestPoint(position: Vector3): Vector3;
  65557. /**
  65558. * Get a navigation mesh constrained position, closest to the parameter position
  65559. * @param position world position
  65560. * @param result output the closest point to position constrained by the navigation mesh
  65561. */
  65562. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65563. /**
  65564. * Get a navigation mesh constrained position, within a particular radius
  65565. * @param position world position
  65566. * @param maxRadius the maximum distance to the constrained world position
  65567. * @returns the closest point to position constrained by the navigation mesh
  65568. */
  65569. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65570. /**
  65571. * Get a navigation mesh constrained position, within a particular radius
  65572. * @param position world position
  65573. * @param maxRadius the maximum distance to the constrained world position
  65574. * @param result output the closest point to position constrained by the navigation mesh
  65575. */
  65576. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65577. /**
  65578. * Compute the final position from a segment made of destination-position
  65579. * @param position world position
  65580. * @param destination world position
  65581. * @returns the resulting point along the navmesh
  65582. */
  65583. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65584. /**
  65585. * Compute the final position from a segment made of destination-position
  65586. * @param position world position
  65587. * @param destination world position
  65588. * @param result output the resulting point along the navmesh
  65589. */
  65590. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65591. /**
  65592. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65593. * @param start world position
  65594. * @param end world position
  65595. * @returns array containing world position composing the path
  65596. */
  65597. computePath(start: Vector3, end: Vector3): Vector3[];
  65598. /**
  65599. * If this plugin is supported
  65600. * @returns true if plugin is supported
  65601. */
  65602. isSupported(): boolean;
  65603. /**
  65604. * Create a new Crowd so you can add agents
  65605. * @param maxAgents the maximum agent count in the crowd
  65606. * @param maxAgentRadius the maximum radius an agent can have
  65607. * @param scene to attach the crowd to
  65608. * @returns the crowd you can add agents to
  65609. */
  65610. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65611. /**
  65612. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65613. * The queries will try to find a solution within those bounds
  65614. * default is (1,1,1)
  65615. * @param extent x,y,z value that define the extent around the queries point of reference
  65616. */
  65617. setDefaultQueryExtent(extent: Vector3): void;
  65618. /**
  65619. * Get the Bounding box extent specified by setDefaultQueryExtent
  65620. * @returns the box extent values
  65621. */
  65622. getDefaultQueryExtent(): Vector3;
  65623. /**
  65624. * build the navmesh from a previously saved state using getNavmeshData
  65625. * @param data the Uint8Array returned by getNavmeshData
  65626. */
  65627. buildFromNavmeshData(data: Uint8Array): void;
  65628. /**
  65629. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65630. * @returns data the Uint8Array that can be saved and reused
  65631. */
  65632. getNavmeshData(): Uint8Array;
  65633. /**
  65634. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65635. * @param result output the box extent values
  65636. */
  65637. getDefaultQueryExtentToRef(result: Vector3): void;
  65638. /**
  65639. * Release all resources
  65640. */
  65641. dispose(): void;
  65642. }
  65643. /**
  65644. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65645. */
  65646. export interface ICrowd {
  65647. /**
  65648. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65649. * You can attach anything to that node. The node position is updated in the scene update tick.
  65650. * @param pos world position that will be constrained by the navigation mesh
  65651. * @param parameters agent parameters
  65652. * @param transform hooked to the agent that will be update by the scene
  65653. * @returns agent index
  65654. */
  65655. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65656. /**
  65657. * Returns the agent position in world space
  65658. * @param index agent index returned by addAgent
  65659. * @returns world space position
  65660. */
  65661. getAgentPosition(index: number): Vector3;
  65662. /**
  65663. * Gets the agent position result in world space
  65664. * @param index agent index returned by addAgent
  65665. * @param result output world space position
  65666. */
  65667. getAgentPositionToRef(index: number, result: Vector3): void;
  65668. /**
  65669. * Gets the agent velocity in world space
  65670. * @param index agent index returned by addAgent
  65671. * @returns world space velocity
  65672. */
  65673. getAgentVelocity(index: number): Vector3;
  65674. /**
  65675. * Gets the agent velocity result in world space
  65676. * @param index agent index returned by addAgent
  65677. * @param result output world space velocity
  65678. */
  65679. getAgentVelocityToRef(index: number, result: Vector3): void;
  65680. /**
  65681. * remove a particular agent previously created
  65682. * @param index agent index returned by addAgent
  65683. */
  65684. removeAgent(index: number): void;
  65685. /**
  65686. * get the list of all agents attached to this crowd
  65687. * @returns list of agent indices
  65688. */
  65689. getAgents(): number[];
  65690. /**
  65691. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65692. * @param deltaTime in seconds
  65693. */
  65694. update(deltaTime: number): void;
  65695. /**
  65696. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65697. * @param index agent index returned by addAgent
  65698. * @param destination targeted world position
  65699. */
  65700. agentGoto(index: number, destination: Vector3): void;
  65701. /**
  65702. * Teleport the agent to a new position
  65703. * @param index agent index returned by addAgent
  65704. * @param destination targeted world position
  65705. */
  65706. agentTeleport(index: number, destination: Vector3): void;
  65707. /**
  65708. * Update agent parameters
  65709. * @param index agent index returned by addAgent
  65710. * @param parameters agent parameters
  65711. */
  65712. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65713. /**
  65714. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65715. * The queries will try to find a solution within those bounds
  65716. * default is (1,1,1)
  65717. * @param extent x,y,z value that define the extent around the queries point of reference
  65718. */
  65719. setDefaultQueryExtent(extent: Vector3): void;
  65720. /**
  65721. * Get the Bounding box extent specified by setDefaultQueryExtent
  65722. * @returns the box extent values
  65723. */
  65724. getDefaultQueryExtent(): Vector3;
  65725. /**
  65726. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65727. * @param result output the box extent values
  65728. */
  65729. getDefaultQueryExtentToRef(result: Vector3): void;
  65730. /**
  65731. * Release all resources
  65732. */
  65733. dispose(): void;
  65734. }
  65735. /**
  65736. * Configures an agent
  65737. */
  65738. export interface IAgentParameters {
  65739. /**
  65740. * Agent radius. [Limit: >= 0]
  65741. */
  65742. radius: number;
  65743. /**
  65744. * Agent height. [Limit: > 0]
  65745. */
  65746. height: number;
  65747. /**
  65748. * Maximum allowed acceleration. [Limit: >= 0]
  65749. */
  65750. maxAcceleration: number;
  65751. /**
  65752. * Maximum allowed speed. [Limit: >= 0]
  65753. */
  65754. maxSpeed: number;
  65755. /**
  65756. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65757. */
  65758. collisionQueryRange: number;
  65759. /**
  65760. * The path visibility optimization range. [Limit: > 0]
  65761. */
  65762. pathOptimizationRange: number;
  65763. /**
  65764. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65765. */
  65766. separationWeight: number;
  65767. }
  65768. /**
  65769. * Configures the navigation mesh creation
  65770. */
  65771. export interface INavMeshParameters {
  65772. /**
  65773. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65774. */
  65775. cs: number;
  65776. /**
  65777. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65778. */
  65779. ch: number;
  65780. /**
  65781. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65782. */
  65783. walkableSlopeAngle: number;
  65784. /**
  65785. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65786. * be considered walkable. [Limit: >= 3] [Units: vx]
  65787. */
  65788. walkableHeight: number;
  65789. /**
  65790. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65791. */
  65792. walkableClimb: number;
  65793. /**
  65794. * The distance to erode/shrink the walkable area of the heightfield away from
  65795. * obstructions. [Limit: >=0] [Units: vx]
  65796. */
  65797. walkableRadius: number;
  65798. /**
  65799. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65800. */
  65801. maxEdgeLen: number;
  65802. /**
  65803. * The maximum distance a simplfied contour's border edges should deviate
  65804. * the original raw contour. [Limit: >=0] [Units: vx]
  65805. */
  65806. maxSimplificationError: number;
  65807. /**
  65808. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65809. */
  65810. minRegionArea: number;
  65811. /**
  65812. * Any regions with a span count smaller than this value will, if possible,
  65813. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65814. */
  65815. mergeRegionArea: number;
  65816. /**
  65817. * The maximum number of vertices allowed for polygons generated during the
  65818. * contour to polygon conversion process. [Limit: >= 3]
  65819. */
  65820. maxVertsPerPoly: number;
  65821. /**
  65822. * Sets the sampling distance to use when generating the detail mesh.
  65823. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65824. */
  65825. detailSampleDist: number;
  65826. /**
  65827. * The maximum distance the detail mesh surface should deviate from heightfield
  65828. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65829. */
  65830. detailSampleMaxError: number;
  65831. }
  65832. }
  65833. declare module BABYLON {
  65834. /**
  65835. * RecastJS navigation plugin
  65836. */
  65837. export class RecastJSPlugin implements INavigationEnginePlugin {
  65838. /**
  65839. * Reference to the Recast library
  65840. */
  65841. bjsRECAST: any;
  65842. /**
  65843. * plugin name
  65844. */
  65845. name: string;
  65846. /**
  65847. * the first navmesh created. We might extend this to support multiple navmeshes
  65848. */
  65849. navMesh: any;
  65850. /**
  65851. * Initializes the recastJS plugin
  65852. * @param recastInjection can be used to inject your own recast reference
  65853. */
  65854. constructor(recastInjection?: any);
  65855. /**
  65856. * Creates a navigation mesh
  65857. * @param meshes array of all the geometry used to compute the navigatio mesh
  65858. * @param parameters bunch of parameters used to filter geometry
  65859. */
  65860. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65861. /**
  65862. * Create a navigation mesh debug mesh
  65863. * @param scene is where the mesh will be added
  65864. * @returns debug display mesh
  65865. */
  65866. createDebugNavMesh(scene: Scene): Mesh;
  65867. /**
  65868. * Get a navigation mesh constrained position, closest to the parameter position
  65869. * @param position world position
  65870. * @returns the closest point to position constrained by the navigation mesh
  65871. */
  65872. getClosestPoint(position: Vector3): Vector3;
  65873. /**
  65874. * Get a navigation mesh constrained position, closest to the parameter position
  65875. * @param position world position
  65876. * @param result output the closest point to position constrained by the navigation mesh
  65877. */
  65878. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65879. /**
  65880. * Get a navigation mesh constrained position, within a particular radius
  65881. * @param position world position
  65882. * @param maxRadius the maximum distance to the constrained world position
  65883. * @returns the closest point to position constrained by the navigation mesh
  65884. */
  65885. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65886. /**
  65887. * Get a navigation mesh constrained position, within a particular radius
  65888. * @param position world position
  65889. * @param maxRadius the maximum distance to the constrained world position
  65890. * @param result output the closest point to position constrained by the navigation mesh
  65891. */
  65892. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65893. /**
  65894. * Compute the final position from a segment made of destination-position
  65895. * @param position world position
  65896. * @param destination world position
  65897. * @returns the resulting point along the navmesh
  65898. */
  65899. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65900. /**
  65901. * Compute the final position from a segment made of destination-position
  65902. * @param position world position
  65903. * @param destination world position
  65904. * @param result output the resulting point along the navmesh
  65905. */
  65906. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65907. /**
  65908. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65909. * @param start world position
  65910. * @param end world position
  65911. * @returns array containing world position composing the path
  65912. */
  65913. computePath(start: Vector3, end: Vector3): Vector3[];
  65914. /**
  65915. * Create a new Crowd so you can add agents
  65916. * @param maxAgents the maximum agent count in the crowd
  65917. * @param maxAgentRadius the maximum radius an agent can have
  65918. * @param scene to attach the crowd to
  65919. * @returns the crowd you can add agents to
  65920. */
  65921. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65922. /**
  65923. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65924. * The queries will try to find a solution within those bounds
  65925. * default is (1,1,1)
  65926. * @param extent x,y,z value that define the extent around the queries point of reference
  65927. */
  65928. setDefaultQueryExtent(extent: Vector3): void;
  65929. /**
  65930. * Get the Bounding box extent specified by setDefaultQueryExtent
  65931. * @returns the box extent values
  65932. */
  65933. getDefaultQueryExtent(): Vector3;
  65934. /**
  65935. * build the navmesh from a previously saved state using getNavmeshData
  65936. * @param data the Uint8Array returned by getNavmeshData
  65937. */
  65938. buildFromNavmeshData(data: Uint8Array): void;
  65939. /**
  65940. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65941. * @returns data the Uint8Array that can be saved and reused
  65942. */
  65943. getNavmeshData(): Uint8Array;
  65944. /**
  65945. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65946. * @param result output the box extent values
  65947. */
  65948. getDefaultQueryExtentToRef(result: Vector3): void;
  65949. /**
  65950. * Disposes
  65951. */
  65952. dispose(): void;
  65953. /**
  65954. * If this plugin is supported
  65955. * @returns true if plugin is supported
  65956. */
  65957. isSupported(): boolean;
  65958. }
  65959. /**
  65960. * Recast detour crowd implementation
  65961. */
  65962. export class RecastJSCrowd implements ICrowd {
  65963. /**
  65964. * Recast/detour plugin
  65965. */
  65966. bjsRECASTPlugin: RecastJSPlugin;
  65967. /**
  65968. * Link to the detour crowd
  65969. */
  65970. recastCrowd: any;
  65971. /**
  65972. * One transform per agent
  65973. */
  65974. transforms: TransformNode[];
  65975. /**
  65976. * All agents created
  65977. */
  65978. agents: number[];
  65979. /**
  65980. * Link to the scene is kept to unregister the crowd from the scene
  65981. */
  65982. private _scene;
  65983. /**
  65984. * Observer for crowd updates
  65985. */
  65986. private _onBeforeAnimationsObserver;
  65987. /**
  65988. * Constructor
  65989. * @param plugin recastJS plugin
  65990. * @param maxAgents the maximum agent count in the crowd
  65991. * @param maxAgentRadius the maximum radius an agent can have
  65992. * @param scene to attach the crowd to
  65993. * @returns the crowd you can add agents to
  65994. */
  65995. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65996. /**
  65997. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65998. * You can attach anything to that node. The node position is updated in the scene update tick.
  65999. * @param pos world position that will be constrained by the navigation mesh
  66000. * @param parameters agent parameters
  66001. * @param transform hooked to the agent that will be update by the scene
  66002. * @returns agent index
  66003. */
  66004. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66005. /**
  66006. * Returns the agent position in world space
  66007. * @param index agent index returned by addAgent
  66008. * @returns world space position
  66009. */
  66010. getAgentPosition(index: number): Vector3;
  66011. /**
  66012. * Returns the agent position result in world space
  66013. * @param index agent index returned by addAgent
  66014. * @param result output world space position
  66015. */
  66016. getAgentPositionToRef(index: number, result: Vector3): void;
  66017. /**
  66018. * Returns the agent velocity in world space
  66019. * @param index agent index returned by addAgent
  66020. * @returns world space velocity
  66021. */
  66022. getAgentVelocity(index: number): Vector3;
  66023. /**
  66024. * Returns the agent velocity result in world space
  66025. * @param index agent index returned by addAgent
  66026. * @param result output world space velocity
  66027. */
  66028. getAgentVelocityToRef(index: number, result: Vector3): void;
  66029. /**
  66030. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66031. * @param index agent index returned by addAgent
  66032. * @param destination targeted world position
  66033. */
  66034. agentGoto(index: number, destination: Vector3): void;
  66035. /**
  66036. * Teleport the agent to a new position
  66037. * @param index agent index returned by addAgent
  66038. * @param destination targeted world position
  66039. */
  66040. agentTeleport(index: number, destination: Vector3): void;
  66041. /**
  66042. * Update agent parameters
  66043. * @param index agent index returned by addAgent
  66044. * @param parameters agent parameters
  66045. */
  66046. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66047. /**
  66048. * remove a particular agent previously created
  66049. * @param index agent index returned by addAgent
  66050. */
  66051. removeAgent(index: number): void;
  66052. /**
  66053. * get the list of all agents attached to this crowd
  66054. * @returns list of agent indices
  66055. */
  66056. getAgents(): number[];
  66057. /**
  66058. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66059. * @param deltaTime in seconds
  66060. */
  66061. update(deltaTime: number): void;
  66062. /**
  66063. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66064. * The queries will try to find a solution within those bounds
  66065. * default is (1,1,1)
  66066. * @param extent x,y,z value that define the extent around the queries point of reference
  66067. */
  66068. setDefaultQueryExtent(extent: Vector3): void;
  66069. /**
  66070. * Get the Bounding box extent specified by setDefaultQueryExtent
  66071. * @returns the box extent values
  66072. */
  66073. getDefaultQueryExtent(): Vector3;
  66074. /**
  66075. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66076. * @param result output the box extent values
  66077. */
  66078. getDefaultQueryExtentToRef(result: Vector3): void;
  66079. /**
  66080. * Release all resources
  66081. */
  66082. dispose(): void;
  66083. }
  66084. }
  66085. declare module BABYLON {
  66086. /**
  66087. * Class used to enable access to IndexedDB
  66088. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66089. */
  66090. export class Database implements IOfflineProvider {
  66091. private _callbackManifestChecked;
  66092. private _currentSceneUrl;
  66093. private _db;
  66094. private _enableSceneOffline;
  66095. private _enableTexturesOffline;
  66096. private _manifestVersionFound;
  66097. private _mustUpdateRessources;
  66098. private _hasReachedQuota;
  66099. private _isSupported;
  66100. private _idbFactory;
  66101. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66102. private static IsUASupportingBlobStorage;
  66103. /**
  66104. * Gets a boolean indicating if Database storate is enabled (off by default)
  66105. */
  66106. static IDBStorageEnabled: boolean;
  66107. /**
  66108. * Gets a boolean indicating if scene must be saved in the database
  66109. */
  66110. get enableSceneOffline(): boolean;
  66111. /**
  66112. * Gets a boolean indicating if textures must be saved in the database
  66113. */
  66114. get enableTexturesOffline(): boolean;
  66115. /**
  66116. * Creates a new Database
  66117. * @param urlToScene defines the url to load the scene
  66118. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66119. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66120. */
  66121. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66122. private static _ParseURL;
  66123. private static _ReturnFullUrlLocation;
  66124. private _checkManifestFile;
  66125. /**
  66126. * Open the database and make it available
  66127. * @param successCallback defines the callback to call on success
  66128. * @param errorCallback defines the callback to call on error
  66129. */
  66130. open(successCallback: () => void, errorCallback: () => void): void;
  66131. /**
  66132. * Loads an image from the database
  66133. * @param url defines the url to load from
  66134. * @param image defines the target DOM image
  66135. */
  66136. loadImage(url: string, image: HTMLImageElement): void;
  66137. private _loadImageFromDBAsync;
  66138. private _saveImageIntoDBAsync;
  66139. private _checkVersionFromDB;
  66140. private _loadVersionFromDBAsync;
  66141. private _saveVersionIntoDBAsync;
  66142. /**
  66143. * Loads a file from database
  66144. * @param url defines the URL to load from
  66145. * @param sceneLoaded defines a callback to call on success
  66146. * @param progressCallBack defines a callback to call when progress changed
  66147. * @param errorCallback defines a callback to call on error
  66148. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66149. */
  66150. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66151. private _loadFileAsync;
  66152. private _saveFileAsync;
  66153. /**
  66154. * Validates if xhr data is correct
  66155. * @param xhr defines the request to validate
  66156. * @param dataType defines the expected data type
  66157. * @returns true if data is correct
  66158. */
  66159. private static _ValidateXHRData;
  66160. }
  66161. }
  66162. declare module BABYLON {
  66163. /** @hidden */
  66164. export var gpuUpdateParticlesPixelShader: {
  66165. name: string;
  66166. shader: string;
  66167. };
  66168. }
  66169. declare module BABYLON {
  66170. /** @hidden */
  66171. export var gpuUpdateParticlesVertexShader: {
  66172. name: string;
  66173. shader: string;
  66174. };
  66175. }
  66176. declare module BABYLON {
  66177. /** @hidden */
  66178. export var clipPlaneFragmentDeclaration2: {
  66179. name: string;
  66180. shader: string;
  66181. };
  66182. }
  66183. declare module BABYLON {
  66184. /** @hidden */
  66185. export var gpuRenderParticlesPixelShader: {
  66186. name: string;
  66187. shader: string;
  66188. };
  66189. }
  66190. declare module BABYLON {
  66191. /** @hidden */
  66192. export var clipPlaneVertexDeclaration2: {
  66193. name: string;
  66194. shader: string;
  66195. };
  66196. }
  66197. declare module BABYLON {
  66198. /** @hidden */
  66199. export var gpuRenderParticlesVertexShader: {
  66200. name: string;
  66201. shader: string;
  66202. };
  66203. }
  66204. declare module BABYLON {
  66205. /**
  66206. * This represents a GPU particle system in Babylon
  66207. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66208. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66209. */
  66210. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66211. /**
  66212. * The layer mask we are rendering the particles through.
  66213. */
  66214. layerMask: number;
  66215. private _capacity;
  66216. private _activeCount;
  66217. private _currentActiveCount;
  66218. private _accumulatedCount;
  66219. private _renderEffect;
  66220. private _updateEffect;
  66221. private _buffer0;
  66222. private _buffer1;
  66223. private _spriteBuffer;
  66224. private _updateVAO;
  66225. private _renderVAO;
  66226. private _targetIndex;
  66227. private _sourceBuffer;
  66228. private _targetBuffer;
  66229. private _engine;
  66230. private _currentRenderId;
  66231. private _started;
  66232. private _stopped;
  66233. private _timeDelta;
  66234. private _randomTexture;
  66235. private _randomTexture2;
  66236. private _attributesStrideSize;
  66237. private _updateEffectOptions;
  66238. private _randomTextureSize;
  66239. private _actualFrame;
  66240. private _customEffect;
  66241. private readonly _rawTextureWidth;
  66242. /**
  66243. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66244. */
  66245. static get IsSupported(): boolean;
  66246. /**
  66247. * An event triggered when the system is disposed.
  66248. */
  66249. onDisposeObservable: Observable<IParticleSystem>;
  66250. /**
  66251. * Gets the maximum number of particles active at the same time.
  66252. * @returns The max number of active particles.
  66253. */
  66254. getCapacity(): number;
  66255. /**
  66256. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66257. * to override the particles.
  66258. */
  66259. forceDepthWrite: boolean;
  66260. /**
  66261. * Gets or set the number of active particles
  66262. */
  66263. get activeParticleCount(): number;
  66264. set activeParticleCount(value: number);
  66265. private _preWarmDone;
  66266. /**
  66267. * Specifies if the particles are updated in emitter local space or world space.
  66268. */
  66269. isLocal: boolean;
  66270. /**
  66271. * Is this system ready to be used/rendered
  66272. * @return true if the system is ready
  66273. */
  66274. isReady(): boolean;
  66275. /**
  66276. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66277. * @returns True if it has been started, otherwise false.
  66278. */
  66279. isStarted(): boolean;
  66280. /**
  66281. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66282. * @returns True if it has been stopped, otherwise false.
  66283. */
  66284. isStopped(): boolean;
  66285. /**
  66286. * Gets a boolean indicating that the system is stopping
  66287. * @returns true if the system is currently stopping
  66288. */
  66289. isStopping(): boolean;
  66290. /**
  66291. * Gets the number of particles active at the same time.
  66292. * @returns The number of active particles.
  66293. */
  66294. getActiveCount(): number;
  66295. /**
  66296. * Starts the particle system and begins to emit
  66297. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66298. */
  66299. start(delay?: number): void;
  66300. /**
  66301. * Stops the particle system.
  66302. */
  66303. stop(): void;
  66304. /**
  66305. * Remove all active particles
  66306. */
  66307. reset(): void;
  66308. /**
  66309. * Returns the string "GPUParticleSystem"
  66310. * @returns a string containing the class name
  66311. */
  66312. getClassName(): string;
  66313. /**
  66314. * Gets the custom effect used to render the particles
  66315. * @param blendMode Blend mode for which the effect should be retrieved
  66316. * @returns The effect
  66317. */
  66318. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66319. /**
  66320. * Sets the custom effect used to render the particles
  66321. * @param effect The effect to set
  66322. * @param blendMode Blend mode for which the effect should be set
  66323. */
  66324. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66325. /** @hidden */
  66326. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66327. /**
  66328. * Observable that will be called just before the particles are drawn
  66329. */
  66330. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66331. /**
  66332. * Gets the name of the particle vertex shader
  66333. */
  66334. get vertexShaderName(): string;
  66335. private _colorGradientsTexture;
  66336. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66337. /**
  66338. * Adds a new color gradient
  66339. * @param gradient defines the gradient to use (between 0 and 1)
  66340. * @param color1 defines the color to affect to the specified gradient
  66341. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66342. * @returns the current particle system
  66343. */
  66344. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66345. private _refreshColorGradient;
  66346. /** Force the system to rebuild all gradients that need to be resync */
  66347. forceRefreshGradients(): void;
  66348. /**
  66349. * Remove a specific color gradient
  66350. * @param gradient defines the gradient to remove
  66351. * @returns the current particle system
  66352. */
  66353. removeColorGradient(gradient: number): GPUParticleSystem;
  66354. private _angularSpeedGradientsTexture;
  66355. private _sizeGradientsTexture;
  66356. private _velocityGradientsTexture;
  66357. private _limitVelocityGradientsTexture;
  66358. private _dragGradientsTexture;
  66359. private _addFactorGradient;
  66360. /**
  66361. * Adds a new size gradient
  66362. * @param gradient defines the gradient to use (between 0 and 1)
  66363. * @param factor defines the size factor to affect to the specified gradient
  66364. * @returns the current particle system
  66365. */
  66366. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66367. /**
  66368. * Remove a specific size gradient
  66369. * @param gradient defines the gradient to remove
  66370. * @returns the current particle system
  66371. */
  66372. removeSizeGradient(gradient: number): GPUParticleSystem;
  66373. private _refreshFactorGradient;
  66374. /**
  66375. * Adds a new angular speed gradient
  66376. * @param gradient defines the gradient to use (between 0 and 1)
  66377. * @param factor defines the angular speed to affect to the specified gradient
  66378. * @returns the current particle system
  66379. */
  66380. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66381. /**
  66382. * Remove a specific angular speed gradient
  66383. * @param gradient defines the gradient to remove
  66384. * @returns the current particle system
  66385. */
  66386. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66387. /**
  66388. * Adds a new velocity gradient
  66389. * @param gradient defines the gradient to use (between 0 and 1)
  66390. * @param factor defines the velocity to affect to the specified gradient
  66391. * @returns the current particle system
  66392. */
  66393. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66394. /**
  66395. * Remove a specific velocity gradient
  66396. * @param gradient defines the gradient to remove
  66397. * @returns the current particle system
  66398. */
  66399. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66400. /**
  66401. * Adds a new limit velocity gradient
  66402. * @param gradient defines the gradient to use (between 0 and 1)
  66403. * @param factor defines the limit velocity value to affect to the specified gradient
  66404. * @returns the current particle system
  66405. */
  66406. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66407. /**
  66408. * Remove a specific limit velocity gradient
  66409. * @param gradient defines the gradient to remove
  66410. * @returns the current particle system
  66411. */
  66412. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66413. /**
  66414. * Adds a new drag gradient
  66415. * @param gradient defines the gradient to use (between 0 and 1)
  66416. * @param factor defines the drag value to affect to the specified gradient
  66417. * @returns the current particle system
  66418. */
  66419. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66420. /**
  66421. * Remove a specific drag gradient
  66422. * @param gradient defines the gradient to remove
  66423. * @returns the current particle system
  66424. */
  66425. removeDragGradient(gradient: number): GPUParticleSystem;
  66426. /**
  66427. * Not supported by GPUParticleSystem
  66428. * @param gradient defines the gradient to use (between 0 and 1)
  66429. * @param factor defines the emit rate value to affect to the specified gradient
  66430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66431. * @returns the current particle system
  66432. */
  66433. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66434. /**
  66435. * Not supported by GPUParticleSystem
  66436. * @param gradient defines the gradient to remove
  66437. * @returns the current particle system
  66438. */
  66439. removeEmitRateGradient(gradient: number): IParticleSystem;
  66440. /**
  66441. * Not supported by GPUParticleSystem
  66442. * @param gradient defines the gradient to use (between 0 and 1)
  66443. * @param factor defines the start size value to affect to the specified gradient
  66444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66445. * @returns the current particle system
  66446. */
  66447. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66448. /**
  66449. * Not supported by GPUParticleSystem
  66450. * @param gradient defines the gradient to remove
  66451. * @returns the current particle system
  66452. */
  66453. removeStartSizeGradient(gradient: number): IParticleSystem;
  66454. /**
  66455. * Not supported by GPUParticleSystem
  66456. * @param gradient defines the gradient to use (between 0 and 1)
  66457. * @param min defines the color remap minimal range
  66458. * @param max defines the color remap maximal range
  66459. * @returns the current particle system
  66460. */
  66461. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66462. /**
  66463. * Not supported by GPUParticleSystem
  66464. * @param gradient defines the gradient to remove
  66465. * @returns the current particle system
  66466. */
  66467. removeColorRemapGradient(): IParticleSystem;
  66468. /**
  66469. * Not supported by GPUParticleSystem
  66470. * @param gradient defines the gradient to use (between 0 and 1)
  66471. * @param min defines the alpha remap minimal range
  66472. * @param max defines the alpha remap maximal range
  66473. * @returns the current particle system
  66474. */
  66475. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66476. /**
  66477. * Not supported by GPUParticleSystem
  66478. * @param gradient defines the gradient to remove
  66479. * @returns the current particle system
  66480. */
  66481. removeAlphaRemapGradient(): IParticleSystem;
  66482. /**
  66483. * Not supported by GPUParticleSystem
  66484. * @param gradient defines the gradient to use (between 0 and 1)
  66485. * @param color defines the color to affect to the specified gradient
  66486. * @returns the current particle system
  66487. */
  66488. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66489. /**
  66490. * Not supported by GPUParticleSystem
  66491. * @param gradient defines the gradient to remove
  66492. * @returns the current particle system
  66493. */
  66494. removeRampGradient(): IParticleSystem;
  66495. /**
  66496. * Not supported by GPUParticleSystem
  66497. * @returns the list of ramp gradients
  66498. */
  66499. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66500. /**
  66501. * Not supported by GPUParticleSystem
  66502. * Gets or sets a boolean indicating that ramp gradients must be used
  66503. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66504. */
  66505. get useRampGradients(): boolean;
  66506. set useRampGradients(value: boolean);
  66507. /**
  66508. * Not supported by GPUParticleSystem
  66509. * @param gradient defines the gradient to use (between 0 and 1)
  66510. * @param factor defines the life time factor to affect to the specified gradient
  66511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66512. * @returns the current particle system
  66513. */
  66514. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66515. /**
  66516. * Not supported by GPUParticleSystem
  66517. * @param gradient defines the gradient to remove
  66518. * @returns the current particle system
  66519. */
  66520. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66521. /**
  66522. * Instantiates a GPU particle system.
  66523. * 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.
  66524. * @param name The name of the particle system
  66525. * @param options The options used to create the system
  66526. * @param scene The scene the particle system belongs to
  66527. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66528. * @param customEffect a custom effect used to change the way particles are rendered by default
  66529. */
  66530. constructor(name: string, options: Partial<{
  66531. capacity: number;
  66532. randomTextureSize: number;
  66533. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66534. protected _reset(): void;
  66535. private _createUpdateVAO;
  66536. private _createRenderVAO;
  66537. private _initialize;
  66538. /** @hidden */
  66539. _recreateUpdateEffect(): void;
  66540. private _getEffect;
  66541. /**
  66542. * Fill the defines array according to the current settings of the particle system
  66543. * @param defines Array to be updated
  66544. * @param blendMode blend mode to take into account when updating the array
  66545. */
  66546. fillDefines(defines: Array<string>, blendMode?: number): void;
  66547. /**
  66548. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66549. * @param uniforms Uniforms array to fill
  66550. * @param attributes Attributes array to fill
  66551. * @param samplers Samplers array to fill
  66552. */
  66553. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66554. /** @hidden */
  66555. _recreateRenderEffect(): Effect;
  66556. /**
  66557. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66558. * @param preWarm defines if we are in the pre-warmimg phase
  66559. */
  66560. animate(preWarm?: boolean): void;
  66561. private _createFactorGradientTexture;
  66562. private _createSizeGradientTexture;
  66563. private _createAngularSpeedGradientTexture;
  66564. private _createVelocityGradientTexture;
  66565. private _createLimitVelocityGradientTexture;
  66566. private _createDragGradientTexture;
  66567. private _createColorGradientTexture;
  66568. /**
  66569. * Renders the particle system in its current state
  66570. * @param preWarm defines if the system should only update the particles but not render them
  66571. * @returns the current number of particles
  66572. */
  66573. render(preWarm?: boolean): number;
  66574. /**
  66575. * Rebuilds the particle system
  66576. */
  66577. rebuild(): void;
  66578. private _releaseBuffers;
  66579. private _releaseVAOs;
  66580. /**
  66581. * Disposes the particle system and free the associated resources
  66582. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66583. */
  66584. dispose(disposeTexture?: boolean): void;
  66585. /**
  66586. * Clones the particle system.
  66587. * @param name The name of the cloned object
  66588. * @param newEmitter The new emitter to use
  66589. * @returns the cloned particle system
  66590. */
  66591. clone(name: string, newEmitter: any): GPUParticleSystem;
  66592. /**
  66593. * Serializes the particle system to a JSON object
  66594. * @param serializeTexture defines if the texture must be serialized as well
  66595. * @returns the JSON object
  66596. */
  66597. serialize(serializeTexture?: boolean): any;
  66598. /**
  66599. * Parses a JSON object to create a GPU particle system.
  66600. * @param parsedParticleSystem The JSON object to parse
  66601. * @param scene The scene to create the particle system in
  66602. * @param rootUrl The root url to use to load external dependencies like texture
  66603. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66604. * @returns the parsed GPU particle system
  66605. */
  66606. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66607. }
  66608. }
  66609. declare module BABYLON {
  66610. /**
  66611. * Represents a set of particle systems working together to create a specific effect
  66612. */
  66613. export class ParticleSystemSet implements IDisposable {
  66614. /**
  66615. * Gets or sets base Assets URL
  66616. */
  66617. static BaseAssetsUrl: string;
  66618. private _emitterCreationOptions;
  66619. private _emitterNode;
  66620. /**
  66621. * Gets the particle system list
  66622. */
  66623. systems: IParticleSystem[];
  66624. /**
  66625. * Gets the emitter node used with this set
  66626. */
  66627. get emitterNode(): Nullable<TransformNode>;
  66628. /**
  66629. * Creates a new emitter mesh as a sphere
  66630. * @param options defines the options used to create the sphere
  66631. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66632. * @param scene defines the hosting scene
  66633. */
  66634. setEmitterAsSphere(options: {
  66635. diameter: number;
  66636. segments: number;
  66637. color: Color3;
  66638. }, renderingGroupId: number, scene: Scene): void;
  66639. /**
  66640. * Starts all particle systems of the set
  66641. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66642. */
  66643. start(emitter?: AbstractMesh): void;
  66644. /**
  66645. * Release all associated resources
  66646. */
  66647. dispose(): void;
  66648. /**
  66649. * Serialize the set into a JSON compatible object
  66650. * @param serializeTexture defines if the texture must be serialized as well
  66651. * @returns a JSON compatible representation of the set
  66652. */
  66653. serialize(serializeTexture?: boolean): any;
  66654. /**
  66655. * Parse a new ParticleSystemSet from a serialized source
  66656. * @param data defines a JSON compatible representation of the set
  66657. * @param scene defines the hosting scene
  66658. * @param gpu defines if we want GPU particles or CPU particles
  66659. * @returns a new ParticleSystemSet
  66660. */
  66661. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66662. }
  66663. }
  66664. declare module BABYLON {
  66665. /**
  66666. * This class is made for on one-liner static method to help creating particle system set.
  66667. */
  66668. export class ParticleHelper {
  66669. /**
  66670. * Gets or sets base Assets URL
  66671. */
  66672. static BaseAssetsUrl: string;
  66673. /** Define the Url to load snippets */
  66674. static SnippetUrl: string;
  66675. /**
  66676. * Create a default particle system that you can tweak
  66677. * @param emitter defines the emitter to use
  66678. * @param capacity defines the system capacity (default is 500 particles)
  66679. * @param scene defines the hosting scene
  66680. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66681. * @returns the new Particle system
  66682. */
  66683. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66684. /**
  66685. * This is the main static method (one-liner) of this helper to create different particle systems
  66686. * @param type This string represents the type to the particle system to create
  66687. * @param scene The scene where the particle system should live
  66688. * @param gpu If the system will use gpu
  66689. * @returns the ParticleSystemSet created
  66690. */
  66691. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66692. /**
  66693. * Static function used to export a particle system to a ParticleSystemSet variable.
  66694. * Please note that the emitter shape is not exported
  66695. * @param systems defines the particle systems to export
  66696. * @returns the created particle system set
  66697. */
  66698. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66699. /**
  66700. * Creates a particle system from a snippet saved in a remote file
  66701. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66702. * @param url defines the url to load from
  66703. * @param scene defines the hosting scene
  66704. * @param gpu If the system will use gpu
  66705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66706. * @returns a promise that will resolve to the new particle system
  66707. */
  66708. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66709. /**
  66710. * Creates a particle system from a snippet saved by the particle system editor
  66711. * @param snippetId defines the snippet to load
  66712. * @param scene defines the hosting scene
  66713. * @param gpu If the system will use gpu
  66714. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66715. * @returns a promise that will resolve to the new particle system
  66716. */
  66717. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66718. }
  66719. }
  66720. declare module BABYLON {
  66721. interface Engine {
  66722. /**
  66723. * Create an effect to use with particle systems.
  66724. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66725. * the particle system for which you want to create a custom effect in the last parameter
  66726. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66727. * @param uniformsNames defines a list of attribute names
  66728. * @param samplers defines an array of string used to represent textures
  66729. * @param defines defines the string containing the defines to use to compile the shaders
  66730. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66731. * @param onCompiled defines a function to call when the effect creation is successful
  66732. * @param onError defines a function to call when the effect creation has failed
  66733. * @param particleSystem the particle system you want to create the effect for
  66734. * @returns the new Effect
  66735. */
  66736. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66737. }
  66738. interface Mesh {
  66739. /**
  66740. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66741. * @returns an array of IParticleSystem
  66742. */
  66743. getEmittedParticleSystems(): IParticleSystem[];
  66744. /**
  66745. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66746. * @returns an array of IParticleSystem
  66747. */
  66748. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66749. }
  66750. }
  66751. declare module BABYLON {
  66752. /** Defines the 4 color options */
  66753. export enum PointColor {
  66754. /** color value */
  66755. Color = 2,
  66756. /** uv value */
  66757. UV = 1,
  66758. /** random value */
  66759. Random = 0,
  66760. /** stated value */
  66761. Stated = 3
  66762. }
  66763. /**
  66764. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66765. * 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.
  66766. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66767. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66768. *
  66769. * Full documentation here : TO BE ENTERED
  66770. */
  66771. export class PointsCloudSystem implements IDisposable {
  66772. /**
  66773. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66774. * Example : var p = SPS.particles[i];
  66775. */
  66776. particles: CloudPoint[];
  66777. /**
  66778. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66779. */
  66780. nbParticles: number;
  66781. /**
  66782. * This a counter for your own usage. It's not set by any SPS functions.
  66783. */
  66784. counter: number;
  66785. /**
  66786. * The PCS name. This name is also given to the underlying mesh.
  66787. */
  66788. name: string;
  66789. /**
  66790. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66791. */
  66792. mesh: Mesh;
  66793. /**
  66794. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66795. * Please read :
  66796. */
  66797. vars: any;
  66798. /**
  66799. * @hidden
  66800. */
  66801. _size: number;
  66802. private _scene;
  66803. private _promises;
  66804. private _positions;
  66805. private _indices;
  66806. private _normals;
  66807. private _colors;
  66808. private _uvs;
  66809. private _indices32;
  66810. private _positions32;
  66811. private _colors32;
  66812. private _uvs32;
  66813. private _updatable;
  66814. private _isVisibilityBoxLocked;
  66815. private _alwaysVisible;
  66816. private _groups;
  66817. private _groupCounter;
  66818. private _computeParticleColor;
  66819. private _computeParticleTexture;
  66820. private _computeParticleRotation;
  66821. private _computeBoundingBox;
  66822. private _isReady;
  66823. /**
  66824. * Creates a PCS (Points Cloud System) object
  66825. * @param name (String) is the PCS name, this will be the underlying mesh name
  66826. * @param pointSize (number) is the size for each point
  66827. * @param scene (Scene) is the scene in which the PCS is added
  66828. * @param options defines the options of the PCS e.g.
  66829. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66830. */
  66831. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66832. updatable?: boolean;
  66833. });
  66834. /**
  66835. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66836. * If no points were added to the PCS, the returned mesh is just a single point.
  66837. * @returns a promise for the created mesh
  66838. */
  66839. buildMeshAsync(): Promise<Mesh>;
  66840. /**
  66841. * @hidden
  66842. */
  66843. private _buildMesh;
  66844. private _addParticle;
  66845. private _randomUnitVector;
  66846. private _getColorIndicesForCoord;
  66847. private _setPointsColorOrUV;
  66848. private _colorFromTexture;
  66849. private _calculateDensity;
  66850. /**
  66851. * Adds points to the PCS in random positions within a unit sphere
  66852. * @param nb (positive integer) the number of particles to be created from this model
  66853. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66854. * @returns the number of groups in the system
  66855. */
  66856. addPoints(nb: number, pointFunction?: any): number;
  66857. /**
  66858. * Adds points to the PCS from the surface of the model shape
  66859. * @param mesh is any Mesh object that will be used as a surface model for the points
  66860. * @param nb (positive integer) the number of particles to be created from this model
  66861. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66862. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66863. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66864. * @returns the number of groups in the system
  66865. */
  66866. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66867. /**
  66868. * Adds points to the PCS inside the model shape
  66869. * @param mesh is any Mesh object that will be used as a surface model for the points
  66870. * @param nb (positive integer) the number of particles to be created from this model
  66871. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66872. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66873. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66874. * @returns the number of groups in the system
  66875. */
  66876. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66877. /**
  66878. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66879. * This method calls `updateParticle()` for each particle of the SPS.
  66880. * For an animated SPS, it is usually called within the render loop.
  66881. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66882. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66883. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66884. * @returns the PCS.
  66885. */
  66886. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66887. /**
  66888. * Disposes the PCS.
  66889. */
  66890. dispose(): void;
  66891. /**
  66892. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66893. * doc :
  66894. * @returns the PCS.
  66895. */
  66896. refreshVisibleSize(): PointsCloudSystem;
  66897. /**
  66898. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66899. * @param size the size (float) of the visibility box
  66900. * note : this doesn't lock the PCS mesh bounding box.
  66901. * doc :
  66902. */
  66903. setVisibilityBox(size: number): void;
  66904. /**
  66905. * Gets whether the PCS is always visible or not
  66906. * doc :
  66907. */
  66908. get isAlwaysVisible(): boolean;
  66909. /**
  66910. * Sets the PCS as always visible or not
  66911. * doc :
  66912. */
  66913. set isAlwaysVisible(val: boolean);
  66914. /**
  66915. * Tells to `setParticles()` to compute the particle rotations or not
  66916. * Default value : false. The PCS is faster when it's set to false
  66917. * Note : particle rotations are only applied to parent particles
  66918. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66919. */
  66920. set computeParticleRotation(val: boolean);
  66921. /**
  66922. * Tells to `setParticles()` to compute the particle colors or not.
  66923. * Default value : true. The PCS is faster when it's set to false.
  66924. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66925. */
  66926. set computeParticleColor(val: boolean);
  66927. set computeParticleTexture(val: boolean);
  66928. /**
  66929. * Gets if `setParticles()` computes the particle colors or not.
  66930. * Default value : false. The PCS is faster when it's set to false.
  66931. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66932. */
  66933. get computeParticleColor(): boolean;
  66934. /**
  66935. * Gets if `setParticles()` computes the particle textures or not.
  66936. * Default value : false. The PCS is faster when it's set to false.
  66937. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66938. */
  66939. get computeParticleTexture(): boolean;
  66940. /**
  66941. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66942. */
  66943. set computeBoundingBox(val: boolean);
  66944. /**
  66945. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66946. */
  66947. get computeBoundingBox(): boolean;
  66948. /**
  66949. * This function does nothing. It may be overwritten to set all the particle first values.
  66950. * The PCS doesn't call this function, you may have to call it by your own.
  66951. * doc :
  66952. */
  66953. initParticles(): void;
  66954. /**
  66955. * This function does nothing. It may be overwritten to recycle a particle
  66956. * The PCS doesn't call this function, you can to call it
  66957. * doc :
  66958. * @param particle The particle to recycle
  66959. * @returns the recycled particle
  66960. */
  66961. recycleParticle(particle: CloudPoint): CloudPoint;
  66962. /**
  66963. * Updates a particle : this function should be overwritten by the user.
  66964. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66965. * doc :
  66966. * @example : just set a particle position or velocity and recycle conditions
  66967. * @param particle The particle to update
  66968. * @returns the updated particle
  66969. */
  66970. updateParticle(particle: CloudPoint): CloudPoint;
  66971. /**
  66972. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66973. * This does nothing and may be overwritten by the user.
  66974. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66975. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66976. * @param update the boolean update value actually passed to setParticles()
  66977. */
  66978. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66979. /**
  66980. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66981. * This will be passed three parameters.
  66982. * This does nothing and may be overwritten by the user.
  66983. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66984. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66985. * @param update the boolean update value actually passed to setParticles()
  66986. */
  66987. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66988. }
  66989. }
  66990. declare module BABYLON {
  66991. /**
  66992. * Represents one particle of a points cloud system.
  66993. */
  66994. export class CloudPoint {
  66995. /**
  66996. * particle global index
  66997. */
  66998. idx: number;
  66999. /**
  67000. * The color of the particle
  67001. */
  67002. color: Nullable<Color4>;
  67003. /**
  67004. * The world space position of the particle.
  67005. */
  67006. position: Vector3;
  67007. /**
  67008. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67009. */
  67010. rotation: Vector3;
  67011. /**
  67012. * The world space rotation quaternion of the particle.
  67013. */
  67014. rotationQuaternion: Nullable<Quaternion>;
  67015. /**
  67016. * The uv of the particle.
  67017. */
  67018. uv: Nullable<Vector2>;
  67019. /**
  67020. * The current speed of the particle.
  67021. */
  67022. velocity: Vector3;
  67023. /**
  67024. * The pivot point in the particle local space.
  67025. */
  67026. pivot: Vector3;
  67027. /**
  67028. * Must the particle be translated from its pivot point in its local space ?
  67029. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67030. * Default : false
  67031. */
  67032. translateFromPivot: boolean;
  67033. /**
  67034. * Index of this particle in the global "positions" array (Internal use)
  67035. * @hidden
  67036. */
  67037. _pos: number;
  67038. /**
  67039. * @hidden Index of this particle in the global "indices" array (Internal use)
  67040. */
  67041. _ind: number;
  67042. /**
  67043. * Group this particle belongs to
  67044. */
  67045. _group: PointsGroup;
  67046. /**
  67047. * Group id of this particle
  67048. */
  67049. groupId: number;
  67050. /**
  67051. * Index of the particle in its group id (Internal use)
  67052. */
  67053. idxInGroup: number;
  67054. /**
  67055. * @hidden Particle BoundingInfo object (Internal use)
  67056. */
  67057. _boundingInfo: BoundingInfo;
  67058. /**
  67059. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67060. */
  67061. _pcs: PointsCloudSystem;
  67062. /**
  67063. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67064. */
  67065. _stillInvisible: boolean;
  67066. /**
  67067. * @hidden Last computed particle rotation matrix
  67068. */
  67069. _rotationMatrix: number[];
  67070. /**
  67071. * Parent particle Id, if any.
  67072. * Default null.
  67073. */
  67074. parentId: Nullable<number>;
  67075. /**
  67076. * @hidden Internal global position in the PCS.
  67077. */
  67078. _globalPosition: Vector3;
  67079. /**
  67080. * Creates a Point Cloud object.
  67081. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67082. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67083. * @param group (PointsGroup) is the group the particle belongs to
  67084. * @param groupId (integer) is the group identifier in the PCS.
  67085. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67086. * @param pcs defines the PCS it is associated to
  67087. */
  67088. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67089. /**
  67090. * get point size
  67091. */
  67092. get size(): Vector3;
  67093. /**
  67094. * Set point size
  67095. */
  67096. set size(scale: Vector3);
  67097. /**
  67098. * Legacy support, changed quaternion to rotationQuaternion
  67099. */
  67100. get quaternion(): Nullable<Quaternion>;
  67101. /**
  67102. * Legacy support, changed quaternion to rotationQuaternion
  67103. */
  67104. set quaternion(q: Nullable<Quaternion>);
  67105. /**
  67106. * Returns a boolean. True if the particle intersects a mesh, else false
  67107. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67108. * @param target is the object (point or mesh) what the intersection is computed against
  67109. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67110. * @returns true if it intersects
  67111. */
  67112. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67113. /**
  67114. * get the rotation matrix of the particle
  67115. * @hidden
  67116. */
  67117. getRotationMatrix(m: Matrix): void;
  67118. }
  67119. /**
  67120. * Represents a group of points in a points cloud system
  67121. * * PCS internal tool, don't use it manually.
  67122. */
  67123. export class PointsGroup {
  67124. /**
  67125. * The group id
  67126. * @hidden
  67127. */
  67128. groupID: number;
  67129. /**
  67130. * image data for group (internal use)
  67131. * @hidden
  67132. */
  67133. _groupImageData: Nullable<ArrayBufferView>;
  67134. /**
  67135. * Image Width (internal use)
  67136. * @hidden
  67137. */
  67138. _groupImgWidth: number;
  67139. /**
  67140. * Image Height (internal use)
  67141. * @hidden
  67142. */
  67143. _groupImgHeight: number;
  67144. /**
  67145. * Custom position function (internal use)
  67146. * @hidden
  67147. */
  67148. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67149. /**
  67150. * density per facet for surface points
  67151. * @hidden
  67152. */
  67153. _groupDensity: number[];
  67154. /**
  67155. * Only when points are colored by texture carries pointer to texture list array
  67156. * @hidden
  67157. */
  67158. _textureNb: number;
  67159. /**
  67160. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67161. * PCS internal tool, don't use it manually.
  67162. * @hidden
  67163. */
  67164. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67165. }
  67166. }
  67167. declare module BABYLON {
  67168. interface Scene {
  67169. /** @hidden (Backing field) */
  67170. _physicsEngine: Nullable<IPhysicsEngine>;
  67171. /** @hidden */
  67172. _physicsTimeAccumulator: number;
  67173. /**
  67174. * Gets the current physics engine
  67175. * @returns a IPhysicsEngine or null if none attached
  67176. */
  67177. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67178. /**
  67179. * Enables physics to the current scene
  67180. * @param gravity defines the scene's gravity for the physics engine
  67181. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67182. * @return a boolean indicating if the physics engine was initialized
  67183. */
  67184. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67185. /**
  67186. * Disables and disposes the physics engine associated with the scene
  67187. */
  67188. disablePhysicsEngine(): void;
  67189. /**
  67190. * Gets a boolean indicating if there is an active physics engine
  67191. * @returns a boolean indicating if there is an active physics engine
  67192. */
  67193. isPhysicsEnabled(): boolean;
  67194. /**
  67195. * Deletes a physics compound impostor
  67196. * @param compound defines the compound to delete
  67197. */
  67198. deleteCompoundImpostor(compound: any): void;
  67199. /**
  67200. * An event triggered when physic simulation is about to be run
  67201. */
  67202. onBeforePhysicsObservable: Observable<Scene>;
  67203. /**
  67204. * An event triggered when physic simulation has been done
  67205. */
  67206. onAfterPhysicsObservable: Observable<Scene>;
  67207. }
  67208. interface AbstractMesh {
  67209. /** @hidden */
  67210. _physicsImpostor: Nullable<PhysicsImpostor>;
  67211. /**
  67212. * Gets or sets impostor used for physic simulation
  67213. * @see http://doc.babylonjs.com/features/physics_engine
  67214. */
  67215. physicsImpostor: Nullable<PhysicsImpostor>;
  67216. /**
  67217. * Gets the current physics impostor
  67218. * @see http://doc.babylonjs.com/features/physics_engine
  67219. * @returns a physics impostor or null
  67220. */
  67221. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67222. /** Apply a physic impulse to the mesh
  67223. * @param force defines the force to apply
  67224. * @param contactPoint defines where to apply the force
  67225. * @returns the current mesh
  67226. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67227. */
  67228. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67229. /**
  67230. * Creates a physic joint between two meshes
  67231. * @param otherMesh defines the other mesh to use
  67232. * @param pivot1 defines the pivot to use on this mesh
  67233. * @param pivot2 defines the pivot to use on the other mesh
  67234. * @param options defines additional options (can be plugin dependent)
  67235. * @returns the current mesh
  67236. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67237. */
  67238. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67239. /** @hidden */
  67240. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67241. }
  67242. /**
  67243. * Defines the physics engine scene component responsible to manage a physics engine
  67244. */
  67245. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67246. /**
  67247. * The component name helpful to identify the component in the list of scene components.
  67248. */
  67249. readonly name: string;
  67250. /**
  67251. * The scene the component belongs to.
  67252. */
  67253. scene: Scene;
  67254. /**
  67255. * Creates a new instance of the component for the given scene
  67256. * @param scene Defines the scene to register the component in
  67257. */
  67258. constructor(scene: Scene);
  67259. /**
  67260. * Registers the component in a given scene
  67261. */
  67262. register(): void;
  67263. /**
  67264. * Rebuilds the elements related to this component in case of
  67265. * context lost for instance.
  67266. */
  67267. rebuild(): void;
  67268. /**
  67269. * Disposes the component and the associated ressources
  67270. */
  67271. dispose(): void;
  67272. }
  67273. }
  67274. declare module BABYLON {
  67275. /**
  67276. * A helper for physics simulations
  67277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67278. */
  67279. export class PhysicsHelper {
  67280. private _scene;
  67281. private _physicsEngine;
  67282. /**
  67283. * Initializes the Physics helper
  67284. * @param scene Babylon.js scene
  67285. */
  67286. constructor(scene: Scene);
  67287. /**
  67288. * Applies a radial explosion impulse
  67289. * @param origin the origin of the explosion
  67290. * @param radiusOrEventOptions the radius or the options of radial explosion
  67291. * @param strength the explosion strength
  67292. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67293. * @returns A physics radial explosion event, or null
  67294. */
  67295. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67296. /**
  67297. * Applies a radial explosion force
  67298. * @param origin the origin of the explosion
  67299. * @param radiusOrEventOptions the radius or the options of radial explosion
  67300. * @param strength the explosion strength
  67301. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67302. * @returns A physics radial explosion event, or null
  67303. */
  67304. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67305. /**
  67306. * Creates a gravitational field
  67307. * @param origin the origin of the explosion
  67308. * @param radiusOrEventOptions the radius or the options of radial explosion
  67309. * @param strength the explosion strength
  67310. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67311. * @returns A physics gravitational field event, or null
  67312. */
  67313. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67314. /**
  67315. * Creates a physics updraft event
  67316. * @param origin the origin of the updraft
  67317. * @param radiusOrEventOptions the radius or the options of the updraft
  67318. * @param strength the strength of the updraft
  67319. * @param height the height of the updraft
  67320. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67321. * @returns A physics updraft event, or null
  67322. */
  67323. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67324. /**
  67325. * Creates a physics vortex event
  67326. * @param origin the of the vortex
  67327. * @param radiusOrEventOptions the radius or the options of the vortex
  67328. * @param strength the strength of the vortex
  67329. * @param height the height of the vortex
  67330. * @returns a Physics vortex event, or null
  67331. * A physics vortex event or null
  67332. */
  67333. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67334. }
  67335. /**
  67336. * Represents a physics radial explosion event
  67337. */
  67338. class PhysicsRadialExplosionEvent {
  67339. private _scene;
  67340. private _options;
  67341. private _sphere;
  67342. private _dataFetched;
  67343. /**
  67344. * Initializes a radial explosioin event
  67345. * @param _scene BabylonJS scene
  67346. * @param _options The options for the vortex event
  67347. */
  67348. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67349. /**
  67350. * Returns the data related to the radial explosion event (sphere).
  67351. * @returns The radial explosion event data
  67352. */
  67353. getData(): PhysicsRadialExplosionEventData;
  67354. /**
  67355. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67356. * @param impostor A physics imposter
  67357. * @param origin the origin of the explosion
  67358. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67359. */
  67360. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67361. /**
  67362. * Triggers affecterd impostors callbacks
  67363. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67364. */
  67365. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67366. /**
  67367. * Disposes the sphere.
  67368. * @param force Specifies if the sphere should be disposed by force
  67369. */
  67370. dispose(force?: boolean): void;
  67371. /*** Helpers ***/
  67372. private _prepareSphere;
  67373. private _intersectsWithSphere;
  67374. }
  67375. /**
  67376. * Represents a gravitational field event
  67377. */
  67378. class PhysicsGravitationalFieldEvent {
  67379. private _physicsHelper;
  67380. private _scene;
  67381. private _origin;
  67382. private _options;
  67383. private _tickCallback;
  67384. private _sphere;
  67385. private _dataFetched;
  67386. /**
  67387. * Initializes the physics gravitational field event
  67388. * @param _physicsHelper A physics helper
  67389. * @param _scene BabylonJS scene
  67390. * @param _origin The origin position of the gravitational field event
  67391. * @param _options The options for the vortex event
  67392. */
  67393. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67394. /**
  67395. * Returns the data related to the gravitational field event (sphere).
  67396. * @returns A gravitational field event
  67397. */
  67398. getData(): PhysicsGravitationalFieldEventData;
  67399. /**
  67400. * Enables the gravitational field.
  67401. */
  67402. enable(): void;
  67403. /**
  67404. * Disables the gravitational field.
  67405. */
  67406. disable(): void;
  67407. /**
  67408. * Disposes the sphere.
  67409. * @param force The force to dispose from the gravitational field event
  67410. */
  67411. dispose(force?: boolean): void;
  67412. private _tick;
  67413. }
  67414. /**
  67415. * Represents a physics updraft event
  67416. */
  67417. class PhysicsUpdraftEvent {
  67418. private _scene;
  67419. private _origin;
  67420. private _options;
  67421. private _physicsEngine;
  67422. private _originTop;
  67423. private _originDirection;
  67424. private _tickCallback;
  67425. private _cylinder;
  67426. private _cylinderPosition;
  67427. private _dataFetched;
  67428. /**
  67429. * Initializes the physics updraft event
  67430. * @param _scene BabylonJS scene
  67431. * @param _origin The origin position of the updraft
  67432. * @param _options The options for the updraft event
  67433. */
  67434. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67435. /**
  67436. * Returns the data related to the updraft event (cylinder).
  67437. * @returns A physics updraft event
  67438. */
  67439. getData(): PhysicsUpdraftEventData;
  67440. /**
  67441. * Enables the updraft.
  67442. */
  67443. enable(): void;
  67444. /**
  67445. * Disables the updraft.
  67446. */
  67447. disable(): void;
  67448. /**
  67449. * Disposes the cylinder.
  67450. * @param force Specifies if the updraft should be disposed by force
  67451. */
  67452. dispose(force?: boolean): void;
  67453. private getImpostorHitData;
  67454. private _tick;
  67455. /*** Helpers ***/
  67456. private _prepareCylinder;
  67457. private _intersectsWithCylinder;
  67458. }
  67459. /**
  67460. * Represents a physics vortex event
  67461. */
  67462. class PhysicsVortexEvent {
  67463. private _scene;
  67464. private _origin;
  67465. private _options;
  67466. private _physicsEngine;
  67467. private _originTop;
  67468. private _tickCallback;
  67469. private _cylinder;
  67470. private _cylinderPosition;
  67471. private _dataFetched;
  67472. /**
  67473. * Initializes the physics vortex event
  67474. * @param _scene The BabylonJS scene
  67475. * @param _origin The origin position of the vortex
  67476. * @param _options The options for the vortex event
  67477. */
  67478. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67479. /**
  67480. * Returns the data related to the vortex event (cylinder).
  67481. * @returns The physics vortex event data
  67482. */
  67483. getData(): PhysicsVortexEventData;
  67484. /**
  67485. * Enables the vortex.
  67486. */
  67487. enable(): void;
  67488. /**
  67489. * Disables the cortex.
  67490. */
  67491. disable(): void;
  67492. /**
  67493. * Disposes the sphere.
  67494. * @param force
  67495. */
  67496. dispose(force?: boolean): void;
  67497. private getImpostorHitData;
  67498. private _tick;
  67499. /*** Helpers ***/
  67500. private _prepareCylinder;
  67501. private _intersectsWithCylinder;
  67502. }
  67503. /**
  67504. * Options fot the radial explosion event
  67505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67506. */
  67507. export class PhysicsRadialExplosionEventOptions {
  67508. /**
  67509. * The radius of the sphere for the radial explosion.
  67510. */
  67511. radius: number;
  67512. /**
  67513. * The strenth of the explosion.
  67514. */
  67515. strength: number;
  67516. /**
  67517. * The strenght of the force in correspondence to the distance of the affected object
  67518. */
  67519. falloff: PhysicsRadialImpulseFalloff;
  67520. /**
  67521. * Sphere options for the radial explosion.
  67522. */
  67523. sphere: {
  67524. segments: number;
  67525. diameter: number;
  67526. };
  67527. /**
  67528. * Sphere options for the radial explosion.
  67529. */
  67530. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67531. }
  67532. /**
  67533. * Options fot the updraft event
  67534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67535. */
  67536. export class PhysicsUpdraftEventOptions {
  67537. /**
  67538. * The radius of the cylinder for the vortex
  67539. */
  67540. radius: number;
  67541. /**
  67542. * The strenth of the updraft.
  67543. */
  67544. strength: number;
  67545. /**
  67546. * The height of the cylinder for the updraft.
  67547. */
  67548. height: number;
  67549. /**
  67550. * The mode for the the updraft.
  67551. */
  67552. updraftMode: PhysicsUpdraftMode;
  67553. }
  67554. /**
  67555. * Options fot the vortex event
  67556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67557. */
  67558. export class PhysicsVortexEventOptions {
  67559. /**
  67560. * The radius of the cylinder for the vortex
  67561. */
  67562. radius: number;
  67563. /**
  67564. * The strenth of the vortex.
  67565. */
  67566. strength: number;
  67567. /**
  67568. * The height of the cylinder for the vortex.
  67569. */
  67570. height: number;
  67571. /**
  67572. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67573. */
  67574. centripetalForceThreshold: number;
  67575. /**
  67576. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67577. */
  67578. centripetalForceMultiplier: number;
  67579. /**
  67580. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67581. */
  67582. centrifugalForceMultiplier: number;
  67583. /**
  67584. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67585. */
  67586. updraftForceMultiplier: number;
  67587. }
  67588. /**
  67589. * The strenght of the force in correspondence to the distance of the affected object
  67590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67591. */
  67592. export enum PhysicsRadialImpulseFalloff {
  67593. /** Defines that impulse is constant in strength across it's whole radius */
  67594. Constant = 0,
  67595. /** Defines that impulse gets weaker if it's further from the origin */
  67596. Linear = 1
  67597. }
  67598. /**
  67599. * The strength of the force in correspondence to the distance of the affected object
  67600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67601. */
  67602. export enum PhysicsUpdraftMode {
  67603. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67604. Center = 0,
  67605. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67606. Perpendicular = 1
  67607. }
  67608. /**
  67609. * Interface for a physics hit data
  67610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67611. */
  67612. export interface PhysicsHitData {
  67613. /**
  67614. * The force applied at the contact point
  67615. */
  67616. force: Vector3;
  67617. /**
  67618. * The contact point
  67619. */
  67620. contactPoint: Vector3;
  67621. /**
  67622. * The distance from the origin to the contact point
  67623. */
  67624. distanceFromOrigin: number;
  67625. }
  67626. /**
  67627. * Interface for radial explosion event data
  67628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67629. */
  67630. export interface PhysicsRadialExplosionEventData {
  67631. /**
  67632. * A sphere used for the radial explosion event
  67633. */
  67634. sphere: Mesh;
  67635. }
  67636. /**
  67637. * Interface for gravitational field event data
  67638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67639. */
  67640. export interface PhysicsGravitationalFieldEventData {
  67641. /**
  67642. * A sphere mesh used for the gravitational field event
  67643. */
  67644. sphere: Mesh;
  67645. }
  67646. /**
  67647. * Interface for updraft event data
  67648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67649. */
  67650. export interface PhysicsUpdraftEventData {
  67651. /**
  67652. * A cylinder used for the updraft event
  67653. */
  67654. cylinder: Mesh;
  67655. }
  67656. /**
  67657. * Interface for vortex event data
  67658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67659. */
  67660. export interface PhysicsVortexEventData {
  67661. /**
  67662. * A cylinder used for the vortex event
  67663. */
  67664. cylinder: Mesh;
  67665. }
  67666. /**
  67667. * Interface for an affected physics impostor
  67668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67669. */
  67670. export interface PhysicsAffectedImpostorWithData {
  67671. /**
  67672. * The impostor affected by the effect
  67673. */
  67674. impostor: PhysicsImpostor;
  67675. /**
  67676. * The data about the hit/horce from the explosion
  67677. */
  67678. hitData: PhysicsHitData;
  67679. }
  67680. }
  67681. declare module BABYLON {
  67682. /** @hidden */
  67683. export var blackAndWhitePixelShader: {
  67684. name: string;
  67685. shader: string;
  67686. };
  67687. }
  67688. declare module BABYLON {
  67689. /**
  67690. * Post process used to render in black and white
  67691. */
  67692. export class BlackAndWhitePostProcess extends PostProcess {
  67693. /**
  67694. * Linear about to convert he result to black and white (default: 1)
  67695. */
  67696. degree: number;
  67697. /**
  67698. * Creates a black and white post process
  67699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67700. * @param name The name of the effect.
  67701. * @param options The required width/height ratio to downsize to before computing the render pass.
  67702. * @param camera The camera to apply the render pass to.
  67703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67704. * @param engine The engine which the post process will be applied. (default: current engine)
  67705. * @param reusable If the post process can be reused on the same frame. (default: false)
  67706. */
  67707. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67708. }
  67709. }
  67710. declare module BABYLON {
  67711. /**
  67712. * This represents a set of one or more post processes in Babylon.
  67713. * A post process can be used to apply a shader to a texture after it is rendered.
  67714. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67715. */
  67716. export class PostProcessRenderEffect {
  67717. private _postProcesses;
  67718. private _getPostProcesses;
  67719. private _singleInstance;
  67720. private _cameras;
  67721. private _indicesForCamera;
  67722. /**
  67723. * Name of the effect
  67724. * @hidden
  67725. */
  67726. _name: string;
  67727. /**
  67728. * Instantiates a post process render effect.
  67729. * A post process can be used to apply a shader to a texture after it is rendered.
  67730. * @param engine The engine the effect is tied to
  67731. * @param name The name of the effect
  67732. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67733. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67734. */
  67735. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67736. /**
  67737. * Checks if all the post processes in the effect are supported.
  67738. */
  67739. get isSupported(): boolean;
  67740. /**
  67741. * Updates the current state of the effect
  67742. * @hidden
  67743. */
  67744. _update(): void;
  67745. /**
  67746. * Attaches the effect on cameras
  67747. * @param cameras The camera to attach to.
  67748. * @hidden
  67749. */
  67750. _attachCameras(cameras: Camera): void;
  67751. /**
  67752. * Attaches the effect on cameras
  67753. * @param cameras The camera to attach to.
  67754. * @hidden
  67755. */
  67756. _attachCameras(cameras: Camera[]): void;
  67757. /**
  67758. * Detaches the effect on cameras
  67759. * @param cameras The camera to detatch from.
  67760. * @hidden
  67761. */
  67762. _detachCameras(cameras: Camera): void;
  67763. /**
  67764. * Detatches the effect on cameras
  67765. * @param cameras The camera to detatch from.
  67766. * @hidden
  67767. */
  67768. _detachCameras(cameras: Camera[]): void;
  67769. /**
  67770. * Enables the effect on given cameras
  67771. * @param cameras The camera to enable.
  67772. * @hidden
  67773. */
  67774. _enable(cameras: Camera): void;
  67775. /**
  67776. * Enables the effect on given cameras
  67777. * @param cameras The camera to enable.
  67778. * @hidden
  67779. */
  67780. _enable(cameras: Nullable<Camera[]>): void;
  67781. /**
  67782. * Disables the effect on the given cameras
  67783. * @param cameras The camera to disable.
  67784. * @hidden
  67785. */
  67786. _disable(cameras: Camera): void;
  67787. /**
  67788. * Disables the effect on the given cameras
  67789. * @param cameras The camera to disable.
  67790. * @hidden
  67791. */
  67792. _disable(cameras: Nullable<Camera[]>): void;
  67793. /**
  67794. * Gets a list of the post processes contained in the effect.
  67795. * @param camera The camera to get the post processes on.
  67796. * @returns The list of the post processes in the effect.
  67797. */
  67798. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67799. }
  67800. }
  67801. declare module BABYLON {
  67802. /** @hidden */
  67803. export var extractHighlightsPixelShader: {
  67804. name: string;
  67805. shader: string;
  67806. };
  67807. }
  67808. declare module BABYLON {
  67809. /**
  67810. * 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.
  67811. */
  67812. export class ExtractHighlightsPostProcess extends PostProcess {
  67813. /**
  67814. * The luminance threshold, pixels below this value will be set to black.
  67815. */
  67816. threshold: number;
  67817. /** @hidden */
  67818. _exposure: number;
  67819. /**
  67820. * Post process which has the input texture to be used when performing highlight extraction
  67821. * @hidden
  67822. */
  67823. _inputPostProcess: Nullable<PostProcess>;
  67824. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67825. }
  67826. }
  67827. declare module BABYLON {
  67828. /** @hidden */
  67829. export var bloomMergePixelShader: {
  67830. name: string;
  67831. shader: string;
  67832. };
  67833. }
  67834. declare module BABYLON {
  67835. /**
  67836. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67837. */
  67838. export class BloomMergePostProcess extends PostProcess {
  67839. /** Weight of the bloom to be added to the original input. */
  67840. weight: number;
  67841. /**
  67842. * Creates a new instance of @see BloomMergePostProcess
  67843. * @param name The name of the effect.
  67844. * @param originalFromInput Post process which's input will be used for the merge.
  67845. * @param blurred Blurred highlights post process which's output will be used.
  67846. * @param weight Weight of the bloom to be added to the original input.
  67847. * @param options The required width/height ratio to downsize to before computing the render pass.
  67848. * @param camera The camera to apply the render pass to.
  67849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67850. * @param engine The engine which the post process will be applied. (default: current engine)
  67851. * @param reusable If the post process can be reused on the same frame. (default: false)
  67852. * @param textureType Type of textures used when performing the post process. (default: 0)
  67853. * @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)
  67854. */
  67855. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67856. /** Weight of the bloom to be added to the original input. */
  67857. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67858. }
  67859. }
  67860. declare module BABYLON {
  67861. /**
  67862. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67863. */
  67864. export class BloomEffect extends PostProcessRenderEffect {
  67865. private bloomScale;
  67866. /**
  67867. * @hidden Internal
  67868. */
  67869. _effects: Array<PostProcess>;
  67870. /**
  67871. * @hidden Internal
  67872. */
  67873. _downscale: ExtractHighlightsPostProcess;
  67874. private _blurX;
  67875. private _blurY;
  67876. private _merge;
  67877. /**
  67878. * The luminance threshold to find bright areas of the image to bloom.
  67879. */
  67880. get threshold(): number;
  67881. set threshold(value: number);
  67882. /**
  67883. * The strength of the bloom.
  67884. */
  67885. get weight(): number;
  67886. set weight(value: number);
  67887. /**
  67888. * Specifies the size of the bloom blur kernel, relative to the final output size
  67889. */
  67890. get kernel(): number;
  67891. set kernel(value: number);
  67892. /**
  67893. * Creates a new instance of @see BloomEffect
  67894. * @param scene The scene the effect belongs to.
  67895. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67896. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67897. * @param bloomWeight The the strength of bloom.
  67898. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67899. * @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)
  67900. */
  67901. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67902. /**
  67903. * Disposes each of the internal effects for a given camera.
  67904. * @param camera The camera to dispose the effect on.
  67905. */
  67906. disposeEffects(camera: Camera): void;
  67907. /**
  67908. * @hidden Internal
  67909. */
  67910. _updateEffects(): void;
  67911. /**
  67912. * Internal
  67913. * @returns if all the contained post processes are ready.
  67914. * @hidden
  67915. */
  67916. _isReady(): boolean;
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /** @hidden */
  67921. export var chromaticAberrationPixelShader: {
  67922. name: string;
  67923. shader: string;
  67924. };
  67925. }
  67926. declare module BABYLON {
  67927. /**
  67928. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67929. */
  67930. export class ChromaticAberrationPostProcess extends PostProcess {
  67931. /**
  67932. * The amount of seperation of rgb channels (default: 30)
  67933. */
  67934. aberrationAmount: number;
  67935. /**
  67936. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67937. */
  67938. radialIntensity: number;
  67939. /**
  67940. * 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))
  67941. */
  67942. direction: Vector2;
  67943. /**
  67944. * 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))
  67945. */
  67946. centerPosition: Vector2;
  67947. /**
  67948. * Creates a new instance ChromaticAberrationPostProcess
  67949. * @param name The name of the effect.
  67950. * @param screenWidth The width of the screen to apply the effect on.
  67951. * @param screenHeight The height of the screen to apply the effect on.
  67952. * @param options The required width/height ratio to downsize to before computing the render pass.
  67953. * @param camera The camera to apply the render pass to.
  67954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67955. * @param engine The engine which the post process will be applied. (default: current engine)
  67956. * @param reusable If the post process can be reused on the same frame. (default: false)
  67957. * @param textureType Type of textures used when performing the post process. (default: 0)
  67958. * @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)
  67959. */
  67960. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67961. }
  67962. }
  67963. declare module BABYLON {
  67964. /** @hidden */
  67965. export var circleOfConfusionPixelShader: {
  67966. name: string;
  67967. shader: string;
  67968. };
  67969. }
  67970. declare module BABYLON {
  67971. /**
  67972. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67973. */
  67974. export class CircleOfConfusionPostProcess extends PostProcess {
  67975. /**
  67976. * 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.
  67977. */
  67978. lensSize: number;
  67979. /**
  67980. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67981. */
  67982. fStop: number;
  67983. /**
  67984. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67985. */
  67986. focusDistance: number;
  67987. /**
  67988. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67989. */
  67990. focalLength: number;
  67991. private _depthTexture;
  67992. /**
  67993. * Creates a new instance CircleOfConfusionPostProcess
  67994. * @param name The name of the effect.
  67995. * @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.
  67996. * @param options The required width/height ratio to downsize to before computing the render pass.
  67997. * @param camera The camera to apply the render pass to.
  67998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67999. * @param engine The engine which the post process will be applied. (default: current engine)
  68000. * @param reusable If the post process can be reused on the same frame. (default: false)
  68001. * @param textureType Type of textures used when performing the post process. (default: 0)
  68002. * @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)
  68003. */
  68004. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68005. /**
  68006. * 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.
  68007. */
  68008. set depthTexture(value: RenderTargetTexture);
  68009. }
  68010. }
  68011. declare module BABYLON {
  68012. /** @hidden */
  68013. export var colorCorrectionPixelShader: {
  68014. name: string;
  68015. shader: string;
  68016. };
  68017. }
  68018. declare module BABYLON {
  68019. /**
  68020. *
  68021. * This post-process allows the modification of rendered colors by using
  68022. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68023. *
  68024. * The object needs to be provided an url to a texture containing the color
  68025. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68026. * Use an image editing software to tweak the LUT to match your needs.
  68027. *
  68028. * For an example of a color LUT, see here:
  68029. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68030. * For explanations on color grading, see here:
  68031. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68032. *
  68033. */
  68034. export class ColorCorrectionPostProcess extends PostProcess {
  68035. private _colorTableTexture;
  68036. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68037. }
  68038. }
  68039. declare module BABYLON {
  68040. /** @hidden */
  68041. export var convolutionPixelShader: {
  68042. name: string;
  68043. shader: string;
  68044. };
  68045. }
  68046. declare module BABYLON {
  68047. /**
  68048. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68049. * input texture to perform effects such as edge detection or sharpening
  68050. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68051. */
  68052. export class ConvolutionPostProcess extends PostProcess {
  68053. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68054. kernel: number[];
  68055. /**
  68056. * Creates a new instance ConvolutionPostProcess
  68057. * @param name The name of the effect.
  68058. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68059. * @param options The required width/height ratio to downsize to before computing the render pass.
  68060. * @param camera The camera to apply the render pass to.
  68061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68062. * @param engine The engine which the post process will be applied. (default: current engine)
  68063. * @param reusable If the post process can be reused on the same frame. (default: false)
  68064. * @param textureType Type of textures used when performing the post process. (default: 0)
  68065. */
  68066. constructor(name: string,
  68067. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68068. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68069. /**
  68070. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68071. */
  68072. static EdgeDetect0Kernel: number[];
  68073. /**
  68074. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68075. */
  68076. static EdgeDetect1Kernel: number[];
  68077. /**
  68078. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68079. */
  68080. static EdgeDetect2Kernel: number[];
  68081. /**
  68082. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68083. */
  68084. static SharpenKernel: number[];
  68085. /**
  68086. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68087. */
  68088. static EmbossKernel: number[];
  68089. /**
  68090. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68091. */
  68092. static GaussianKernel: number[];
  68093. }
  68094. }
  68095. declare module BABYLON {
  68096. /**
  68097. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68098. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68099. * based on samples that have a large difference in distance than the center pixel.
  68100. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68101. */
  68102. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68103. direction: Vector2;
  68104. /**
  68105. * Creates a new instance CircleOfConfusionPostProcess
  68106. * @param name The name of the effect.
  68107. * @param scene The scene the effect belongs to.
  68108. * @param direction The direction the blur should be applied.
  68109. * @param kernel The size of the kernel used to blur.
  68110. * @param options The required width/height ratio to downsize to before computing the render pass.
  68111. * @param camera The camera to apply the render pass to.
  68112. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68113. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68115. * @param engine The engine which the post process will be applied. (default: current engine)
  68116. * @param reusable If the post process can be reused on the same frame. (default: false)
  68117. * @param textureType Type of textures used when performing the post process. (default: 0)
  68118. * @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)
  68119. */
  68120. 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);
  68121. }
  68122. }
  68123. declare module BABYLON {
  68124. /** @hidden */
  68125. export var depthOfFieldMergePixelShader: {
  68126. name: string;
  68127. shader: string;
  68128. };
  68129. }
  68130. declare module BABYLON {
  68131. /**
  68132. * Options to be set when merging outputs from the default pipeline.
  68133. */
  68134. export class DepthOfFieldMergePostProcessOptions {
  68135. /**
  68136. * The original image to merge on top of
  68137. */
  68138. originalFromInput: PostProcess;
  68139. /**
  68140. * Parameters to perform the merge of the depth of field effect
  68141. */
  68142. depthOfField?: {
  68143. circleOfConfusion: PostProcess;
  68144. blurSteps: Array<PostProcess>;
  68145. };
  68146. /**
  68147. * Parameters to perform the merge of bloom effect
  68148. */
  68149. bloom?: {
  68150. blurred: PostProcess;
  68151. weight: number;
  68152. };
  68153. }
  68154. /**
  68155. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68156. */
  68157. export class DepthOfFieldMergePostProcess extends PostProcess {
  68158. private blurSteps;
  68159. /**
  68160. * Creates a new instance of DepthOfFieldMergePostProcess
  68161. * @param name The name of the effect.
  68162. * @param originalFromInput Post process which's input will be used for the merge.
  68163. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68164. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68165. * @param options The required width/height ratio to downsize to before computing the render pass.
  68166. * @param camera The camera to apply the render pass to.
  68167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68168. * @param engine The engine which the post process will be applied. (default: current engine)
  68169. * @param reusable If the post process can be reused on the same frame. (default: false)
  68170. * @param textureType Type of textures used when performing the post process. (default: 0)
  68171. * @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)
  68172. */
  68173. 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);
  68174. /**
  68175. * Updates the effect with the current post process compile time values and recompiles the shader.
  68176. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68177. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68178. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68179. * @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
  68180. * @param onCompiled Called when the shader has been compiled.
  68181. * @param onError Called if there is an error when compiling a shader.
  68182. */
  68183. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68184. }
  68185. }
  68186. declare module BABYLON {
  68187. /**
  68188. * Specifies the level of max blur that should be applied when using the depth of field effect
  68189. */
  68190. export enum DepthOfFieldEffectBlurLevel {
  68191. /**
  68192. * Subtle blur
  68193. */
  68194. Low = 0,
  68195. /**
  68196. * Medium blur
  68197. */
  68198. Medium = 1,
  68199. /**
  68200. * Large blur
  68201. */
  68202. High = 2
  68203. }
  68204. /**
  68205. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68206. */
  68207. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68208. private _circleOfConfusion;
  68209. /**
  68210. * @hidden Internal, blurs from high to low
  68211. */
  68212. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68213. private _depthOfFieldBlurY;
  68214. private _dofMerge;
  68215. /**
  68216. * @hidden Internal post processes in depth of field effect
  68217. */
  68218. _effects: Array<PostProcess>;
  68219. /**
  68220. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68221. */
  68222. set focalLength(value: number);
  68223. get focalLength(): number;
  68224. /**
  68225. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68226. */
  68227. set fStop(value: number);
  68228. get fStop(): number;
  68229. /**
  68230. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68231. */
  68232. set focusDistance(value: number);
  68233. get focusDistance(): number;
  68234. /**
  68235. * 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.
  68236. */
  68237. set lensSize(value: number);
  68238. get lensSize(): number;
  68239. /**
  68240. * Creates a new instance DepthOfFieldEffect
  68241. * @param scene The scene the effect belongs to.
  68242. * @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.
  68243. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68244. * @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)
  68245. */
  68246. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68247. /**
  68248. * Get the current class name of the current effet
  68249. * @returns "DepthOfFieldEffect"
  68250. */
  68251. getClassName(): string;
  68252. /**
  68253. * 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.
  68254. */
  68255. set depthTexture(value: RenderTargetTexture);
  68256. /**
  68257. * Disposes each of the internal effects for a given camera.
  68258. * @param camera The camera to dispose the effect on.
  68259. */
  68260. disposeEffects(camera: Camera): void;
  68261. /**
  68262. * @hidden Internal
  68263. */
  68264. _updateEffects(): void;
  68265. /**
  68266. * Internal
  68267. * @returns if all the contained post processes are ready.
  68268. * @hidden
  68269. */
  68270. _isReady(): boolean;
  68271. }
  68272. }
  68273. declare module BABYLON {
  68274. /** @hidden */
  68275. export var displayPassPixelShader: {
  68276. name: string;
  68277. shader: string;
  68278. };
  68279. }
  68280. declare module BABYLON {
  68281. /**
  68282. * DisplayPassPostProcess which produces an output the same as it's input
  68283. */
  68284. export class DisplayPassPostProcess extends PostProcess {
  68285. /**
  68286. * Creates the DisplayPassPostProcess
  68287. * @param name The name of the effect.
  68288. * @param options The required width/height ratio to downsize to before computing the render pass.
  68289. * @param camera The camera to apply the render pass to.
  68290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68291. * @param engine The engine which the post process will be applied. (default: current engine)
  68292. * @param reusable If the post process can be reused on the same frame. (default: false)
  68293. */
  68294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68295. }
  68296. }
  68297. declare module BABYLON {
  68298. /** @hidden */
  68299. export var filterPixelShader: {
  68300. name: string;
  68301. shader: string;
  68302. };
  68303. }
  68304. declare module BABYLON {
  68305. /**
  68306. * Applies a kernel filter to the image
  68307. */
  68308. export class FilterPostProcess extends PostProcess {
  68309. /** The matrix to be applied to the image */
  68310. kernelMatrix: Matrix;
  68311. /**
  68312. *
  68313. * @param name The name of the effect.
  68314. * @param kernelMatrix The matrix to be applied to the image
  68315. * @param options The required width/height ratio to downsize to before computing the render pass.
  68316. * @param camera The camera to apply the render pass to.
  68317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68318. * @param engine The engine which the post process will be applied. (default: current engine)
  68319. * @param reusable If the post process can be reused on the same frame. (default: false)
  68320. */
  68321. constructor(name: string,
  68322. /** The matrix to be applied to the image */
  68323. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68324. }
  68325. }
  68326. declare module BABYLON {
  68327. /** @hidden */
  68328. export var fxaaPixelShader: {
  68329. name: string;
  68330. shader: string;
  68331. };
  68332. }
  68333. declare module BABYLON {
  68334. /** @hidden */
  68335. export var fxaaVertexShader: {
  68336. name: string;
  68337. shader: string;
  68338. };
  68339. }
  68340. declare module BABYLON {
  68341. /**
  68342. * Fxaa post process
  68343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68344. */
  68345. export class FxaaPostProcess extends PostProcess {
  68346. /** @hidden */
  68347. texelWidth: number;
  68348. /** @hidden */
  68349. texelHeight: number;
  68350. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68351. private _getDefines;
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. /** @hidden */
  68356. export var grainPixelShader: {
  68357. name: string;
  68358. shader: string;
  68359. };
  68360. }
  68361. declare module BABYLON {
  68362. /**
  68363. * The GrainPostProcess adds noise to the image at mid luminance levels
  68364. */
  68365. export class GrainPostProcess extends PostProcess {
  68366. /**
  68367. * The intensity of the grain added (default: 30)
  68368. */
  68369. intensity: number;
  68370. /**
  68371. * If the grain should be randomized on every frame
  68372. */
  68373. animated: boolean;
  68374. /**
  68375. * Creates a new instance of @see GrainPostProcess
  68376. * @param name The name of the effect.
  68377. * @param options The required width/height ratio to downsize to before computing the render pass.
  68378. * @param camera The camera to apply the render pass to.
  68379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68380. * @param engine The engine which the post process will be applied. (default: current engine)
  68381. * @param reusable If the post process can be reused on the same frame. (default: false)
  68382. * @param textureType Type of textures used when performing the post process. (default: 0)
  68383. * @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)
  68384. */
  68385. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /** @hidden */
  68390. export var highlightsPixelShader: {
  68391. name: string;
  68392. shader: string;
  68393. };
  68394. }
  68395. declare module BABYLON {
  68396. /**
  68397. * Extracts highlights from the image
  68398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68399. */
  68400. export class HighlightsPostProcess extends PostProcess {
  68401. /**
  68402. * Extracts highlights from the image
  68403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68404. * @param name The name of the effect.
  68405. * @param options The required width/height ratio to downsize to before computing the render pass.
  68406. * @param camera The camera to apply the render pass to.
  68407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68408. * @param engine The engine which the post process will be applied. (default: current engine)
  68409. * @param reusable If the post process can be reused on the same frame. (default: false)
  68410. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68411. */
  68412. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /** @hidden */
  68417. export var mrtFragmentDeclaration: {
  68418. name: string;
  68419. shader: string;
  68420. };
  68421. }
  68422. declare module BABYLON {
  68423. /** @hidden */
  68424. export var geometryPixelShader: {
  68425. name: string;
  68426. shader: string;
  68427. };
  68428. }
  68429. declare module BABYLON {
  68430. /** @hidden */
  68431. export var geometryVertexShader: {
  68432. name: string;
  68433. shader: string;
  68434. };
  68435. }
  68436. declare module BABYLON {
  68437. /** @hidden */
  68438. interface ISavedTransformationMatrix {
  68439. world: Matrix;
  68440. viewProjection: Matrix;
  68441. }
  68442. /**
  68443. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68444. */
  68445. export class GeometryBufferRenderer {
  68446. /**
  68447. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68448. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68449. */
  68450. static readonly POSITION_TEXTURE_TYPE: number;
  68451. /**
  68452. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68453. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68454. */
  68455. static readonly VELOCITY_TEXTURE_TYPE: number;
  68456. /**
  68457. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68458. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68459. */
  68460. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68461. /**
  68462. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68463. * in order to compute objects velocities when enableVelocity is set to "true"
  68464. * @hidden
  68465. */
  68466. _previousTransformationMatrices: {
  68467. [index: number]: ISavedTransformationMatrix;
  68468. };
  68469. /**
  68470. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68471. * in order to compute objects velocities when enableVelocity is set to "true"
  68472. * @hidden
  68473. */
  68474. _previousBonesTransformationMatrices: {
  68475. [index: number]: Float32Array;
  68476. };
  68477. /**
  68478. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68479. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68480. */
  68481. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68482. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68483. renderTransparentMeshes: boolean;
  68484. private _scene;
  68485. private _multiRenderTarget;
  68486. private _ratio;
  68487. private _enablePosition;
  68488. private _enableVelocity;
  68489. private _enableReflectivity;
  68490. private _positionIndex;
  68491. private _velocityIndex;
  68492. private _reflectivityIndex;
  68493. protected _effect: Effect;
  68494. protected _cachedDefines: string;
  68495. /**
  68496. * Set the render list (meshes to be rendered) used in the G buffer.
  68497. */
  68498. set renderList(meshes: Mesh[]);
  68499. /**
  68500. * Gets wether or not G buffer are supported by the running hardware.
  68501. * This requires draw buffer supports
  68502. */
  68503. get isSupported(): boolean;
  68504. /**
  68505. * Returns the index of the given texture type in the G-Buffer textures array
  68506. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68507. * @returns the index of the given texture type in the G-Buffer textures array
  68508. */
  68509. getTextureIndex(textureType: number): number;
  68510. /**
  68511. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68512. */
  68513. get enablePosition(): boolean;
  68514. /**
  68515. * Sets whether or not objects positions are enabled for the G buffer.
  68516. */
  68517. set enablePosition(enable: boolean);
  68518. /**
  68519. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68520. */
  68521. get enableVelocity(): boolean;
  68522. /**
  68523. * Sets wether or not objects velocities are enabled for the G buffer.
  68524. */
  68525. set enableVelocity(enable: boolean);
  68526. /**
  68527. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68528. */
  68529. get enableReflectivity(): boolean;
  68530. /**
  68531. * Sets wether or not objects roughness are enabled for the G buffer.
  68532. */
  68533. set enableReflectivity(enable: boolean);
  68534. /**
  68535. * Gets the scene associated with the buffer.
  68536. */
  68537. get scene(): Scene;
  68538. /**
  68539. * Gets the ratio used by the buffer during its creation.
  68540. * How big is the buffer related to the main canvas.
  68541. */
  68542. get ratio(): number;
  68543. /** @hidden */
  68544. static _SceneComponentInitialization: (scene: Scene) => void;
  68545. /**
  68546. * Creates a new G Buffer for the scene
  68547. * @param scene The scene the buffer belongs to
  68548. * @param ratio How big is the buffer related to the main canvas.
  68549. */
  68550. constructor(scene: Scene, ratio?: number);
  68551. /**
  68552. * Checks wether everything is ready to render a submesh to the G buffer.
  68553. * @param subMesh the submesh to check readiness for
  68554. * @param useInstances is the mesh drawn using instance or not
  68555. * @returns true if ready otherwise false
  68556. */
  68557. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68558. /**
  68559. * Gets the current underlying G Buffer.
  68560. * @returns the buffer
  68561. */
  68562. getGBuffer(): MultiRenderTarget;
  68563. /**
  68564. * Gets the number of samples used to render the buffer (anti aliasing).
  68565. */
  68566. get samples(): number;
  68567. /**
  68568. * Sets the number of samples used to render the buffer (anti aliasing).
  68569. */
  68570. set samples(value: number);
  68571. /**
  68572. * Disposes the renderer and frees up associated resources.
  68573. */
  68574. dispose(): void;
  68575. protected _createRenderTargets(): void;
  68576. private _copyBonesTransformationMatrices;
  68577. }
  68578. }
  68579. declare module BABYLON {
  68580. interface Scene {
  68581. /** @hidden (Backing field) */
  68582. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68583. /**
  68584. * Gets or Sets the current geometry buffer associated to the scene.
  68585. */
  68586. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68587. /**
  68588. * Enables a GeometryBufferRender and associates it with the scene
  68589. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68590. * @returns the GeometryBufferRenderer
  68591. */
  68592. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68593. /**
  68594. * Disables the GeometryBufferRender associated with the scene
  68595. */
  68596. disableGeometryBufferRenderer(): void;
  68597. }
  68598. /**
  68599. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68600. * in several rendering techniques.
  68601. */
  68602. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68603. /**
  68604. * The component name helpful to identify the component in the list of scene components.
  68605. */
  68606. readonly name: string;
  68607. /**
  68608. * The scene the component belongs to.
  68609. */
  68610. scene: Scene;
  68611. /**
  68612. * Creates a new instance of the component for the given scene
  68613. * @param scene Defines the scene to register the component in
  68614. */
  68615. constructor(scene: Scene);
  68616. /**
  68617. * Registers the component in a given scene
  68618. */
  68619. register(): void;
  68620. /**
  68621. * Rebuilds the elements related to this component in case of
  68622. * context lost for instance.
  68623. */
  68624. rebuild(): void;
  68625. /**
  68626. * Disposes the component and the associated ressources
  68627. */
  68628. dispose(): void;
  68629. private _gatherRenderTargets;
  68630. }
  68631. }
  68632. declare module BABYLON {
  68633. /** @hidden */
  68634. export var motionBlurPixelShader: {
  68635. name: string;
  68636. shader: string;
  68637. };
  68638. }
  68639. declare module BABYLON {
  68640. /**
  68641. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68642. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68643. * As an example, all you have to do is to create the post-process:
  68644. * var mb = new BABYLON.MotionBlurPostProcess(
  68645. * 'mb', // The name of the effect.
  68646. * scene, // The scene containing the objects to blur according to their velocity.
  68647. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68648. * camera // The camera to apply the render pass to.
  68649. * );
  68650. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68651. */
  68652. export class MotionBlurPostProcess extends PostProcess {
  68653. /**
  68654. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68655. */
  68656. motionStrength: number;
  68657. /**
  68658. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68659. */
  68660. get motionBlurSamples(): number;
  68661. /**
  68662. * Sets the number of iterations to be used for motion blur quality
  68663. */
  68664. set motionBlurSamples(samples: number);
  68665. private _motionBlurSamples;
  68666. private _geometryBufferRenderer;
  68667. /**
  68668. * Creates a new instance MotionBlurPostProcess
  68669. * @param name The name of the effect.
  68670. * @param scene The scene containing the objects to blur according to their velocity.
  68671. * @param options The required width/height ratio to downsize to before computing the render pass.
  68672. * @param camera The camera to apply the render pass to.
  68673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68674. * @param engine The engine which the post process will be applied. (default: current engine)
  68675. * @param reusable If the post process can be reused on the same frame. (default: false)
  68676. * @param textureType Type of textures used when performing the post process. (default: 0)
  68677. * @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)
  68678. */
  68679. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68680. /**
  68681. * Excludes the given skinned mesh from computing bones velocities.
  68682. * 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.
  68683. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68684. */
  68685. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68686. /**
  68687. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68688. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68689. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68690. */
  68691. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68692. /**
  68693. * Disposes the post process.
  68694. * @param camera The camera to dispose the post process on.
  68695. */
  68696. dispose(camera?: Camera): void;
  68697. }
  68698. }
  68699. declare module BABYLON {
  68700. /** @hidden */
  68701. export var refractionPixelShader: {
  68702. name: string;
  68703. shader: string;
  68704. };
  68705. }
  68706. declare module BABYLON {
  68707. /**
  68708. * Post process which applies a refractin texture
  68709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68710. */
  68711. export class RefractionPostProcess extends PostProcess {
  68712. /** the base color of the refraction (used to taint the rendering) */
  68713. color: Color3;
  68714. /** simulated refraction depth */
  68715. depth: number;
  68716. /** the coefficient of the base color (0 to remove base color tainting) */
  68717. colorLevel: number;
  68718. private _refTexture;
  68719. private _ownRefractionTexture;
  68720. /**
  68721. * Gets or sets the refraction texture
  68722. * Please note that you are responsible for disposing the texture if you set it manually
  68723. */
  68724. get refractionTexture(): Texture;
  68725. set refractionTexture(value: Texture);
  68726. /**
  68727. * Initializes the RefractionPostProcess
  68728. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68729. * @param name The name of the effect.
  68730. * @param refractionTextureUrl Url of the refraction texture to use
  68731. * @param color the base color of the refraction (used to taint the rendering)
  68732. * @param depth simulated refraction depth
  68733. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68734. * @param camera The camera to apply the render pass to.
  68735. * @param options The required width/height ratio to downsize to before computing the render pass.
  68736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68737. * @param engine The engine which the post process will be applied. (default: current engine)
  68738. * @param reusable If the post process can be reused on the same frame. (default: false)
  68739. */
  68740. constructor(name: string, refractionTextureUrl: string,
  68741. /** the base color of the refraction (used to taint the rendering) */
  68742. color: Color3,
  68743. /** simulated refraction depth */
  68744. depth: number,
  68745. /** the coefficient of the base color (0 to remove base color tainting) */
  68746. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68747. /**
  68748. * Disposes of the post process
  68749. * @param camera Camera to dispose post process on
  68750. */
  68751. dispose(camera: Camera): void;
  68752. }
  68753. }
  68754. declare module BABYLON {
  68755. /** @hidden */
  68756. export var sharpenPixelShader: {
  68757. name: string;
  68758. shader: string;
  68759. };
  68760. }
  68761. declare module BABYLON {
  68762. /**
  68763. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68764. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68765. */
  68766. export class SharpenPostProcess extends PostProcess {
  68767. /**
  68768. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68769. */
  68770. colorAmount: number;
  68771. /**
  68772. * How much sharpness should be applied (default: 0.3)
  68773. */
  68774. edgeAmount: number;
  68775. /**
  68776. * Creates a new instance ConvolutionPostProcess
  68777. * @param name The name of the effect.
  68778. * @param options The required width/height ratio to downsize to before computing the render pass.
  68779. * @param camera The camera to apply the render pass to.
  68780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68781. * @param engine The engine which the post process will be applied. (default: current engine)
  68782. * @param reusable If the post process can be reused on the same frame. (default: false)
  68783. * @param textureType Type of textures used when performing the post process. (default: 0)
  68784. * @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)
  68785. */
  68786. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68787. }
  68788. }
  68789. declare module BABYLON {
  68790. /**
  68791. * PostProcessRenderPipeline
  68792. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68793. */
  68794. export class PostProcessRenderPipeline {
  68795. private engine;
  68796. private _renderEffects;
  68797. private _renderEffectsForIsolatedPass;
  68798. /**
  68799. * List of inspectable custom properties (used by the Inspector)
  68800. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68801. */
  68802. inspectableCustomProperties: IInspectable[];
  68803. /**
  68804. * @hidden
  68805. */
  68806. protected _cameras: Camera[];
  68807. /** @hidden */
  68808. _name: string;
  68809. /**
  68810. * Gets pipeline name
  68811. */
  68812. get name(): string;
  68813. /** Gets the list of attached cameras */
  68814. get cameras(): Camera[];
  68815. /**
  68816. * Initializes a PostProcessRenderPipeline
  68817. * @param engine engine to add the pipeline to
  68818. * @param name name of the pipeline
  68819. */
  68820. constructor(engine: Engine, name: string);
  68821. /**
  68822. * Gets the class name
  68823. * @returns "PostProcessRenderPipeline"
  68824. */
  68825. getClassName(): string;
  68826. /**
  68827. * If all the render effects in the pipeline are supported
  68828. */
  68829. get isSupported(): boolean;
  68830. /**
  68831. * Adds an effect to the pipeline
  68832. * @param renderEffect the effect to add
  68833. */
  68834. addEffect(renderEffect: PostProcessRenderEffect): void;
  68835. /** @hidden */
  68836. _rebuild(): void;
  68837. /** @hidden */
  68838. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68839. /** @hidden */
  68840. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68841. /** @hidden */
  68842. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68843. /** @hidden */
  68844. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68845. /** @hidden */
  68846. _attachCameras(cameras: Camera, unique: boolean): void;
  68847. /** @hidden */
  68848. _attachCameras(cameras: Camera[], unique: boolean): void;
  68849. /** @hidden */
  68850. _detachCameras(cameras: Camera): void;
  68851. /** @hidden */
  68852. _detachCameras(cameras: Nullable<Camera[]>): void;
  68853. /** @hidden */
  68854. _update(): void;
  68855. /** @hidden */
  68856. _reset(): void;
  68857. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68858. /**
  68859. * Disposes of the pipeline
  68860. */
  68861. dispose(): void;
  68862. }
  68863. }
  68864. declare module BABYLON {
  68865. /**
  68866. * PostProcessRenderPipelineManager class
  68867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68868. */
  68869. export class PostProcessRenderPipelineManager {
  68870. private _renderPipelines;
  68871. /**
  68872. * Initializes a PostProcessRenderPipelineManager
  68873. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68874. */
  68875. constructor();
  68876. /**
  68877. * Gets the list of supported render pipelines
  68878. */
  68879. get supportedPipelines(): PostProcessRenderPipeline[];
  68880. /**
  68881. * Adds a pipeline to the manager
  68882. * @param renderPipeline The pipeline to add
  68883. */
  68884. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68885. /**
  68886. * Attaches a camera to the pipeline
  68887. * @param renderPipelineName The name of the pipeline to attach to
  68888. * @param cameras the camera to attach
  68889. * @param unique if the camera can be attached multiple times to the pipeline
  68890. */
  68891. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68892. /**
  68893. * Detaches a camera from the pipeline
  68894. * @param renderPipelineName The name of the pipeline to detach from
  68895. * @param cameras the camera to detach
  68896. */
  68897. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68898. /**
  68899. * Enables an effect by name on a pipeline
  68900. * @param renderPipelineName the name of the pipeline to enable the effect in
  68901. * @param renderEffectName the name of the effect to enable
  68902. * @param cameras the cameras that the effect should be enabled on
  68903. */
  68904. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68905. /**
  68906. * Disables an effect by name on a pipeline
  68907. * @param renderPipelineName the name of the pipeline to disable the effect in
  68908. * @param renderEffectName the name of the effect to disable
  68909. * @param cameras the cameras that the effect should be disabled on
  68910. */
  68911. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68912. /**
  68913. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68914. */
  68915. update(): void;
  68916. /** @hidden */
  68917. _rebuild(): void;
  68918. /**
  68919. * Disposes of the manager and pipelines
  68920. */
  68921. dispose(): void;
  68922. }
  68923. }
  68924. declare module BABYLON {
  68925. interface Scene {
  68926. /** @hidden (Backing field) */
  68927. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68928. /**
  68929. * Gets the postprocess render pipeline manager
  68930. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68931. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68932. */
  68933. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68934. }
  68935. /**
  68936. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68937. */
  68938. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68939. /**
  68940. * The component name helpfull to identify the component in the list of scene components.
  68941. */
  68942. readonly name: string;
  68943. /**
  68944. * The scene the component belongs to.
  68945. */
  68946. scene: Scene;
  68947. /**
  68948. * Creates a new instance of the component for the given scene
  68949. * @param scene Defines the scene to register the component in
  68950. */
  68951. constructor(scene: Scene);
  68952. /**
  68953. * Registers the component in a given scene
  68954. */
  68955. register(): void;
  68956. /**
  68957. * Rebuilds the elements related to this component in case of
  68958. * context lost for instance.
  68959. */
  68960. rebuild(): void;
  68961. /**
  68962. * Disposes the component and the associated ressources
  68963. */
  68964. dispose(): void;
  68965. private _gatherRenderTargets;
  68966. }
  68967. }
  68968. declare module BABYLON {
  68969. /**
  68970. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68971. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68972. */
  68973. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68974. private _scene;
  68975. private _camerasToBeAttached;
  68976. /**
  68977. * ID of the sharpen post process,
  68978. */
  68979. private readonly SharpenPostProcessId;
  68980. /**
  68981. * @ignore
  68982. * ID of the image processing post process;
  68983. */
  68984. readonly ImageProcessingPostProcessId: string;
  68985. /**
  68986. * @ignore
  68987. * ID of the Fast Approximate Anti-Aliasing post process;
  68988. */
  68989. readonly FxaaPostProcessId: string;
  68990. /**
  68991. * ID of the chromatic aberration post process,
  68992. */
  68993. private readonly ChromaticAberrationPostProcessId;
  68994. /**
  68995. * ID of the grain post process
  68996. */
  68997. private readonly GrainPostProcessId;
  68998. /**
  68999. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69000. */
  69001. sharpen: SharpenPostProcess;
  69002. private _sharpenEffect;
  69003. private bloom;
  69004. /**
  69005. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69006. */
  69007. depthOfField: DepthOfFieldEffect;
  69008. /**
  69009. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69010. */
  69011. fxaa: FxaaPostProcess;
  69012. /**
  69013. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69014. */
  69015. imageProcessing: ImageProcessingPostProcess;
  69016. /**
  69017. * Chromatic aberration post process which will shift rgb colors in the image
  69018. */
  69019. chromaticAberration: ChromaticAberrationPostProcess;
  69020. private _chromaticAberrationEffect;
  69021. /**
  69022. * Grain post process which add noise to the image
  69023. */
  69024. grain: GrainPostProcess;
  69025. private _grainEffect;
  69026. /**
  69027. * Glow post process which adds a glow to emissive areas of the image
  69028. */
  69029. private _glowLayer;
  69030. /**
  69031. * Animations which can be used to tweak settings over a period of time
  69032. */
  69033. animations: Animation[];
  69034. private _imageProcessingConfigurationObserver;
  69035. private _sharpenEnabled;
  69036. private _bloomEnabled;
  69037. private _depthOfFieldEnabled;
  69038. private _depthOfFieldBlurLevel;
  69039. private _fxaaEnabled;
  69040. private _imageProcessingEnabled;
  69041. private _defaultPipelineTextureType;
  69042. private _bloomScale;
  69043. private _chromaticAberrationEnabled;
  69044. private _grainEnabled;
  69045. private _buildAllowed;
  69046. /**
  69047. * Gets active scene
  69048. */
  69049. get scene(): Scene;
  69050. /**
  69051. * Enable or disable the sharpen process from the pipeline
  69052. */
  69053. set sharpenEnabled(enabled: boolean);
  69054. get sharpenEnabled(): boolean;
  69055. private _resizeObserver;
  69056. private _hardwareScaleLevel;
  69057. private _bloomKernel;
  69058. /**
  69059. * Specifies the size of the bloom blur kernel, relative to the final output size
  69060. */
  69061. get bloomKernel(): number;
  69062. set bloomKernel(value: number);
  69063. /**
  69064. * Specifies the weight of the bloom in the final rendering
  69065. */
  69066. private _bloomWeight;
  69067. /**
  69068. * Specifies the luma threshold for the area that will be blurred by the bloom
  69069. */
  69070. private _bloomThreshold;
  69071. private _hdr;
  69072. /**
  69073. * The strength of the bloom.
  69074. */
  69075. set bloomWeight(value: number);
  69076. get bloomWeight(): number;
  69077. /**
  69078. * The strength of the bloom.
  69079. */
  69080. set bloomThreshold(value: number);
  69081. get bloomThreshold(): number;
  69082. /**
  69083. * The scale of the bloom, lower value will provide better performance.
  69084. */
  69085. set bloomScale(value: number);
  69086. get bloomScale(): number;
  69087. /**
  69088. * Enable or disable the bloom from the pipeline
  69089. */
  69090. set bloomEnabled(enabled: boolean);
  69091. get bloomEnabled(): boolean;
  69092. private _rebuildBloom;
  69093. /**
  69094. * If the depth of field is enabled.
  69095. */
  69096. get depthOfFieldEnabled(): boolean;
  69097. set depthOfFieldEnabled(enabled: boolean);
  69098. /**
  69099. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69100. */
  69101. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69102. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69103. /**
  69104. * If the anti aliasing is enabled.
  69105. */
  69106. set fxaaEnabled(enabled: boolean);
  69107. get fxaaEnabled(): boolean;
  69108. private _samples;
  69109. /**
  69110. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69111. */
  69112. set samples(sampleCount: number);
  69113. get samples(): number;
  69114. /**
  69115. * If image processing is enabled.
  69116. */
  69117. set imageProcessingEnabled(enabled: boolean);
  69118. get imageProcessingEnabled(): boolean;
  69119. /**
  69120. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69121. */
  69122. set glowLayerEnabled(enabled: boolean);
  69123. get glowLayerEnabled(): boolean;
  69124. /**
  69125. * Gets the glow layer (or null if not defined)
  69126. */
  69127. get glowLayer(): Nullable<GlowLayer>;
  69128. /**
  69129. * Enable or disable the chromaticAberration process from the pipeline
  69130. */
  69131. set chromaticAberrationEnabled(enabled: boolean);
  69132. get chromaticAberrationEnabled(): boolean;
  69133. /**
  69134. * Enable or disable the grain process from the pipeline
  69135. */
  69136. set grainEnabled(enabled: boolean);
  69137. get grainEnabled(): boolean;
  69138. /**
  69139. * @constructor
  69140. * @param name - The rendering pipeline name (default: "")
  69141. * @param hdr - If high dynamic range textures should be used (default: true)
  69142. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69143. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69144. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69145. */
  69146. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69147. /**
  69148. * Get the class name
  69149. * @returns "DefaultRenderingPipeline"
  69150. */
  69151. getClassName(): string;
  69152. /**
  69153. * Force the compilation of the entire pipeline.
  69154. */
  69155. prepare(): void;
  69156. private _hasCleared;
  69157. private _prevPostProcess;
  69158. private _prevPrevPostProcess;
  69159. private _setAutoClearAndTextureSharing;
  69160. private _depthOfFieldSceneObserver;
  69161. private _buildPipeline;
  69162. private _disposePostProcesses;
  69163. /**
  69164. * Adds a camera to the pipeline
  69165. * @param camera the camera to be added
  69166. */
  69167. addCamera(camera: Camera): void;
  69168. /**
  69169. * Removes a camera from the pipeline
  69170. * @param camera the camera to remove
  69171. */
  69172. removeCamera(camera: Camera): void;
  69173. /**
  69174. * Dispose of the pipeline and stop all post processes
  69175. */
  69176. dispose(): void;
  69177. /**
  69178. * Serialize the rendering pipeline (Used when exporting)
  69179. * @returns the serialized object
  69180. */
  69181. serialize(): any;
  69182. /**
  69183. * Parse the serialized pipeline
  69184. * @param source Source pipeline.
  69185. * @param scene The scene to load the pipeline to.
  69186. * @param rootUrl The URL of the serialized pipeline.
  69187. * @returns An instantiated pipeline from the serialized object.
  69188. */
  69189. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69190. }
  69191. }
  69192. declare module BABYLON {
  69193. /** @hidden */
  69194. export var lensHighlightsPixelShader: {
  69195. name: string;
  69196. shader: string;
  69197. };
  69198. }
  69199. declare module BABYLON {
  69200. /** @hidden */
  69201. export var depthOfFieldPixelShader: {
  69202. name: string;
  69203. shader: string;
  69204. };
  69205. }
  69206. declare module BABYLON {
  69207. /**
  69208. * BABYLON.JS Chromatic Aberration GLSL Shader
  69209. * Author: Olivier Guyot
  69210. * Separates very slightly R, G and B colors on the edges of the screen
  69211. * Inspired by Francois Tarlier & Martins Upitis
  69212. */
  69213. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69214. /**
  69215. * @ignore
  69216. * The chromatic aberration PostProcess id in the pipeline
  69217. */
  69218. LensChromaticAberrationEffect: string;
  69219. /**
  69220. * @ignore
  69221. * The highlights enhancing PostProcess id in the pipeline
  69222. */
  69223. HighlightsEnhancingEffect: string;
  69224. /**
  69225. * @ignore
  69226. * The depth-of-field PostProcess id in the pipeline
  69227. */
  69228. LensDepthOfFieldEffect: string;
  69229. private _scene;
  69230. private _depthTexture;
  69231. private _grainTexture;
  69232. private _chromaticAberrationPostProcess;
  69233. private _highlightsPostProcess;
  69234. private _depthOfFieldPostProcess;
  69235. private _edgeBlur;
  69236. private _grainAmount;
  69237. private _chromaticAberration;
  69238. private _distortion;
  69239. private _highlightsGain;
  69240. private _highlightsThreshold;
  69241. private _dofDistance;
  69242. private _dofAperture;
  69243. private _dofDarken;
  69244. private _dofPentagon;
  69245. private _blurNoise;
  69246. /**
  69247. * @constructor
  69248. *
  69249. * Effect parameters are as follow:
  69250. * {
  69251. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69252. * edge_blur: number; // from 0 to x (1 for realism)
  69253. * distortion: number; // from 0 to x (1 for realism)
  69254. * grain_amount: number; // from 0 to 1
  69255. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69256. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69257. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69258. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69259. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69260. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69261. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69262. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69263. * }
  69264. * Note: if an effect parameter is unset, effect is disabled
  69265. *
  69266. * @param name The rendering pipeline name
  69267. * @param parameters - An object containing all parameters (see above)
  69268. * @param scene The scene linked to this pipeline
  69269. * @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)
  69270. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69271. */
  69272. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69273. /**
  69274. * Get the class name
  69275. * @returns "LensRenderingPipeline"
  69276. */
  69277. getClassName(): string;
  69278. /**
  69279. * Gets associated scene
  69280. */
  69281. get scene(): Scene;
  69282. /**
  69283. * Gets or sets the edge blur
  69284. */
  69285. get edgeBlur(): number;
  69286. set edgeBlur(value: number);
  69287. /**
  69288. * Gets or sets the grain amount
  69289. */
  69290. get grainAmount(): number;
  69291. set grainAmount(value: number);
  69292. /**
  69293. * Gets or sets the chromatic aberration amount
  69294. */
  69295. get chromaticAberration(): number;
  69296. set chromaticAberration(value: number);
  69297. /**
  69298. * Gets or sets the depth of field aperture
  69299. */
  69300. get dofAperture(): number;
  69301. set dofAperture(value: number);
  69302. /**
  69303. * Gets or sets the edge distortion
  69304. */
  69305. get edgeDistortion(): number;
  69306. set edgeDistortion(value: number);
  69307. /**
  69308. * Gets or sets the depth of field distortion
  69309. */
  69310. get dofDistortion(): number;
  69311. set dofDistortion(value: number);
  69312. /**
  69313. * Gets or sets the darken out of focus amount
  69314. */
  69315. get darkenOutOfFocus(): number;
  69316. set darkenOutOfFocus(value: number);
  69317. /**
  69318. * Gets or sets a boolean indicating if blur noise is enabled
  69319. */
  69320. get blurNoise(): boolean;
  69321. set blurNoise(value: boolean);
  69322. /**
  69323. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69324. */
  69325. get pentagonBokeh(): boolean;
  69326. set pentagonBokeh(value: boolean);
  69327. /**
  69328. * Gets or sets the highlight grain amount
  69329. */
  69330. get highlightsGain(): number;
  69331. set highlightsGain(value: number);
  69332. /**
  69333. * Gets or sets the highlight threshold
  69334. */
  69335. get highlightsThreshold(): number;
  69336. set highlightsThreshold(value: number);
  69337. /**
  69338. * Sets the amount of blur at the edges
  69339. * @param amount blur amount
  69340. */
  69341. setEdgeBlur(amount: number): void;
  69342. /**
  69343. * Sets edge blur to 0
  69344. */
  69345. disableEdgeBlur(): void;
  69346. /**
  69347. * Sets the amout of grain
  69348. * @param amount Amount of grain
  69349. */
  69350. setGrainAmount(amount: number): void;
  69351. /**
  69352. * Set grain amount to 0
  69353. */
  69354. disableGrain(): void;
  69355. /**
  69356. * Sets the chromatic aberration amount
  69357. * @param amount amount of chromatic aberration
  69358. */
  69359. setChromaticAberration(amount: number): void;
  69360. /**
  69361. * Sets chromatic aberration amount to 0
  69362. */
  69363. disableChromaticAberration(): void;
  69364. /**
  69365. * Sets the EdgeDistortion amount
  69366. * @param amount amount of EdgeDistortion
  69367. */
  69368. setEdgeDistortion(amount: number): void;
  69369. /**
  69370. * Sets edge distortion to 0
  69371. */
  69372. disableEdgeDistortion(): void;
  69373. /**
  69374. * Sets the FocusDistance amount
  69375. * @param amount amount of FocusDistance
  69376. */
  69377. setFocusDistance(amount: number): void;
  69378. /**
  69379. * Disables depth of field
  69380. */
  69381. disableDepthOfField(): void;
  69382. /**
  69383. * Sets the Aperture amount
  69384. * @param amount amount of Aperture
  69385. */
  69386. setAperture(amount: number): void;
  69387. /**
  69388. * Sets the DarkenOutOfFocus amount
  69389. * @param amount amount of DarkenOutOfFocus
  69390. */
  69391. setDarkenOutOfFocus(amount: number): void;
  69392. private _pentagonBokehIsEnabled;
  69393. /**
  69394. * Creates a pentagon bokeh effect
  69395. */
  69396. enablePentagonBokeh(): void;
  69397. /**
  69398. * Disables the pentagon bokeh effect
  69399. */
  69400. disablePentagonBokeh(): void;
  69401. /**
  69402. * Enables noise blur
  69403. */
  69404. enableNoiseBlur(): void;
  69405. /**
  69406. * Disables noise blur
  69407. */
  69408. disableNoiseBlur(): void;
  69409. /**
  69410. * Sets the HighlightsGain amount
  69411. * @param amount amount of HighlightsGain
  69412. */
  69413. setHighlightsGain(amount: number): void;
  69414. /**
  69415. * Sets the HighlightsThreshold amount
  69416. * @param amount amount of HighlightsThreshold
  69417. */
  69418. setHighlightsThreshold(amount: number): void;
  69419. /**
  69420. * Disables highlights
  69421. */
  69422. disableHighlights(): void;
  69423. /**
  69424. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69425. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69426. */
  69427. dispose(disableDepthRender?: boolean): void;
  69428. private _createChromaticAberrationPostProcess;
  69429. private _createHighlightsPostProcess;
  69430. private _createDepthOfFieldPostProcess;
  69431. private _createGrainTexture;
  69432. }
  69433. }
  69434. declare module BABYLON {
  69435. /** @hidden */
  69436. export var ssao2PixelShader: {
  69437. name: string;
  69438. shader: string;
  69439. };
  69440. }
  69441. declare module BABYLON {
  69442. /** @hidden */
  69443. export var ssaoCombinePixelShader: {
  69444. name: string;
  69445. shader: string;
  69446. };
  69447. }
  69448. declare module BABYLON {
  69449. /**
  69450. * Render pipeline to produce ssao effect
  69451. */
  69452. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69453. /**
  69454. * @ignore
  69455. * The PassPostProcess id in the pipeline that contains the original scene color
  69456. */
  69457. SSAOOriginalSceneColorEffect: string;
  69458. /**
  69459. * @ignore
  69460. * The SSAO PostProcess id in the pipeline
  69461. */
  69462. SSAORenderEffect: string;
  69463. /**
  69464. * @ignore
  69465. * The horizontal blur PostProcess id in the pipeline
  69466. */
  69467. SSAOBlurHRenderEffect: string;
  69468. /**
  69469. * @ignore
  69470. * The vertical blur PostProcess id in the pipeline
  69471. */
  69472. SSAOBlurVRenderEffect: string;
  69473. /**
  69474. * @ignore
  69475. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69476. */
  69477. SSAOCombineRenderEffect: string;
  69478. /**
  69479. * The output strength of the SSAO post-process. Default value is 1.0.
  69480. */
  69481. totalStrength: number;
  69482. /**
  69483. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69484. */
  69485. maxZ: number;
  69486. /**
  69487. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69488. */
  69489. minZAspect: number;
  69490. private _samples;
  69491. /**
  69492. * Number of samples used for the SSAO calculations. Default value is 8
  69493. */
  69494. set samples(n: number);
  69495. get samples(): number;
  69496. private _textureSamples;
  69497. /**
  69498. * Number of samples to use for antialiasing
  69499. */
  69500. set textureSamples(n: number);
  69501. get textureSamples(): number;
  69502. /**
  69503. * Ratio object used for SSAO ratio and blur ratio
  69504. */
  69505. private _ratio;
  69506. /**
  69507. * Dynamically generated sphere sampler.
  69508. */
  69509. private _sampleSphere;
  69510. /**
  69511. * Blur filter offsets
  69512. */
  69513. private _samplerOffsets;
  69514. private _expensiveBlur;
  69515. /**
  69516. * If bilateral blur should be used
  69517. */
  69518. set expensiveBlur(b: boolean);
  69519. get expensiveBlur(): boolean;
  69520. /**
  69521. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69522. */
  69523. radius: number;
  69524. /**
  69525. * The base color of the SSAO post-process
  69526. * The final result is "base + ssao" between [0, 1]
  69527. */
  69528. base: number;
  69529. /**
  69530. * Support test.
  69531. */
  69532. static get IsSupported(): boolean;
  69533. private _scene;
  69534. private _depthTexture;
  69535. private _normalTexture;
  69536. private _randomTexture;
  69537. private _originalColorPostProcess;
  69538. private _ssaoPostProcess;
  69539. private _blurHPostProcess;
  69540. private _blurVPostProcess;
  69541. private _ssaoCombinePostProcess;
  69542. /**
  69543. * Gets active scene
  69544. */
  69545. get scene(): Scene;
  69546. /**
  69547. * @constructor
  69548. * @param name The rendering pipeline name
  69549. * @param scene The scene linked to this pipeline
  69550. * @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 }
  69551. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69552. */
  69553. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69554. /**
  69555. * Get the class name
  69556. * @returns "SSAO2RenderingPipeline"
  69557. */
  69558. getClassName(): string;
  69559. /**
  69560. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69561. */
  69562. dispose(disableGeometryBufferRenderer?: boolean): void;
  69563. private _createBlurPostProcess;
  69564. /** @hidden */
  69565. _rebuild(): void;
  69566. private _bits;
  69567. private _radicalInverse_VdC;
  69568. private _hammersley;
  69569. private _hemisphereSample_uniform;
  69570. private _generateHemisphere;
  69571. private _createSSAOPostProcess;
  69572. private _createSSAOCombinePostProcess;
  69573. private _createRandomTexture;
  69574. /**
  69575. * Serialize the rendering pipeline (Used when exporting)
  69576. * @returns the serialized object
  69577. */
  69578. serialize(): any;
  69579. /**
  69580. * Parse the serialized pipeline
  69581. * @param source Source pipeline.
  69582. * @param scene The scene to load the pipeline to.
  69583. * @param rootUrl The URL of the serialized pipeline.
  69584. * @returns An instantiated pipeline from the serialized object.
  69585. */
  69586. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69587. }
  69588. }
  69589. declare module BABYLON {
  69590. /** @hidden */
  69591. export var ssaoPixelShader: {
  69592. name: string;
  69593. shader: string;
  69594. };
  69595. }
  69596. declare module BABYLON {
  69597. /**
  69598. * Render pipeline to produce ssao effect
  69599. */
  69600. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69601. /**
  69602. * @ignore
  69603. * The PassPostProcess id in the pipeline that contains the original scene color
  69604. */
  69605. SSAOOriginalSceneColorEffect: string;
  69606. /**
  69607. * @ignore
  69608. * The SSAO PostProcess id in the pipeline
  69609. */
  69610. SSAORenderEffect: string;
  69611. /**
  69612. * @ignore
  69613. * The horizontal blur PostProcess id in the pipeline
  69614. */
  69615. SSAOBlurHRenderEffect: string;
  69616. /**
  69617. * @ignore
  69618. * The vertical blur PostProcess id in the pipeline
  69619. */
  69620. SSAOBlurVRenderEffect: string;
  69621. /**
  69622. * @ignore
  69623. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69624. */
  69625. SSAOCombineRenderEffect: string;
  69626. /**
  69627. * The output strength of the SSAO post-process. Default value is 1.0.
  69628. */
  69629. totalStrength: number;
  69630. /**
  69631. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69632. */
  69633. radius: number;
  69634. /**
  69635. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69636. * Must not be equal to fallOff and superior to fallOff.
  69637. * Default value is 0.0075
  69638. */
  69639. area: number;
  69640. /**
  69641. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69642. * Must not be equal to area and inferior to area.
  69643. * Default value is 0.000001
  69644. */
  69645. fallOff: number;
  69646. /**
  69647. * The base color of the SSAO post-process
  69648. * The final result is "base + ssao" between [0, 1]
  69649. */
  69650. base: number;
  69651. private _scene;
  69652. private _depthTexture;
  69653. private _randomTexture;
  69654. private _originalColorPostProcess;
  69655. private _ssaoPostProcess;
  69656. private _blurHPostProcess;
  69657. private _blurVPostProcess;
  69658. private _ssaoCombinePostProcess;
  69659. private _firstUpdate;
  69660. /**
  69661. * Gets active scene
  69662. */
  69663. get scene(): Scene;
  69664. /**
  69665. * @constructor
  69666. * @param name - The rendering pipeline name
  69667. * @param scene - The scene linked to this pipeline
  69668. * @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 }
  69669. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69670. */
  69671. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69672. /**
  69673. * Get the class name
  69674. * @returns "SSAORenderingPipeline"
  69675. */
  69676. getClassName(): string;
  69677. /**
  69678. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69679. */
  69680. dispose(disableDepthRender?: boolean): void;
  69681. private _createBlurPostProcess;
  69682. /** @hidden */
  69683. _rebuild(): void;
  69684. private _createSSAOPostProcess;
  69685. private _createSSAOCombinePostProcess;
  69686. private _createRandomTexture;
  69687. }
  69688. }
  69689. declare module BABYLON {
  69690. /** @hidden */
  69691. export var screenSpaceReflectionPixelShader: {
  69692. name: string;
  69693. shader: string;
  69694. };
  69695. }
  69696. declare module BABYLON {
  69697. /**
  69698. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69699. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69700. */
  69701. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69702. /**
  69703. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69704. */
  69705. threshold: number;
  69706. /**
  69707. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69708. */
  69709. strength: number;
  69710. /**
  69711. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69712. */
  69713. reflectionSpecularFalloffExponent: number;
  69714. /**
  69715. * 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]
  69716. */
  69717. step: number;
  69718. /**
  69719. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69720. */
  69721. roughnessFactor: number;
  69722. private _geometryBufferRenderer;
  69723. private _enableSmoothReflections;
  69724. private _reflectionSamples;
  69725. private _smoothSteps;
  69726. /**
  69727. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69728. * @param name The name of the effect.
  69729. * @param scene The scene containing the objects to calculate reflections.
  69730. * @param options The required width/height ratio to downsize to before computing the render pass.
  69731. * @param camera The camera to apply the render pass to.
  69732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69733. * @param engine The engine which the post process will be applied. (default: current engine)
  69734. * @param reusable If the post process can be reused on the same frame. (default: false)
  69735. * @param textureType Type of textures used when performing the post process. (default: 0)
  69736. * @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)
  69737. */
  69738. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69739. /**
  69740. * Gets wether or not smoothing reflections is enabled.
  69741. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69742. */
  69743. get enableSmoothReflections(): boolean;
  69744. /**
  69745. * Sets wether or not smoothing reflections is enabled.
  69746. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69747. */
  69748. set enableSmoothReflections(enabled: boolean);
  69749. /**
  69750. * Gets the number of samples taken while computing reflections. More samples count is high,
  69751. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69752. */
  69753. get reflectionSamples(): number;
  69754. /**
  69755. * Sets the number of samples taken while computing reflections. More samples count is high,
  69756. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69757. */
  69758. set reflectionSamples(samples: number);
  69759. /**
  69760. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69761. * more the post-process will require GPU power and can generate a drop in FPS.
  69762. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69763. */
  69764. get smoothSteps(): number;
  69765. set smoothSteps(steps: number);
  69766. private _updateEffectDefines;
  69767. }
  69768. }
  69769. declare module BABYLON {
  69770. /** @hidden */
  69771. export var standardPixelShader: {
  69772. name: string;
  69773. shader: string;
  69774. };
  69775. }
  69776. declare module BABYLON {
  69777. /**
  69778. * Standard rendering pipeline
  69779. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69780. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69781. */
  69782. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69783. /**
  69784. * Public members
  69785. */
  69786. /**
  69787. * Post-process which contains the original scene color before the pipeline applies all the effects
  69788. */
  69789. originalPostProcess: Nullable<PostProcess>;
  69790. /**
  69791. * Post-process used to down scale an image x4
  69792. */
  69793. downSampleX4PostProcess: Nullable<PostProcess>;
  69794. /**
  69795. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69796. */
  69797. brightPassPostProcess: Nullable<PostProcess>;
  69798. /**
  69799. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69800. */
  69801. blurHPostProcesses: PostProcess[];
  69802. /**
  69803. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69804. */
  69805. blurVPostProcesses: PostProcess[];
  69806. /**
  69807. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69808. */
  69809. textureAdderPostProcess: Nullable<PostProcess>;
  69810. /**
  69811. * Post-process used to create volumetric lighting effect
  69812. */
  69813. volumetricLightPostProcess: Nullable<PostProcess>;
  69814. /**
  69815. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69816. */
  69817. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69818. /**
  69819. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69820. */
  69821. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69822. /**
  69823. * Post-process used to merge the volumetric light effect and the real scene color
  69824. */
  69825. volumetricLightMergePostProces: Nullable<PostProcess>;
  69826. /**
  69827. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69828. */
  69829. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69830. /**
  69831. * Base post-process used to calculate the average luminance of the final image for HDR
  69832. */
  69833. luminancePostProcess: Nullable<PostProcess>;
  69834. /**
  69835. * Post-processes used to create down sample post-processes in order to get
  69836. * the average luminance of the final image for HDR
  69837. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69838. */
  69839. luminanceDownSamplePostProcesses: PostProcess[];
  69840. /**
  69841. * Post-process used to create a HDR effect (light adaptation)
  69842. */
  69843. hdrPostProcess: Nullable<PostProcess>;
  69844. /**
  69845. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69846. */
  69847. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69848. /**
  69849. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69850. */
  69851. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69852. /**
  69853. * Post-process used to merge the final HDR post-process and the real scene color
  69854. */
  69855. hdrFinalPostProcess: Nullable<PostProcess>;
  69856. /**
  69857. * Post-process used to create a lens flare effect
  69858. */
  69859. lensFlarePostProcess: Nullable<PostProcess>;
  69860. /**
  69861. * Post-process that merges the result of the lens flare post-process and the real scene color
  69862. */
  69863. lensFlareComposePostProcess: Nullable<PostProcess>;
  69864. /**
  69865. * Post-process used to create a motion blur effect
  69866. */
  69867. motionBlurPostProcess: Nullable<PostProcess>;
  69868. /**
  69869. * Post-process used to create a depth of field effect
  69870. */
  69871. depthOfFieldPostProcess: Nullable<PostProcess>;
  69872. /**
  69873. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69874. */
  69875. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69876. /**
  69877. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69878. */
  69879. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69880. /**
  69881. * Represents the brightness threshold in order to configure the illuminated surfaces
  69882. */
  69883. brightThreshold: number;
  69884. /**
  69885. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69886. */
  69887. blurWidth: number;
  69888. /**
  69889. * Sets if the blur for highlighted surfaces must be only horizontal
  69890. */
  69891. horizontalBlur: boolean;
  69892. /**
  69893. * Gets the overall exposure used by the pipeline
  69894. */
  69895. get exposure(): number;
  69896. /**
  69897. * Sets the overall exposure used by the pipeline
  69898. */
  69899. set exposure(value: number);
  69900. /**
  69901. * Texture used typically to simulate "dirty" on camera lens
  69902. */
  69903. lensTexture: Nullable<Texture>;
  69904. /**
  69905. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69906. */
  69907. volumetricLightCoefficient: number;
  69908. /**
  69909. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69910. */
  69911. volumetricLightPower: number;
  69912. /**
  69913. * Used the set the blur intensity to smooth the volumetric lights
  69914. */
  69915. volumetricLightBlurScale: number;
  69916. /**
  69917. * Light (spot or directional) used to generate the volumetric lights rays
  69918. * The source light must have a shadow generate so the pipeline can get its
  69919. * depth map
  69920. */
  69921. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69922. /**
  69923. * For eye adaptation, represents the minimum luminance the eye can see
  69924. */
  69925. hdrMinimumLuminance: number;
  69926. /**
  69927. * For eye adaptation, represents the decrease luminance speed
  69928. */
  69929. hdrDecreaseRate: number;
  69930. /**
  69931. * For eye adaptation, represents the increase luminance speed
  69932. */
  69933. hdrIncreaseRate: number;
  69934. /**
  69935. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69936. */
  69937. get hdrAutoExposure(): boolean;
  69938. /**
  69939. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69940. */
  69941. set hdrAutoExposure(value: boolean);
  69942. /**
  69943. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69944. */
  69945. lensColorTexture: Nullable<Texture>;
  69946. /**
  69947. * The overall strengh for the lens flare effect
  69948. */
  69949. lensFlareStrength: number;
  69950. /**
  69951. * Dispersion coefficient for lens flare ghosts
  69952. */
  69953. lensFlareGhostDispersal: number;
  69954. /**
  69955. * Main lens flare halo width
  69956. */
  69957. lensFlareHaloWidth: number;
  69958. /**
  69959. * Based on the lens distortion effect, defines how much the lens flare result
  69960. * is distorted
  69961. */
  69962. lensFlareDistortionStrength: number;
  69963. /**
  69964. * Configures the blur intensity used for for lens flare (halo)
  69965. */
  69966. lensFlareBlurWidth: number;
  69967. /**
  69968. * Lens star texture must be used to simulate rays on the flares and is available
  69969. * in the documentation
  69970. */
  69971. lensStarTexture: Nullable<Texture>;
  69972. /**
  69973. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69974. * flare effect by taking account of the dirt texture
  69975. */
  69976. lensFlareDirtTexture: Nullable<Texture>;
  69977. /**
  69978. * Represents the focal length for the depth of field effect
  69979. */
  69980. depthOfFieldDistance: number;
  69981. /**
  69982. * Represents the blur intensity for the blurred part of the depth of field effect
  69983. */
  69984. depthOfFieldBlurWidth: number;
  69985. /**
  69986. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69987. */
  69988. get motionStrength(): number;
  69989. /**
  69990. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69991. */
  69992. set motionStrength(strength: number);
  69993. /**
  69994. * Gets wether or not the motion blur post-process is object based or screen based.
  69995. */
  69996. get objectBasedMotionBlur(): boolean;
  69997. /**
  69998. * Sets wether or not the motion blur post-process should be object based or screen based
  69999. */
  70000. set objectBasedMotionBlur(value: boolean);
  70001. /**
  70002. * List of animations for the pipeline (IAnimatable implementation)
  70003. */
  70004. animations: Animation[];
  70005. /**
  70006. * Private members
  70007. */
  70008. private _scene;
  70009. private _currentDepthOfFieldSource;
  70010. private _basePostProcess;
  70011. private _fixedExposure;
  70012. private _currentExposure;
  70013. private _hdrAutoExposure;
  70014. private _hdrCurrentLuminance;
  70015. private _motionStrength;
  70016. private _isObjectBasedMotionBlur;
  70017. private _floatTextureType;
  70018. private _camerasToBeAttached;
  70019. private _ratio;
  70020. private _bloomEnabled;
  70021. private _depthOfFieldEnabled;
  70022. private _vlsEnabled;
  70023. private _lensFlareEnabled;
  70024. private _hdrEnabled;
  70025. private _motionBlurEnabled;
  70026. private _fxaaEnabled;
  70027. private _screenSpaceReflectionsEnabled;
  70028. private _motionBlurSamples;
  70029. private _volumetricLightStepsCount;
  70030. private _samples;
  70031. /**
  70032. * @ignore
  70033. * Specifies if the bloom pipeline is enabled
  70034. */
  70035. get BloomEnabled(): boolean;
  70036. set BloomEnabled(enabled: boolean);
  70037. /**
  70038. * @ignore
  70039. * Specifies if the depth of field pipeline is enabed
  70040. */
  70041. get DepthOfFieldEnabled(): boolean;
  70042. set DepthOfFieldEnabled(enabled: boolean);
  70043. /**
  70044. * @ignore
  70045. * Specifies if the lens flare pipeline is enabed
  70046. */
  70047. get LensFlareEnabled(): boolean;
  70048. set LensFlareEnabled(enabled: boolean);
  70049. /**
  70050. * @ignore
  70051. * Specifies if the HDR pipeline is enabled
  70052. */
  70053. get HDREnabled(): boolean;
  70054. set HDREnabled(enabled: boolean);
  70055. /**
  70056. * @ignore
  70057. * Specifies if the volumetric lights scattering effect is enabled
  70058. */
  70059. get VLSEnabled(): boolean;
  70060. set VLSEnabled(enabled: boolean);
  70061. /**
  70062. * @ignore
  70063. * Specifies if the motion blur effect is enabled
  70064. */
  70065. get MotionBlurEnabled(): boolean;
  70066. set MotionBlurEnabled(enabled: boolean);
  70067. /**
  70068. * Specifies if anti-aliasing is enabled
  70069. */
  70070. get fxaaEnabled(): boolean;
  70071. set fxaaEnabled(enabled: boolean);
  70072. /**
  70073. * Specifies if screen space reflections are enabled.
  70074. */
  70075. get screenSpaceReflectionsEnabled(): boolean;
  70076. set screenSpaceReflectionsEnabled(enabled: boolean);
  70077. /**
  70078. * Specifies the number of steps used to calculate the volumetric lights
  70079. * Typically in interval [50, 200]
  70080. */
  70081. get volumetricLightStepsCount(): number;
  70082. set volumetricLightStepsCount(count: number);
  70083. /**
  70084. * Specifies the number of samples used for the motion blur effect
  70085. * Typically in interval [16, 64]
  70086. */
  70087. get motionBlurSamples(): number;
  70088. set motionBlurSamples(samples: number);
  70089. /**
  70090. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70091. */
  70092. get samples(): number;
  70093. set samples(sampleCount: number);
  70094. /**
  70095. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70096. * @constructor
  70097. * @param name The rendering pipeline name
  70098. * @param scene The scene linked to this pipeline
  70099. * @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)
  70100. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70101. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70102. */
  70103. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70104. private _buildPipeline;
  70105. private _createDownSampleX4PostProcess;
  70106. private _createBrightPassPostProcess;
  70107. private _createBlurPostProcesses;
  70108. private _createTextureAdderPostProcess;
  70109. private _createVolumetricLightPostProcess;
  70110. private _createLuminancePostProcesses;
  70111. private _createHdrPostProcess;
  70112. private _createLensFlarePostProcess;
  70113. private _createDepthOfFieldPostProcess;
  70114. private _createMotionBlurPostProcess;
  70115. private _getDepthTexture;
  70116. private _disposePostProcesses;
  70117. /**
  70118. * Dispose of the pipeline and stop all post processes
  70119. */
  70120. dispose(): void;
  70121. /**
  70122. * Serialize the rendering pipeline (Used when exporting)
  70123. * @returns the serialized object
  70124. */
  70125. serialize(): any;
  70126. /**
  70127. * Parse the serialized pipeline
  70128. * @param source Source pipeline.
  70129. * @param scene The scene to load the pipeline to.
  70130. * @param rootUrl The URL of the serialized pipeline.
  70131. * @returns An instantiated pipeline from the serialized object.
  70132. */
  70133. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70134. /**
  70135. * Luminance steps
  70136. */
  70137. static LuminanceSteps: number;
  70138. }
  70139. }
  70140. declare module BABYLON {
  70141. /** @hidden */
  70142. export var stereoscopicInterlacePixelShader: {
  70143. name: string;
  70144. shader: string;
  70145. };
  70146. }
  70147. declare module BABYLON {
  70148. /**
  70149. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70150. */
  70151. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70152. private _stepSize;
  70153. private _passedProcess;
  70154. /**
  70155. * Initializes a StereoscopicInterlacePostProcessI
  70156. * @param name The name of the effect.
  70157. * @param rigCameras The rig cameras to be appled to the post process
  70158. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70159. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70161. * @param engine The engine which the post process will be applied. (default: current engine)
  70162. * @param reusable If the post process can be reused on the same frame. (default: false)
  70163. */
  70164. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70165. }
  70166. /**
  70167. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70168. */
  70169. export class StereoscopicInterlacePostProcess extends PostProcess {
  70170. private _stepSize;
  70171. private _passedProcess;
  70172. /**
  70173. * Initializes a StereoscopicInterlacePostProcess
  70174. * @param name The name of the effect.
  70175. * @param rigCameras The rig cameras to be appled to the post process
  70176. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70178. * @param engine The engine which the post process will be applied. (default: current engine)
  70179. * @param reusable If the post process can be reused on the same frame. (default: false)
  70180. */
  70181. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70182. }
  70183. }
  70184. declare module BABYLON {
  70185. /** @hidden */
  70186. export var tonemapPixelShader: {
  70187. name: string;
  70188. shader: string;
  70189. };
  70190. }
  70191. declare module BABYLON {
  70192. /** Defines operator used for tonemapping */
  70193. export enum TonemappingOperator {
  70194. /** Hable */
  70195. Hable = 0,
  70196. /** Reinhard */
  70197. Reinhard = 1,
  70198. /** HejiDawson */
  70199. HejiDawson = 2,
  70200. /** Photographic */
  70201. Photographic = 3
  70202. }
  70203. /**
  70204. * Defines a post process to apply tone mapping
  70205. */
  70206. export class TonemapPostProcess extends PostProcess {
  70207. private _operator;
  70208. /** Defines the required exposure adjustement */
  70209. exposureAdjustment: number;
  70210. /**
  70211. * Creates a new TonemapPostProcess
  70212. * @param name defines the name of the postprocess
  70213. * @param _operator defines the operator to use
  70214. * @param exposureAdjustment defines the required exposure adjustement
  70215. * @param camera defines the camera to use (can be null)
  70216. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70217. * @param engine defines the hosting engine (can be ignore if camera is set)
  70218. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70219. */
  70220. constructor(name: string, _operator: TonemappingOperator,
  70221. /** Defines the required exposure adjustement */
  70222. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70223. }
  70224. }
  70225. declare module BABYLON {
  70226. /** @hidden */
  70227. export var volumetricLightScatteringPixelShader: {
  70228. name: string;
  70229. shader: string;
  70230. };
  70231. }
  70232. declare module BABYLON {
  70233. /** @hidden */
  70234. export var volumetricLightScatteringPassVertexShader: {
  70235. name: string;
  70236. shader: string;
  70237. };
  70238. }
  70239. declare module BABYLON {
  70240. /** @hidden */
  70241. export var volumetricLightScatteringPassPixelShader: {
  70242. name: string;
  70243. shader: string;
  70244. };
  70245. }
  70246. declare module BABYLON {
  70247. /**
  70248. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70249. */
  70250. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70251. private _volumetricLightScatteringPass;
  70252. private _volumetricLightScatteringRTT;
  70253. private _viewPort;
  70254. private _screenCoordinates;
  70255. private _cachedDefines;
  70256. /**
  70257. * If not undefined, the mesh position is computed from the attached node position
  70258. */
  70259. attachedNode: {
  70260. position: Vector3;
  70261. };
  70262. /**
  70263. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70264. */
  70265. customMeshPosition: Vector3;
  70266. /**
  70267. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70268. */
  70269. useCustomMeshPosition: boolean;
  70270. /**
  70271. * If the post-process should inverse the light scattering direction
  70272. */
  70273. invert: boolean;
  70274. /**
  70275. * The internal mesh used by the post-process
  70276. */
  70277. mesh: Mesh;
  70278. /**
  70279. * @hidden
  70280. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70281. */
  70282. get useDiffuseColor(): boolean;
  70283. set useDiffuseColor(useDiffuseColor: boolean);
  70284. /**
  70285. * Array containing the excluded meshes not rendered in the internal pass
  70286. */
  70287. excludedMeshes: AbstractMesh[];
  70288. /**
  70289. * Controls the overall intensity of the post-process
  70290. */
  70291. exposure: number;
  70292. /**
  70293. * Dissipates each sample's contribution in range [0, 1]
  70294. */
  70295. decay: number;
  70296. /**
  70297. * Controls the overall intensity of each sample
  70298. */
  70299. weight: number;
  70300. /**
  70301. * Controls the density of each sample
  70302. */
  70303. density: number;
  70304. /**
  70305. * @constructor
  70306. * @param name The post-process name
  70307. * @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)
  70308. * @param camera The camera that the post-process will be attached to
  70309. * @param mesh The mesh used to create the light scattering
  70310. * @param samples The post-process quality, default 100
  70311. * @param samplingModeThe post-process filtering mode
  70312. * @param engine The babylon engine
  70313. * @param reusable If the post-process is reusable
  70314. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70315. */
  70316. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70317. /**
  70318. * Returns the string "VolumetricLightScatteringPostProcess"
  70319. * @returns "VolumetricLightScatteringPostProcess"
  70320. */
  70321. getClassName(): string;
  70322. private _isReady;
  70323. /**
  70324. * Sets the new light position for light scattering effect
  70325. * @param position The new custom light position
  70326. */
  70327. setCustomMeshPosition(position: Vector3): void;
  70328. /**
  70329. * Returns the light position for light scattering effect
  70330. * @return Vector3 The custom light position
  70331. */
  70332. getCustomMeshPosition(): Vector3;
  70333. /**
  70334. * Disposes the internal assets and detaches the post-process from the camera
  70335. */
  70336. dispose(camera: Camera): void;
  70337. /**
  70338. * Returns the render target texture used by the post-process
  70339. * @return the render target texture used by the post-process
  70340. */
  70341. getPass(): RenderTargetTexture;
  70342. private _meshExcluded;
  70343. private _createPass;
  70344. private _updateMeshScreenCoordinates;
  70345. /**
  70346. * Creates a default mesh for the Volumeric Light Scattering post-process
  70347. * @param name The mesh name
  70348. * @param scene The scene where to create the mesh
  70349. * @return the default mesh
  70350. */
  70351. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70352. }
  70353. }
  70354. declare module BABYLON {
  70355. interface Scene {
  70356. /** @hidden (Backing field) */
  70357. _boundingBoxRenderer: BoundingBoxRenderer;
  70358. /** @hidden (Backing field) */
  70359. _forceShowBoundingBoxes: boolean;
  70360. /**
  70361. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70362. */
  70363. forceShowBoundingBoxes: boolean;
  70364. /**
  70365. * Gets the bounding box renderer associated with the scene
  70366. * @returns a BoundingBoxRenderer
  70367. */
  70368. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70369. }
  70370. interface AbstractMesh {
  70371. /** @hidden (Backing field) */
  70372. _showBoundingBox: boolean;
  70373. /**
  70374. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70375. */
  70376. showBoundingBox: boolean;
  70377. }
  70378. /**
  70379. * Component responsible of rendering the bounding box of the meshes in a scene.
  70380. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70381. */
  70382. export class BoundingBoxRenderer implements ISceneComponent {
  70383. /**
  70384. * The component name helpfull to identify the component in the list of scene components.
  70385. */
  70386. readonly name: string;
  70387. /**
  70388. * The scene the component belongs to.
  70389. */
  70390. scene: Scene;
  70391. /**
  70392. * Color of the bounding box lines placed in front of an object
  70393. */
  70394. frontColor: Color3;
  70395. /**
  70396. * Color of the bounding box lines placed behind an object
  70397. */
  70398. backColor: Color3;
  70399. /**
  70400. * Defines if the renderer should show the back lines or not
  70401. */
  70402. showBackLines: boolean;
  70403. /**
  70404. * Observable raised before rendering a bounding box
  70405. */
  70406. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70407. /**
  70408. * Observable raised after rendering a bounding box
  70409. */
  70410. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70411. /**
  70412. * @hidden
  70413. */
  70414. renderList: SmartArray<BoundingBox>;
  70415. private _colorShader;
  70416. private _vertexBuffers;
  70417. private _indexBuffer;
  70418. private _fillIndexBuffer;
  70419. private _fillIndexData;
  70420. /**
  70421. * Instantiates a new bounding box renderer in a scene.
  70422. * @param scene the scene the renderer renders in
  70423. */
  70424. constructor(scene: Scene);
  70425. /**
  70426. * Registers the component in a given scene
  70427. */
  70428. register(): void;
  70429. private _evaluateSubMesh;
  70430. private _activeMesh;
  70431. private _prepareRessources;
  70432. private _createIndexBuffer;
  70433. /**
  70434. * Rebuilds the elements related to this component in case of
  70435. * context lost for instance.
  70436. */
  70437. rebuild(): void;
  70438. /**
  70439. * @hidden
  70440. */
  70441. reset(): void;
  70442. /**
  70443. * Render the bounding boxes of a specific rendering group
  70444. * @param renderingGroupId defines the rendering group to render
  70445. */
  70446. render(renderingGroupId: number): void;
  70447. /**
  70448. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70449. * @param mesh Define the mesh to render the occlusion bounding box for
  70450. */
  70451. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70452. /**
  70453. * Dispose and release the resources attached to this renderer.
  70454. */
  70455. dispose(): void;
  70456. }
  70457. }
  70458. declare module BABYLON {
  70459. interface Scene {
  70460. /** @hidden (Backing field) */
  70461. _depthRenderer: {
  70462. [id: string]: DepthRenderer;
  70463. };
  70464. /**
  70465. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70466. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70467. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70468. * @returns the created depth renderer
  70469. */
  70470. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70471. /**
  70472. * Disables a depth renderer for a given camera
  70473. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70474. */
  70475. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70476. }
  70477. /**
  70478. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70479. * in several rendering techniques.
  70480. */
  70481. export class DepthRendererSceneComponent implements ISceneComponent {
  70482. /**
  70483. * The component name helpfull to identify the component in the list of scene components.
  70484. */
  70485. readonly name: string;
  70486. /**
  70487. * The scene the component belongs to.
  70488. */
  70489. scene: Scene;
  70490. /**
  70491. * Creates a new instance of the component for the given scene
  70492. * @param scene Defines the scene to register the component in
  70493. */
  70494. constructor(scene: Scene);
  70495. /**
  70496. * Registers the component in a given scene
  70497. */
  70498. register(): void;
  70499. /**
  70500. * Rebuilds the elements related to this component in case of
  70501. * context lost for instance.
  70502. */
  70503. rebuild(): void;
  70504. /**
  70505. * Disposes the component and the associated ressources
  70506. */
  70507. dispose(): void;
  70508. private _gatherRenderTargets;
  70509. private _gatherActiveCameraRenderTargets;
  70510. }
  70511. }
  70512. declare module BABYLON {
  70513. /** @hidden */
  70514. export var outlinePixelShader: {
  70515. name: string;
  70516. shader: string;
  70517. };
  70518. }
  70519. declare module BABYLON {
  70520. /** @hidden */
  70521. export var outlineVertexShader: {
  70522. name: string;
  70523. shader: string;
  70524. };
  70525. }
  70526. declare module BABYLON {
  70527. interface Scene {
  70528. /** @hidden */
  70529. _outlineRenderer: OutlineRenderer;
  70530. /**
  70531. * Gets the outline renderer associated with the scene
  70532. * @returns a OutlineRenderer
  70533. */
  70534. getOutlineRenderer(): OutlineRenderer;
  70535. }
  70536. interface AbstractMesh {
  70537. /** @hidden (Backing field) */
  70538. _renderOutline: boolean;
  70539. /**
  70540. * Gets or sets a boolean indicating if the outline must be rendered as well
  70541. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70542. */
  70543. renderOutline: boolean;
  70544. /** @hidden (Backing field) */
  70545. _renderOverlay: boolean;
  70546. /**
  70547. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70548. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70549. */
  70550. renderOverlay: boolean;
  70551. }
  70552. /**
  70553. * This class is responsible to draw bothe outline/overlay of meshes.
  70554. * It should not be used directly but through the available method on mesh.
  70555. */
  70556. export class OutlineRenderer implements ISceneComponent {
  70557. /**
  70558. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70559. */
  70560. private static _StencilReference;
  70561. /**
  70562. * The name of the component. Each component must have a unique name.
  70563. */
  70564. name: string;
  70565. /**
  70566. * The scene the component belongs to.
  70567. */
  70568. scene: Scene;
  70569. /**
  70570. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70571. */
  70572. zOffset: number;
  70573. private _engine;
  70574. private _effect;
  70575. private _cachedDefines;
  70576. private _savedDepthWrite;
  70577. /**
  70578. * Instantiates a new outline renderer. (There could be only one per scene).
  70579. * @param scene Defines the scene it belongs to
  70580. */
  70581. constructor(scene: Scene);
  70582. /**
  70583. * Register the component to one instance of a scene.
  70584. */
  70585. register(): void;
  70586. /**
  70587. * Rebuilds the elements related to this component in case of
  70588. * context lost for instance.
  70589. */
  70590. rebuild(): void;
  70591. /**
  70592. * Disposes the component and the associated ressources.
  70593. */
  70594. dispose(): void;
  70595. /**
  70596. * Renders the outline in the canvas.
  70597. * @param subMesh Defines the sumesh to render
  70598. * @param batch Defines the batch of meshes in case of instances
  70599. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70600. */
  70601. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70602. /**
  70603. * Returns whether or not the outline renderer is ready for a given submesh.
  70604. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70605. * @param subMesh Defines the submesh to check readyness for
  70606. * @param useInstances Defines wheter wee are trying to render instances or not
  70607. * @returns true if ready otherwise false
  70608. */
  70609. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70610. private _beforeRenderingMesh;
  70611. private _afterRenderingMesh;
  70612. }
  70613. }
  70614. declare module BABYLON {
  70615. /**
  70616. * Defines the basic options interface of a Sprite Frame Source Size.
  70617. */
  70618. export interface ISpriteJSONSpriteSourceSize {
  70619. /**
  70620. * number of the original width of the Frame
  70621. */
  70622. w: number;
  70623. /**
  70624. * number of the original height of the Frame
  70625. */
  70626. h: number;
  70627. }
  70628. /**
  70629. * Defines the basic options interface of a Sprite Frame Data.
  70630. */
  70631. export interface ISpriteJSONSpriteFrameData {
  70632. /**
  70633. * number of the x offset of the Frame
  70634. */
  70635. x: number;
  70636. /**
  70637. * number of the y offset of the Frame
  70638. */
  70639. y: number;
  70640. /**
  70641. * number of the width of the Frame
  70642. */
  70643. w: number;
  70644. /**
  70645. * number of the height of the Frame
  70646. */
  70647. h: number;
  70648. }
  70649. /**
  70650. * Defines the basic options interface of a JSON Sprite.
  70651. */
  70652. export interface ISpriteJSONSprite {
  70653. /**
  70654. * string name of the Frame
  70655. */
  70656. filename: string;
  70657. /**
  70658. * ISpriteJSONSpriteFrame basic object of the frame data
  70659. */
  70660. frame: ISpriteJSONSpriteFrameData;
  70661. /**
  70662. * boolean to flag is the frame was rotated.
  70663. */
  70664. rotated: boolean;
  70665. /**
  70666. * boolean to flag is the frame was trimmed.
  70667. */
  70668. trimmed: boolean;
  70669. /**
  70670. * ISpriteJSONSpriteFrame basic object of the source data
  70671. */
  70672. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70673. /**
  70674. * ISpriteJSONSpriteFrame basic object of the source data
  70675. */
  70676. sourceSize: ISpriteJSONSpriteSourceSize;
  70677. }
  70678. /**
  70679. * Defines the basic options interface of a JSON atlas.
  70680. */
  70681. export interface ISpriteJSONAtlas {
  70682. /**
  70683. * Array of objects that contain the frame data.
  70684. */
  70685. frames: Array<ISpriteJSONSprite>;
  70686. /**
  70687. * object basic object containing the sprite meta data.
  70688. */
  70689. meta?: object;
  70690. }
  70691. }
  70692. declare module BABYLON {
  70693. /** @hidden */
  70694. export var spriteMapPixelShader: {
  70695. name: string;
  70696. shader: string;
  70697. };
  70698. }
  70699. declare module BABYLON {
  70700. /** @hidden */
  70701. export var spriteMapVertexShader: {
  70702. name: string;
  70703. shader: string;
  70704. };
  70705. }
  70706. declare module BABYLON {
  70707. /**
  70708. * Defines the basic options interface of a SpriteMap
  70709. */
  70710. export interface ISpriteMapOptions {
  70711. /**
  70712. * Vector2 of the number of cells in the grid.
  70713. */
  70714. stageSize?: Vector2;
  70715. /**
  70716. * Vector2 of the size of the output plane in World Units.
  70717. */
  70718. outputSize?: Vector2;
  70719. /**
  70720. * Vector3 of the position of the output plane in World Units.
  70721. */
  70722. outputPosition?: Vector3;
  70723. /**
  70724. * Vector3 of the rotation of the output plane.
  70725. */
  70726. outputRotation?: Vector3;
  70727. /**
  70728. * number of layers that the system will reserve in resources.
  70729. */
  70730. layerCount?: number;
  70731. /**
  70732. * number of max animation frames a single cell will reserve in resources.
  70733. */
  70734. maxAnimationFrames?: number;
  70735. /**
  70736. * number cell index of the base tile when the system compiles.
  70737. */
  70738. baseTile?: number;
  70739. /**
  70740. * boolean flip the sprite after its been repositioned by the framing data.
  70741. */
  70742. flipU?: boolean;
  70743. /**
  70744. * Vector3 scalar of the global RGB values of the SpriteMap.
  70745. */
  70746. colorMultiply?: Vector3;
  70747. }
  70748. /**
  70749. * Defines the IDisposable interface in order to be cleanable from resources.
  70750. */
  70751. export interface ISpriteMap extends IDisposable {
  70752. /**
  70753. * String name of the SpriteMap.
  70754. */
  70755. name: string;
  70756. /**
  70757. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70758. */
  70759. atlasJSON: ISpriteJSONAtlas;
  70760. /**
  70761. * Texture of the SpriteMap.
  70762. */
  70763. spriteSheet: Texture;
  70764. /**
  70765. * The parameters to initialize the SpriteMap with.
  70766. */
  70767. options: ISpriteMapOptions;
  70768. }
  70769. /**
  70770. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70771. */
  70772. export class SpriteMap implements ISpriteMap {
  70773. /** The Name of the spriteMap */
  70774. name: string;
  70775. /** The JSON file with the frame and meta data */
  70776. atlasJSON: ISpriteJSONAtlas;
  70777. /** The systems Sprite Sheet Texture */
  70778. spriteSheet: Texture;
  70779. /** Arguments passed with the Constructor */
  70780. options: ISpriteMapOptions;
  70781. /** Public Sprite Storage array, parsed from atlasJSON */
  70782. sprites: Array<ISpriteJSONSprite>;
  70783. /** Returns the Number of Sprites in the System */
  70784. get spriteCount(): number;
  70785. /** Returns the Position of Output Plane*/
  70786. get position(): Vector3;
  70787. /** Returns the Position of Output Plane*/
  70788. set position(v: Vector3);
  70789. /** Returns the Rotation of Output Plane*/
  70790. get rotation(): Vector3;
  70791. /** Returns the Rotation of Output Plane*/
  70792. set rotation(v: Vector3);
  70793. /** Sets the AnimationMap*/
  70794. get animationMap(): RawTexture;
  70795. /** Sets the AnimationMap*/
  70796. set animationMap(v: RawTexture);
  70797. /** Scene that the SpriteMap was created in */
  70798. private _scene;
  70799. /** Texture Buffer of Float32 that holds tile frame data*/
  70800. private _frameMap;
  70801. /** Texture Buffers of Float32 that holds tileMap data*/
  70802. private _tileMaps;
  70803. /** Texture Buffer of Float32 that holds Animation Data*/
  70804. private _animationMap;
  70805. /** Custom ShaderMaterial Central to the System*/
  70806. private _material;
  70807. /** Custom ShaderMaterial Central to the System*/
  70808. private _output;
  70809. /** Systems Time Ticker*/
  70810. private _time;
  70811. /**
  70812. * Creates a new SpriteMap
  70813. * @param name defines the SpriteMaps Name
  70814. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70815. * @param spriteSheet is the Texture that the Sprites are on.
  70816. * @param options a basic deployment configuration
  70817. * @param scene The Scene that the map is deployed on
  70818. */
  70819. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70820. /**
  70821. * Returns tileID location
  70822. * @returns Vector2 the cell position ID
  70823. */
  70824. getTileID(): Vector2;
  70825. /**
  70826. * Gets the UV location of the mouse over the SpriteMap.
  70827. * @returns Vector2 the UV position of the mouse interaction
  70828. */
  70829. getMousePosition(): Vector2;
  70830. /**
  70831. * Creates the "frame" texture Buffer
  70832. * -------------------------------------
  70833. * Structure of frames
  70834. * "filename": "Falling-Water-2.png",
  70835. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70836. * "rotated": true,
  70837. * "trimmed": true,
  70838. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70839. * "sourceSize": {"w":32,"h":32}
  70840. * @returns RawTexture of the frameMap
  70841. */
  70842. private _createFrameBuffer;
  70843. /**
  70844. * Creates the tileMap texture Buffer
  70845. * @param buffer normally and array of numbers, or a false to generate from scratch
  70846. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70847. * @returns RawTexture of the tileMap
  70848. */
  70849. private _createTileBuffer;
  70850. /**
  70851. * Modifies the data of the tileMaps
  70852. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70853. * @param pos is the iVector2 Coordinates of the Tile
  70854. * @param tile The SpriteIndex of the new Tile
  70855. */
  70856. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70857. /**
  70858. * Creates the animationMap texture Buffer
  70859. * @param buffer normally and array of numbers, or a false to generate from scratch
  70860. * @returns RawTexture of the animationMap
  70861. */
  70862. private _createTileAnimationBuffer;
  70863. /**
  70864. * Modifies the data of the animationMap
  70865. * @param cellID is the Index of the Sprite
  70866. * @param _frame is the target Animation frame
  70867. * @param toCell is the Target Index of the next frame of the animation
  70868. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70869. * @param speed is a global scalar of the time variable on the map.
  70870. */
  70871. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70872. /**
  70873. * Exports the .tilemaps file
  70874. */
  70875. saveTileMaps(): void;
  70876. /**
  70877. * Imports the .tilemaps file
  70878. * @param url of the .tilemaps file
  70879. */
  70880. loadTileMaps(url: string): void;
  70881. /**
  70882. * Release associated resources
  70883. */
  70884. dispose(): void;
  70885. }
  70886. }
  70887. declare module BABYLON {
  70888. /**
  70889. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70890. * @see http://doc.babylonjs.com/babylon101/sprites
  70891. */
  70892. export class SpritePackedManager extends SpriteManager {
  70893. /** defines the packed manager's name */
  70894. name: string;
  70895. /**
  70896. * Creates a new sprite manager from a packed sprite sheet
  70897. * @param name defines the manager's name
  70898. * @param imgUrl defines the sprite sheet url
  70899. * @param capacity defines the maximum allowed number of sprites
  70900. * @param scene defines the hosting scene
  70901. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70902. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70903. * @param samplingMode defines the smapling mode to use with spritesheet
  70904. * @param fromPacked set to true; do not alter
  70905. */
  70906. constructor(
  70907. /** defines the packed manager's name */
  70908. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70909. }
  70910. }
  70911. declare module BABYLON {
  70912. /**
  70913. * Defines the list of states available for a task inside a AssetsManager
  70914. */
  70915. export enum AssetTaskState {
  70916. /**
  70917. * Initialization
  70918. */
  70919. INIT = 0,
  70920. /**
  70921. * Running
  70922. */
  70923. RUNNING = 1,
  70924. /**
  70925. * Done
  70926. */
  70927. DONE = 2,
  70928. /**
  70929. * Error
  70930. */
  70931. ERROR = 3
  70932. }
  70933. /**
  70934. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70935. */
  70936. export abstract class AbstractAssetTask {
  70937. /**
  70938. * Task name
  70939. */ name: string;
  70940. /**
  70941. * Callback called when the task is successful
  70942. */
  70943. onSuccess: (task: any) => void;
  70944. /**
  70945. * Callback called when the task is not successful
  70946. */
  70947. onError: (task: any, message?: string, exception?: any) => void;
  70948. /**
  70949. * Creates a new AssetsManager
  70950. * @param name defines the name of the task
  70951. */
  70952. constructor(
  70953. /**
  70954. * Task name
  70955. */ name: string);
  70956. private _isCompleted;
  70957. private _taskState;
  70958. private _errorObject;
  70959. /**
  70960. * Get if the task is completed
  70961. */
  70962. get isCompleted(): boolean;
  70963. /**
  70964. * Gets the current state of the task
  70965. */
  70966. get taskState(): AssetTaskState;
  70967. /**
  70968. * Gets the current error object (if task is in error)
  70969. */
  70970. get errorObject(): {
  70971. message?: string;
  70972. exception?: any;
  70973. };
  70974. /**
  70975. * Internal only
  70976. * @hidden
  70977. */
  70978. _setErrorObject(message?: string, exception?: any): void;
  70979. /**
  70980. * Execute the current task
  70981. * @param scene defines the scene where you want your assets to be loaded
  70982. * @param onSuccess is a callback called when the task is successfully executed
  70983. * @param onError is a callback called if an error occurs
  70984. */
  70985. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70986. /**
  70987. * Execute the current task
  70988. * @param scene defines the scene where you want your assets to be loaded
  70989. * @param onSuccess is a callback called when the task is successfully executed
  70990. * @param onError is a callback called if an error occurs
  70991. */
  70992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70993. /**
  70994. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70995. * This can be used with failed tasks that have the reason for failure fixed.
  70996. */
  70997. reset(): void;
  70998. private onErrorCallback;
  70999. private onDoneCallback;
  71000. }
  71001. /**
  71002. * Define the interface used by progress events raised during assets loading
  71003. */
  71004. export interface IAssetsProgressEvent {
  71005. /**
  71006. * Defines the number of remaining tasks to process
  71007. */
  71008. remainingCount: number;
  71009. /**
  71010. * Defines the total number of tasks
  71011. */
  71012. totalCount: number;
  71013. /**
  71014. * Defines the task that was just processed
  71015. */
  71016. task: AbstractAssetTask;
  71017. }
  71018. /**
  71019. * Class used to share progress information about assets loading
  71020. */
  71021. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71022. /**
  71023. * Defines the number of remaining tasks to process
  71024. */
  71025. remainingCount: number;
  71026. /**
  71027. * Defines the total number of tasks
  71028. */
  71029. totalCount: number;
  71030. /**
  71031. * Defines the task that was just processed
  71032. */
  71033. task: AbstractAssetTask;
  71034. /**
  71035. * Creates a AssetsProgressEvent
  71036. * @param remainingCount defines the number of remaining tasks to process
  71037. * @param totalCount defines the total number of tasks
  71038. * @param task defines the task that was just processed
  71039. */
  71040. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71041. }
  71042. /**
  71043. * Define a task used by AssetsManager to load meshes
  71044. */
  71045. export class MeshAssetTask extends AbstractAssetTask {
  71046. /**
  71047. * Defines the name of the task
  71048. */
  71049. name: string;
  71050. /**
  71051. * Defines the list of mesh's names you want to load
  71052. */
  71053. meshesNames: any;
  71054. /**
  71055. * Defines the root url to use as a base to load your meshes and associated resources
  71056. */
  71057. rootUrl: string;
  71058. /**
  71059. * Defines the filename or File of the scene to load from
  71060. */
  71061. sceneFilename: string | File;
  71062. /**
  71063. * Gets the list of loaded meshes
  71064. */
  71065. loadedMeshes: Array<AbstractMesh>;
  71066. /**
  71067. * Gets the list of loaded particle systems
  71068. */
  71069. loadedParticleSystems: Array<IParticleSystem>;
  71070. /**
  71071. * Gets the list of loaded skeletons
  71072. */
  71073. loadedSkeletons: Array<Skeleton>;
  71074. /**
  71075. * Gets the list of loaded animation groups
  71076. */
  71077. loadedAnimationGroups: Array<AnimationGroup>;
  71078. /**
  71079. * Callback called when the task is successful
  71080. */
  71081. onSuccess: (task: MeshAssetTask) => void;
  71082. /**
  71083. * Callback called when the task is successful
  71084. */
  71085. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71086. /**
  71087. * Creates a new MeshAssetTask
  71088. * @param name defines the name of the task
  71089. * @param meshesNames defines the list of mesh's names you want to load
  71090. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71091. * @param sceneFilename defines the filename or File of the scene to load from
  71092. */
  71093. constructor(
  71094. /**
  71095. * Defines the name of the task
  71096. */
  71097. name: string,
  71098. /**
  71099. * Defines the list of mesh's names you want to load
  71100. */
  71101. meshesNames: any,
  71102. /**
  71103. * Defines the root url to use as a base to load your meshes and associated resources
  71104. */
  71105. rootUrl: string,
  71106. /**
  71107. * Defines the filename or File of the scene to load from
  71108. */
  71109. sceneFilename: string | File);
  71110. /**
  71111. * Execute the current task
  71112. * @param scene defines the scene where you want your assets to be loaded
  71113. * @param onSuccess is a callback called when the task is successfully executed
  71114. * @param onError is a callback called if an error occurs
  71115. */
  71116. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71117. }
  71118. /**
  71119. * Define a task used by AssetsManager to load text content
  71120. */
  71121. export class TextFileAssetTask extends AbstractAssetTask {
  71122. /**
  71123. * Defines the name of the task
  71124. */
  71125. name: string;
  71126. /**
  71127. * Defines the location of the file to load
  71128. */
  71129. url: string;
  71130. /**
  71131. * Gets the loaded text string
  71132. */
  71133. text: string;
  71134. /**
  71135. * Callback called when the task is successful
  71136. */
  71137. onSuccess: (task: TextFileAssetTask) => void;
  71138. /**
  71139. * Callback called when the task is successful
  71140. */
  71141. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71142. /**
  71143. * Creates a new TextFileAssetTask object
  71144. * @param name defines the name of the task
  71145. * @param url defines the location of the file to load
  71146. */
  71147. constructor(
  71148. /**
  71149. * Defines the name of the task
  71150. */
  71151. name: string,
  71152. /**
  71153. * Defines the location of the file to load
  71154. */
  71155. url: string);
  71156. /**
  71157. * Execute the current task
  71158. * @param scene defines the scene where you want your assets to be loaded
  71159. * @param onSuccess is a callback called when the task is successfully executed
  71160. * @param onError is a callback called if an error occurs
  71161. */
  71162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71163. }
  71164. /**
  71165. * Define a task used by AssetsManager to load binary data
  71166. */
  71167. export class BinaryFileAssetTask extends AbstractAssetTask {
  71168. /**
  71169. * Defines the name of the task
  71170. */
  71171. name: string;
  71172. /**
  71173. * Defines the location of the file to load
  71174. */
  71175. url: string;
  71176. /**
  71177. * Gets the lodaded data (as an array buffer)
  71178. */
  71179. data: ArrayBuffer;
  71180. /**
  71181. * Callback called when the task is successful
  71182. */
  71183. onSuccess: (task: BinaryFileAssetTask) => void;
  71184. /**
  71185. * Callback called when the task is successful
  71186. */
  71187. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71188. /**
  71189. * Creates a new BinaryFileAssetTask object
  71190. * @param name defines the name of the new task
  71191. * @param url defines the location of the file to load
  71192. */
  71193. constructor(
  71194. /**
  71195. * Defines the name of the task
  71196. */
  71197. name: string,
  71198. /**
  71199. * Defines the location of the file to load
  71200. */
  71201. url: string);
  71202. /**
  71203. * Execute the current task
  71204. * @param scene defines the scene where you want your assets to be loaded
  71205. * @param onSuccess is a callback called when the task is successfully executed
  71206. * @param onError is a callback called if an error occurs
  71207. */
  71208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71209. }
  71210. /**
  71211. * Define a task used by AssetsManager to load images
  71212. */
  71213. export class ImageAssetTask extends AbstractAssetTask {
  71214. /**
  71215. * Defines the name of the task
  71216. */
  71217. name: string;
  71218. /**
  71219. * Defines the location of the image to load
  71220. */
  71221. url: string;
  71222. /**
  71223. * Gets the loaded images
  71224. */
  71225. image: HTMLImageElement;
  71226. /**
  71227. * Callback called when the task is successful
  71228. */
  71229. onSuccess: (task: ImageAssetTask) => void;
  71230. /**
  71231. * Callback called when the task is successful
  71232. */
  71233. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71234. /**
  71235. * Creates a new ImageAssetTask
  71236. * @param name defines the name of the task
  71237. * @param url defines the location of the image to load
  71238. */
  71239. constructor(
  71240. /**
  71241. * Defines the name of the task
  71242. */
  71243. name: string,
  71244. /**
  71245. * Defines the location of the image to load
  71246. */
  71247. url: string);
  71248. /**
  71249. * Execute the current task
  71250. * @param scene defines the scene where you want your assets to be loaded
  71251. * @param onSuccess is a callback called when the task is successfully executed
  71252. * @param onError is a callback called if an error occurs
  71253. */
  71254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71255. }
  71256. /**
  71257. * Defines the interface used by texture loading tasks
  71258. */
  71259. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71260. /**
  71261. * Gets the loaded texture
  71262. */
  71263. texture: TEX;
  71264. }
  71265. /**
  71266. * Define a task used by AssetsManager to load 2D textures
  71267. */
  71268. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71269. /**
  71270. * Defines the name of the task
  71271. */
  71272. name: string;
  71273. /**
  71274. * Defines the location of the file to load
  71275. */
  71276. url: string;
  71277. /**
  71278. * Defines if mipmap should not be generated (default is false)
  71279. */
  71280. noMipmap?: boolean | undefined;
  71281. /**
  71282. * Defines if texture must be inverted on Y axis (default is true)
  71283. */
  71284. invertY: boolean;
  71285. /**
  71286. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71287. */
  71288. samplingMode: number;
  71289. /**
  71290. * Gets the loaded texture
  71291. */
  71292. texture: Texture;
  71293. /**
  71294. * Callback called when the task is successful
  71295. */
  71296. onSuccess: (task: TextureAssetTask) => void;
  71297. /**
  71298. * Callback called when the task is successful
  71299. */
  71300. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71301. /**
  71302. * Creates a new TextureAssetTask object
  71303. * @param name defines the name of the task
  71304. * @param url defines the location of the file to load
  71305. * @param noMipmap defines if mipmap should not be generated (default is false)
  71306. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71307. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71308. */
  71309. constructor(
  71310. /**
  71311. * Defines the name of the task
  71312. */
  71313. name: string,
  71314. /**
  71315. * Defines the location of the file to load
  71316. */
  71317. url: string,
  71318. /**
  71319. * Defines if mipmap should not be generated (default is false)
  71320. */
  71321. noMipmap?: boolean | undefined,
  71322. /**
  71323. * Defines if texture must be inverted on Y axis (default is true)
  71324. */
  71325. invertY?: boolean,
  71326. /**
  71327. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71328. */
  71329. samplingMode?: number);
  71330. /**
  71331. * Execute the current task
  71332. * @param scene defines the scene where you want your assets to be loaded
  71333. * @param onSuccess is a callback called when the task is successfully executed
  71334. * @param onError is a callback called if an error occurs
  71335. */
  71336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71337. }
  71338. /**
  71339. * Define a task used by AssetsManager to load cube textures
  71340. */
  71341. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71342. /**
  71343. * Defines the name of the task
  71344. */
  71345. name: string;
  71346. /**
  71347. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71348. */
  71349. url: string;
  71350. /**
  71351. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71352. */
  71353. extensions?: string[] | undefined;
  71354. /**
  71355. * Defines if mipmaps should not be generated (default is false)
  71356. */
  71357. noMipmap?: boolean | undefined;
  71358. /**
  71359. * Defines the explicit list of files (undefined by default)
  71360. */
  71361. files?: string[] | undefined;
  71362. /**
  71363. * Gets the loaded texture
  71364. */
  71365. texture: CubeTexture;
  71366. /**
  71367. * Callback called when the task is successful
  71368. */
  71369. onSuccess: (task: CubeTextureAssetTask) => void;
  71370. /**
  71371. * Callback called when the task is successful
  71372. */
  71373. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71374. /**
  71375. * Creates a new CubeTextureAssetTask
  71376. * @param name defines the name of the task
  71377. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71378. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71379. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71380. * @param files defines the explicit list of files (undefined by default)
  71381. */
  71382. constructor(
  71383. /**
  71384. * Defines the name of the task
  71385. */
  71386. name: string,
  71387. /**
  71388. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71389. */
  71390. url: string,
  71391. /**
  71392. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71393. */
  71394. extensions?: string[] | undefined,
  71395. /**
  71396. * Defines if mipmaps should not be generated (default is false)
  71397. */
  71398. noMipmap?: boolean | undefined,
  71399. /**
  71400. * Defines the explicit list of files (undefined by default)
  71401. */
  71402. files?: string[] | undefined);
  71403. /**
  71404. * Execute the current task
  71405. * @param scene defines the scene where you want your assets to be loaded
  71406. * @param onSuccess is a callback called when the task is successfully executed
  71407. * @param onError is a callback called if an error occurs
  71408. */
  71409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71410. }
  71411. /**
  71412. * Define a task used by AssetsManager to load HDR cube textures
  71413. */
  71414. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71415. /**
  71416. * Defines the name of the task
  71417. */
  71418. name: string;
  71419. /**
  71420. * Defines the location of the file to load
  71421. */
  71422. url: string;
  71423. /**
  71424. * Defines the desired size (the more it increases the longer the generation will be)
  71425. */
  71426. size: number;
  71427. /**
  71428. * Defines if mipmaps should not be generated (default is false)
  71429. */
  71430. noMipmap: boolean;
  71431. /**
  71432. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71433. */
  71434. generateHarmonics: boolean;
  71435. /**
  71436. * 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)
  71437. */
  71438. gammaSpace: boolean;
  71439. /**
  71440. * Internal Use Only
  71441. */
  71442. reserved: boolean;
  71443. /**
  71444. * Gets the loaded texture
  71445. */
  71446. texture: HDRCubeTexture;
  71447. /**
  71448. * Callback called when the task is successful
  71449. */
  71450. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71451. /**
  71452. * Callback called when the task is successful
  71453. */
  71454. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71455. /**
  71456. * Creates a new HDRCubeTextureAssetTask object
  71457. * @param name defines the name of the task
  71458. * @param url defines the location of the file to load
  71459. * @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.
  71460. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71461. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71462. * @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)
  71463. * @param reserved Internal use only
  71464. */
  71465. constructor(
  71466. /**
  71467. * Defines the name of the task
  71468. */
  71469. name: string,
  71470. /**
  71471. * Defines the location of the file to load
  71472. */
  71473. url: string,
  71474. /**
  71475. * Defines the desired size (the more it increases the longer the generation will be)
  71476. */
  71477. size: number,
  71478. /**
  71479. * Defines if mipmaps should not be generated (default is false)
  71480. */
  71481. noMipmap?: boolean,
  71482. /**
  71483. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71484. */
  71485. generateHarmonics?: boolean,
  71486. /**
  71487. * 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)
  71488. */
  71489. gammaSpace?: boolean,
  71490. /**
  71491. * Internal Use Only
  71492. */
  71493. reserved?: boolean);
  71494. /**
  71495. * Execute the current task
  71496. * @param scene defines the scene where you want your assets to be loaded
  71497. * @param onSuccess is a callback called when the task is successfully executed
  71498. * @param onError is a callback called if an error occurs
  71499. */
  71500. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71501. }
  71502. /**
  71503. * Define a task used by AssetsManager to load Equirectangular cube textures
  71504. */
  71505. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71506. /**
  71507. * Defines the name of the task
  71508. */
  71509. name: string;
  71510. /**
  71511. * Defines the location of the file to load
  71512. */
  71513. url: string;
  71514. /**
  71515. * Defines the desired size (the more it increases the longer the generation will be)
  71516. */
  71517. size: number;
  71518. /**
  71519. * Defines if mipmaps should not be generated (default is false)
  71520. */
  71521. noMipmap: boolean;
  71522. /**
  71523. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71524. * but the standard material would require them in Gamma space) (default is true)
  71525. */
  71526. gammaSpace: boolean;
  71527. /**
  71528. * Gets the loaded texture
  71529. */
  71530. texture: EquiRectangularCubeTexture;
  71531. /**
  71532. * Callback called when the task is successful
  71533. */
  71534. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71535. /**
  71536. * Callback called when the task is successful
  71537. */
  71538. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71539. /**
  71540. * Creates a new EquiRectangularCubeTextureAssetTask object
  71541. * @param name defines the name of the task
  71542. * @param url defines the location of the file to load
  71543. * @param size defines the desired size (the more it increases the longer the generation will be)
  71544. * If the size is omitted this implies you are using a preprocessed cubemap.
  71545. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71546. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71547. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71548. * (default is true)
  71549. */
  71550. constructor(
  71551. /**
  71552. * Defines the name of the task
  71553. */
  71554. name: string,
  71555. /**
  71556. * Defines the location of the file to load
  71557. */
  71558. url: string,
  71559. /**
  71560. * Defines the desired size (the more it increases the longer the generation will be)
  71561. */
  71562. size: number,
  71563. /**
  71564. * Defines if mipmaps should not be generated (default is false)
  71565. */
  71566. noMipmap?: boolean,
  71567. /**
  71568. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71569. * but the standard material would require them in Gamma space) (default is true)
  71570. */
  71571. gammaSpace?: boolean);
  71572. /**
  71573. * Execute the current task
  71574. * @param scene defines the scene where you want your assets to be loaded
  71575. * @param onSuccess is a callback called when the task is successfully executed
  71576. * @param onError is a callback called if an error occurs
  71577. */
  71578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71579. }
  71580. /**
  71581. * This class can be used to easily import assets into a scene
  71582. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71583. */
  71584. export class AssetsManager {
  71585. private _scene;
  71586. private _isLoading;
  71587. protected _tasks: AbstractAssetTask[];
  71588. protected _waitingTasksCount: number;
  71589. protected _totalTasksCount: number;
  71590. /**
  71591. * Callback called when all tasks are processed
  71592. */
  71593. onFinish: (tasks: AbstractAssetTask[]) => void;
  71594. /**
  71595. * Callback called when a task is successful
  71596. */
  71597. onTaskSuccess: (task: AbstractAssetTask) => void;
  71598. /**
  71599. * Callback called when a task had an error
  71600. */
  71601. onTaskError: (task: AbstractAssetTask) => void;
  71602. /**
  71603. * Callback called when a task is done (whatever the result is)
  71604. */
  71605. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71606. /**
  71607. * Observable called when all tasks are processed
  71608. */
  71609. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71610. /**
  71611. * Observable called when a task had an error
  71612. */
  71613. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71614. /**
  71615. * Observable called when all tasks were executed
  71616. */
  71617. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71618. /**
  71619. * Observable called when a task is done (whatever the result is)
  71620. */
  71621. onProgressObservable: Observable<IAssetsProgressEvent>;
  71622. /**
  71623. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71624. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71625. */
  71626. useDefaultLoadingScreen: boolean;
  71627. /**
  71628. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71629. * when all assets have been downloaded.
  71630. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71631. */
  71632. autoHideLoadingUI: boolean;
  71633. /**
  71634. * Creates a new AssetsManager
  71635. * @param scene defines the scene to work on
  71636. */
  71637. constructor(scene: Scene);
  71638. /**
  71639. * Add a MeshAssetTask to the list of active tasks
  71640. * @param taskName defines the name of the new task
  71641. * @param meshesNames defines the name of meshes to load
  71642. * @param rootUrl defines the root url to use to locate files
  71643. * @param sceneFilename defines the filename of the scene file
  71644. * @returns a new MeshAssetTask object
  71645. */
  71646. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71647. /**
  71648. * Add a TextFileAssetTask to the list of active tasks
  71649. * @param taskName defines the name of the new task
  71650. * @param url defines the url of the file to load
  71651. * @returns a new TextFileAssetTask object
  71652. */
  71653. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71654. /**
  71655. * Add a BinaryFileAssetTask to the list of active tasks
  71656. * @param taskName defines the name of the new task
  71657. * @param url defines the url of the file to load
  71658. * @returns a new BinaryFileAssetTask object
  71659. */
  71660. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71661. /**
  71662. * Add a ImageAssetTask to the list of active tasks
  71663. * @param taskName defines the name of the new task
  71664. * @param url defines the url of the file to load
  71665. * @returns a new ImageAssetTask object
  71666. */
  71667. addImageTask(taskName: string, url: string): ImageAssetTask;
  71668. /**
  71669. * Add a TextureAssetTask to the list of active tasks
  71670. * @param taskName defines the name of the new task
  71671. * @param url defines the url of the file to load
  71672. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71673. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71674. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71675. * @returns a new TextureAssetTask object
  71676. */
  71677. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71678. /**
  71679. * Add a CubeTextureAssetTask to the list of active tasks
  71680. * @param taskName defines the name of the new task
  71681. * @param url defines the url of the file to load
  71682. * @param extensions defines the extension to use to load the cube map (can be null)
  71683. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71684. * @param files defines the list of files to load (can be null)
  71685. * @returns a new CubeTextureAssetTask object
  71686. */
  71687. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71688. /**
  71689. *
  71690. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71691. * @param taskName defines the name of the new task
  71692. * @param url defines the url of the file to load
  71693. * @param size defines the size you want for the cubemap (can be null)
  71694. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71695. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71696. * @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)
  71697. * @param reserved Internal use only
  71698. * @returns a new HDRCubeTextureAssetTask object
  71699. */
  71700. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71701. /**
  71702. *
  71703. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71704. * @param taskName defines the name of the new task
  71705. * @param url defines the url of the file to load
  71706. * @param size defines the size you want for the cubemap (can be null)
  71707. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71708. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71709. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71710. * @returns a new EquiRectangularCubeTextureAssetTask object
  71711. */
  71712. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71713. /**
  71714. * Remove a task from the assets manager.
  71715. * @param task the task to remove
  71716. */
  71717. removeTask(task: AbstractAssetTask): void;
  71718. private _decreaseWaitingTasksCount;
  71719. private _runTask;
  71720. /**
  71721. * Reset the AssetsManager and remove all tasks
  71722. * @return the current instance of the AssetsManager
  71723. */
  71724. reset(): AssetsManager;
  71725. /**
  71726. * Start the loading process
  71727. * @return the current instance of the AssetsManager
  71728. */
  71729. load(): AssetsManager;
  71730. /**
  71731. * Start the loading process as an async operation
  71732. * @return a promise returning the list of failed tasks
  71733. */
  71734. loadAsync(): Promise<void>;
  71735. }
  71736. }
  71737. declare module BABYLON {
  71738. /**
  71739. * Wrapper class for promise with external resolve and reject.
  71740. */
  71741. export class Deferred<T> {
  71742. /**
  71743. * The promise associated with this deferred object.
  71744. */
  71745. readonly promise: Promise<T>;
  71746. private _resolve;
  71747. private _reject;
  71748. /**
  71749. * The resolve method of the promise associated with this deferred object.
  71750. */
  71751. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71752. /**
  71753. * The reject method of the promise associated with this deferred object.
  71754. */
  71755. get reject(): (reason?: any) => void;
  71756. /**
  71757. * Constructor for this deferred object.
  71758. */
  71759. constructor();
  71760. }
  71761. }
  71762. declare module BABYLON {
  71763. /**
  71764. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71765. */
  71766. export class MeshExploder {
  71767. private _centerMesh;
  71768. private _meshes;
  71769. private _meshesOrigins;
  71770. private _toCenterVectors;
  71771. private _scaledDirection;
  71772. private _newPosition;
  71773. private _centerPosition;
  71774. /**
  71775. * Explodes meshes from a center mesh.
  71776. * @param meshes The meshes to explode.
  71777. * @param centerMesh The mesh to be center of explosion.
  71778. */
  71779. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71780. private _setCenterMesh;
  71781. /**
  71782. * Get class name
  71783. * @returns "MeshExploder"
  71784. */
  71785. getClassName(): string;
  71786. /**
  71787. * "Exploded meshes"
  71788. * @returns Array of meshes with the centerMesh at index 0.
  71789. */
  71790. getMeshes(): Array<Mesh>;
  71791. /**
  71792. * Explodes meshes giving a specific direction
  71793. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71794. */
  71795. explode(direction?: number): void;
  71796. }
  71797. }
  71798. declare module BABYLON {
  71799. /**
  71800. * Class used to help managing file picking and drag'n'drop
  71801. */
  71802. export class FilesInput {
  71803. /**
  71804. * List of files ready to be loaded
  71805. */
  71806. static get FilesToLoad(): {
  71807. [key: string]: File;
  71808. };
  71809. /**
  71810. * Callback called when a file is processed
  71811. */
  71812. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71813. private _engine;
  71814. private _currentScene;
  71815. private _sceneLoadedCallback;
  71816. private _progressCallback;
  71817. private _additionalRenderLoopLogicCallback;
  71818. private _textureLoadingCallback;
  71819. private _startingProcessingFilesCallback;
  71820. private _onReloadCallback;
  71821. private _errorCallback;
  71822. private _elementToMonitor;
  71823. private _sceneFileToLoad;
  71824. private _filesToLoad;
  71825. /**
  71826. * Creates a new FilesInput
  71827. * @param engine defines the rendering engine
  71828. * @param scene defines the hosting scene
  71829. * @param sceneLoadedCallback callback called when scene is loaded
  71830. * @param progressCallback callback called to track progress
  71831. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71832. * @param textureLoadingCallback callback called when a texture is loading
  71833. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71834. * @param onReloadCallback callback called when a reload is requested
  71835. * @param errorCallback callback call if an error occurs
  71836. */
  71837. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  71838. private _dragEnterHandler;
  71839. private _dragOverHandler;
  71840. private _dropHandler;
  71841. /**
  71842. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71843. * @param elementToMonitor defines the DOM element to track
  71844. */
  71845. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71846. /**
  71847. * Release all associated resources
  71848. */
  71849. dispose(): void;
  71850. private renderFunction;
  71851. private drag;
  71852. private drop;
  71853. private _traverseFolder;
  71854. private _processFiles;
  71855. /**
  71856. * Load files from a drop event
  71857. * @param event defines the drop event to use as source
  71858. */
  71859. loadFiles(event: any): void;
  71860. private _processReload;
  71861. /**
  71862. * Reload the current scene from the loaded files
  71863. */
  71864. reload(): void;
  71865. }
  71866. }
  71867. declare module BABYLON {
  71868. /**
  71869. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71871. */
  71872. export class SceneOptimization {
  71873. /**
  71874. * Defines the priority of this optimization (0 by default which means first in the list)
  71875. */
  71876. priority: number;
  71877. /**
  71878. * Gets a string describing the action executed by the current optimization
  71879. * @returns description string
  71880. */
  71881. getDescription(): string;
  71882. /**
  71883. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71884. * @param scene defines the current scene where to apply this optimization
  71885. * @param optimizer defines the current optimizer
  71886. * @returns true if everything that can be done was applied
  71887. */
  71888. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71889. /**
  71890. * Creates the SceneOptimization object
  71891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71892. * @param desc defines the description associated with the optimization
  71893. */
  71894. constructor(
  71895. /**
  71896. * Defines the priority of this optimization (0 by default which means first in the list)
  71897. */
  71898. priority?: number);
  71899. }
  71900. /**
  71901. * Defines an optimization used to reduce the size of render target textures
  71902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71903. */
  71904. export class TextureOptimization extends SceneOptimization {
  71905. /**
  71906. * Defines the priority of this optimization (0 by default which means first in the list)
  71907. */
  71908. priority: number;
  71909. /**
  71910. * 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
  71911. */
  71912. maximumSize: number;
  71913. /**
  71914. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71915. */
  71916. step: number;
  71917. /**
  71918. * Gets a string describing the action executed by the current optimization
  71919. * @returns description string
  71920. */
  71921. getDescription(): string;
  71922. /**
  71923. * Creates the TextureOptimization object
  71924. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71925. * @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
  71926. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71927. */
  71928. constructor(
  71929. /**
  71930. * Defines the priority of this optimization (0 by default which means first in the list)
  71931. */
  71932. priority?: number,
  71933. /**
  71934. * 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
  71935. */
  71936. maximumSize?: number,
  71937. /**
  71938. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71939. */
  71940. step?: number);
  71941. /**
  71942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71943. * @param scene defines the current scene where to apply this optimization
  71944. * @param optimizer defines the current optimizer
  71945. * @returns true if everything that can be done was applied
  71946. */
  71947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71948. }
  71949. /**
  71950. * Defines an optimization used to increase or decrease the rendering resolution
  71951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71952. */
  71953. export class HardwareScalingOptimization extends SceneOptimization {
  71954. /**
  71955. * Defines the priority of this optimization (0 by default which means first in the list)
  71956. */
  71957. priority: number;
  71958. /**
  71959. * Defines the maximum scale to use (2 by default)
  71960. */
  71961. maximumScale: number;
  71962. /**
  71963. * Defines the step to use between two passes (0.5 by default)
  71964. */
  71965. step: number;
  71966. private _currentScale;
  71967. private _directionOffset;
  71968. /**
  71969. * Gets a string describing the action executed by the current optimization
  71970. * @return description string
  71971. */
  71972. getDescription(): string;
  71973. /**
  71974. * Creates the HardwareScalingOptimization object
  71975. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71976. * @param maximumScale defines the maximum scale to use (2 by default)
  71977. * @param step defines the step to use between two passes (0.5 by default)
  71978. */
  71979. constructor(
  71980. /**
  71981. * Defines the priority of this optimization (0 by default which means first in the list)
  71982. */
  71983. priority?: number,
  71984. /**
  71985. * Defines the maximum scale to use (2 by default)
  71986. */
  71987. maximumScale?: number,
  71988. /**
  71989. * Defines the step to use between two passes (0.5 by default)
  71990. */
  71991. step?: number);
  71992. /**
  71993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71994. * @param scene defines the current scene where to apply this optimization
  71995. * @param optimizer defines the current optimizer
  71996. * @returns true if everything that can be done was applied
  71997. */
  71998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71999. }
  72000. /**
  72001. * Defines an optimization used to remove shadows
  72002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72003. */
  72004. export class ShadowsOptimization extends SceneOptimization {
  72005. /**
  72006. * Gets a string describing the action executed by the current optimization
  72007. * @return description string
  72008. */
  72009. getDescription(): string;
  72010. /**
  72011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72012. * @param scene defines the current scene where to apply this optimization
  72013. * @param optimizer defines the current optimizer
  72014. * @returns true if everything that can be done was applied
  72015. */
  72016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72017. }
  72018. /**
  72019. * Defines an optimization used to turn post-processes off
  72020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72021. */
  72022. export class PostProcessesOptimization extends SceneOptimization {
  72023. /**
  72024. * Gets a string describing the action executed by the current optimization
  72025. * @return description string
  72026. */
  72027. getDescription(): string;
  72028. /**
  72029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72030. * @param scene defines the current scene where to apply this optimization
  72031. * @param optimizer defines the current optimizer
  72032. * @returns true if everything that can be done was applied
  72033. */
  72034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72035. }
  72036. /**
  72037. * Defines an optimization used to turn lens flares off
  72038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72039. */
  72040. export class LensFlaresOptimization extends SceneOptimization {
  72041. /**
  72042. * Gets a string describing the action executed by the current optimization
  72043. * @return description string
  72044. */
  72045. getDescription(): string;
  72046. /**
  72047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72048. * @param scene defines the current scene where to apply this optimization
  72049. * @param optimizer defines the current optimizer
  72050. * @returns true if everything that can be done was applied
  72051. */
  72052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72053. }
  72054. /**
  72055. * Defines an optimization based on user defined callback.
  72056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72057. */
  72058. export class CustomOptimization extends SceneOptimization {
  72059. /**
  72060. * Callback called to apply the custom optimization.
  72061. */
  72062. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72063. /**
  72064. * Callback called to get custom description
  72065. */
  72066. onGetDescription: () => string;
  72067. /**
  72068. * Gets a string describing the action executed by the current optimization
  72069. * @returns description string
  72070. */
  72071. getDescription(): string;
  72072. /**
  72073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72074. * @param scene defines the current scene where to apply this optimization
  72075. * @param optimizer defines the current optimizer
  72076. * @returns true if everything that can be done was applied
  72077. */
  72078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72079. }
  72080. /**
  72081. * Defines an optimization used to turn particles off
  72082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72083. */
  72084. export class ParticlesOptimization extends SceneOptimization {
  72085. /**
  72086. * Gets a string describing the action executed by the current optimization
  72087. * @return description string
  72088. */
  72089. getDescription(): string;
  72090. /**
  72091. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72092. * @param scene defines the current scene where to apply this optimization
  72093. * @param optimizer defines the current optimizer
  72094. * @returns true if everything that can be done was applied
  72095. */
  72096. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72097. }
  72098. /**
  72099. * Defines an optimization used to turn render targets off
  72100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72101. */
  72102. export class RenderTargetsOptimization extends SceneOptimization {
  72103. /**
  72104. * Gets a string describing the action executed by the current optimization
  72105. * @return description string
  72106. */
  72107. getDescription(): string;
  72108. /**
  72109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72110. * @param scene defines the current scene where to apply this optimization
  72111. * @param optimizer defines the current optimizer
  72112. * @returns true if everything that can be done was applied
  72113. */
  72114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72115. }
  72116. /**
  72117. * Defines an optimization used to merge meshes with compatible materials
  72118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72119. */
  72120. export class MergeMeshesOptimization extends SceneOptimization {
  72121. private static _UpdateSelectionTree;
  72122. /**
  72123. * Gets or sets a boolean which defines if optimization octree has to be updated
  72124. */
  72125. static get UpdateSelectionTree(): boolean;
  72126. /**
  72127. * Gets or sets a boolean which defines if optimization octree has to be updated
  72128. */
  72129. static set UpdateSelectionTree(value: boolean);
  72130. /**
  72131. * Gets a string describing the action executed by the current optimization
  72132. * @return description string
  72133. */
  72134. getDescription(): string;
  72135. private _canBeMerged;
  72136. /**
  72137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72138. * @param scene defines the current scene where to apply this optimization
  72139. * @param optimizer defines the current optimizer
  72140. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72141. * @returns true if everything that can be done was applied
  72142. */
  72143. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72144. }
  72145. /**
  72146. * Defines a list of options used by SceneOptimizer
  72147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72148. */
  72149. export class SceneOptimizerOptions {
  72150. /**
  72151. * Defines the target frame rate to reach (60 by default)
  72152. */
  72153. targetFrameRate: number;
  72154. /**
  72155. * Defines the interval between two checkes (2000ms by default)
  72156. */
  72157. trackerDuration: number;
  72158. /**
  72159. * Gets the list of optimizations to apply
  72160. */
  72161. optimizations: SceneOptimization[];
  72162. /**
  72163. * Creates a new list of options used by SceneOptimizer
  72164. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72165. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72166. */
  72167. constructor(
  72168. /**
  72169. * Defines the target frame rate to reach (60 by default)
  72170. */
  72171. targetFrameRate?: number,
  72172. /**
  72173. * Defines the interval between two checkes (2000ms by default)
  72174. */
  72175. trackerDuration?: number);
  72176. /**
  72177. * Add a new optimization
  72178. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72179. * @returns the current SceneOptimizerOptions
  72180. */
  72181. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72182. /**
  72183. * Add a new custom optimization
  72184. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72185. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72186. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72187. * @returns the current SceneOptimizerOptions
  72188. */
  72189. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72190. /**
  72191. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72192. * @param targetFrameRate defines the target frame rate (60 by default)
  72193. * @returns a SceneOptimizerOptions object
  72194. */
  72195. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72196. /**
  72197. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72198. * @param targetFrameRate defines the target frame rate (60 by default)
  72199. * @returns a SceneOptimizerOptions object
  72200. */
  72201. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72202. /**
  72203. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72204. * @param targetFrameRate defines the target frame rate (60 by default)
  72205. * @returns a SceneOptimizerOptions object
  72206. */
  72207. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72208. }
  72209. /**
  72210. * Class used to run optimizations in order to reach a target frame rate
  72211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72212. */
  72213. export class SceneOptimizer implements IDisposable {
  72214. private _isRunning;
  72215. private _options;
  72216. private _scene;
  72217. private _currentPriorityLevel;
  72218. private _targetFrameRate;
  72219. private _trackerDuration;
  72220. private _currentFrameRate;
  72221. private _sceneDisposeObserver;
  72222. private _improvementMode;
  72223. /**
  72224. * Defines an observable called when the optimizer reaches the target frame rate
  72225. */
  72226. onSuccessObservable: Observable<SceneOptimizer>;
  72227. /**
  72228. * Defines an observable called when the optimizer enables an optimization
  72229. */
  72230. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72231. /**
  72232. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72233. */
  72234. onFailureObservable: Observable<SceneOptimizer>;
  72235. /**
  72236. * Gets a boolean indicating if the optimizer is in improvement mode
  72237. */
  72238. get isInImprovementMode(): boolean;
  72239. /**
  72240. * Gets the current priority level (0 at start)
  72241. */
  72242. get currentPriorityLevel(): number;
  72243. /**
  72244. * Gets the current frame rate checked by the SceneOptimizer
  72245. */
  72246. get currentFrameRate(): number;
  72247. /**
  72248. * Gets or sets the current target frame rate (60 by default)
  72249. */
  72250. get targetFrameRate(): number;
  72251. /**
  72252. * Gets or sets the current target frame rate (60 by default)
  72253. */
  72254. set targetFrameRate(value: number);
  72255. /**
  72256. * Gets or sets the current interval between two checks (every 2000ms by default)
  72257. */
  72258. get trackerDuration(): number;
  72259. /**
  72260. * Gets or sets the current interval between two checks (every 2000ms by default)
  72261. */
  72262. set trackerDuration(value: number);
  72263. /**
  72264. * Gets the list of active optimizations
  72265. */
  72266. get optimizations(): SceneOptimization[];
  72267. /**
  72268. * Creates a new SceneOptimizer
  72269. * @param scene defines the scene to work on
  72270. * @param options defines the options to use with the SceneOptimizer
  72271. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72272. * @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)
  72273. */
  72274. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72275. /**
  72276. * Stops the current optimizer
  72277. */
  72278. stop(): void;
  72279. /**
  72280. * Reset the optimizer to initial step (current priority level = 0)
  72281. */
  72282. reset(): void;
  72283. /**
  72284. * Start the optimizer. By default it will try to reach a specific framerate
  72285. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72286. */
  72287. start(): void;
  72288. private _checkCurrentState;
  72289. /**
  72290. * Release all resources
  72291. */
  72292. dispose(): void;
  72293. /**
  72294. * Helper function to create a SceneOptimizer with one single line of code
  72295. * @param scene defines the scene to work on
  72296. * @param options defines the options to use with the SceneOptimizer
  72297. * @param onSuccess defines a callback to call on success
  72298. * @param onFailure defines a callback to call on failure
  72299. * @returns the new SceneOptimizer object
  72300. */
  72301. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72302. }
  72303. }
  72304. declare module BABYLON {
  72305. /**
  72306. * Class used to serialize a scene into a string
  72307. */
  72308. export class SceneSerializer {
  72309. /**
  72310. * Clear cache used by a previous serialization
  72311. */
  72312. static ClearCache(): void;
  72313. /**
  72314. * Serialize a scene into a JSON compatible object
  72315. * @param scene defines the scene to serialize
  72316. * @returns a JSON compatible object
  72317. */
  72318. static Serialize(scene: Scene): any;
  72319. /**
  72320. * Serialize a mesh into a JSON compatible object
  72321. * @param toSerialize defines the mesh to serialize
  72322. * @param withParents defines if parents must be serialized as well
  72323. * @param withChildren defines if children must be serialized as well
  72324. * @returns a JSON compatible object
  72325. */
  72326. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72327. }
  72328. }
  72329. declare module BABYLON {
  72330. /**
  72331. * Class used to host texture specific utilities
  72332. */
  72333. export class TextureTools {
  72334. /**
  72335. * Uses the GPU to create a copy texture rescaled at a given size
  72336. * @param texture Texture to copy from
  72337. * @param width defines the desired width
  72338. * @param height defines the desired height
  72339. * @param useBilinearMode defines if bilinear mode has to be used
  72340. * @return the generated texture
  72341. */
  72342. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72343. }
  72344. }
  72345. declare module BABYLON {
  72346. /**
  72347. * This represents the different options available for the video capture.
  72348. */
  72349. export interface VideoRecorderOptions {
  72350. /** Defines the mime type of the video. */
  72351. mimeType: string;
  72352. /** Defines the FPS the video should be recorded at. */
  72353. fps: number;
  72354. /** Defines the chunk size for the recording data. */
  72355. recordChunckSize: number;
  72356. /** The audio tracks to attach to the recording. */
  72357. audioTracks?: MediaStreamTrack[];
  72358. }
  72359. /**
  72360. * This can help with recording videos from BabylonJS.
  72361. * This is based on the available WebRTC functionalities of the browser.
  72362. *
  72363. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72364. */
  72365. export class VideoRecorder {
  72366. private static readonly _defaultOptions;
  72367. /**
  72368. * Returns whether or not the VideoRecorder is available in your browser.
  72369. * @param engine Defines the Babylon Engine.
  72370. * @returns true if supported otherwise false.
  72371. */
  72372. static IsSupported(engine: Engine): boolean;
  72373. private readonly _options;
  72374. private _canvas;
  72375. private _mediaRecorder;
  72376. private _recordedChunks;
  72377. private _fileName;
  72378. private _resolve;
  72379. private _reject;
  72380. /**
  72381. * True when a recording is already in progress.
  72382. */
  72383. get isRecording(): boolean;
  72384. /**
  72385. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72386. * @param engine Defines the BabylonJS Engine you wish to record.
  72387. * @param options Defines options that can be used to customize the capture.
  72388. */
  72389. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72390. /**
  72391. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72392. */
  72393. stopRecording(): void;
  72394. /**
  72395. * Starts recording the canvas for a max duration specified in parameters.
  72396. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72397. * If null no automatic download will start and you can rely on the promise to get the data back.
  72398. * @param maxDuration Defines the maximum recording time in seconds.
  72399. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72400. * @return A promise callback at the end of the recording with the video data in Blob.
  72401. */
  72402. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72403. /**
  72404. * Releases internal resources used during the recording.
  72405. */
  72406. dispose(): void;
  72407. private _handleDataAvailable;
  72408. private _handleError;
  72409. private _handleStop;
  72410. }
  72411. }
  72412. declare module BABYLON {
  72413. /**
  72414. * Class containing a set of static utilities functions for screenshots
  72415. */
  72416. export class ScreenshotTools {
  72417. /**
  72418. * Captures a screenshot of the current rendering
  72419. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72420. * @param engine defines the rendering engine
  72421. * @param camera defines the source camera
  72422. * @param size This parameter can be set to a single number or to an object with the
  72423. * following (optional) properties: precision, width, height. If a single number is passed,
  72424. * it will be used for both width and height. If an object is passed, the screenshot size
  72425. * will be derived from the parameters. The precision property is a multiplier allowing
  72426. * rendering at a higher or lower resolution
  72427. * @param successCallback defines the callback receives a single parameter which contains the
  72428. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72429. * src parameter of an <img> to display it
  72430. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72431. * Check your browser for supported MIME types
  72432. */
  72433. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72434. /**
  72435. * Captures a screenshot of the current rendering
  72436. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72437. * @param engine defines the rendering engine
  72438. * @param camera defines the source camera
  72439. * @param size This parameter can be set to a single number or to an object with the
  72440. * following (optional) properties: precision, width, height. If a single number is passed,
  72441. * it will be used for both width and height. If an object is passed, the screenshot size
  72442. * will be derived from the parameters. The precision property is a multiplier allowing
  72443. * rendering at a higher or lower resolution
  72444. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72445. * Check your browser for supported MIME types
  72446. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72447. * to the src parameter of an <img> to display it
  72448. */
  72449. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72450. /**
  72451. * Generates an image screenshot from the specified camera.
  72452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72453. * @param engine The engine to use for rendering
  72454. * @param camera The camera to use for rendering
  72455. * @param size This parameter can be set to a single number or to an object with the
  72456. * following (optional) properties: precision, width, height. If a single number is passed,
  72457. * it will be used for both width and height. If an object is passed, the screenshot size
  72458. * will be derived from the parameters. The precision property is a multiplier allowing
  72459. * rendering at a higher or lower resolution
  72460. * @param successCallback The callback receives a single parameter which contains the
  72461. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72462. * src parameter of an <img> to display it
  72463. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72464. * Check your browser for supported MIME types
  72465. * @param samples Texture samples (default: 1)
  72466. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72467. * @param fileName A name for for the downloaded file.
  72468. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72469. */
  72470. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72471. /**
  72472. * Generates an image screenshot from the specified camera.
  72473. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72474. * @param engine The engine to use for rendering
  72475. * @param camera The camera to use for rendering
  72476. * @param size This parameter can be set to a single number or to an object with the
  72477. * following (optional) properties: precision, width, height. If a single number is passed,
  72478. * it will be used for both width and height. If an object is passed, the screenshot size
  72479. * will be derived from the parameters. The precision property is a multiplier allowing
  72480. * rendering at a higher or lower resolution
  72481. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72482. * Check your browser for supported MIME types
  72483. * @param samples Texture samples (default: 1)
  72484. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72485. * @param fileName A name for for the downloaded file.
  72486. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72487. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72488. * to the src parameter of an <img> to display it
  72489. */
  72490. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72491. /**
  72492. * Gets height and width for screenshot size
  72493. * @private
  72494. */
  72495. private static _getScreenshotSize;
  72496. }
  72497. }
  72498. declare module BABYLON {
  72499. /**
  72500. * Interface for a data buffer
  72501. */
  72502. export interface IDataBuffer {
  72503. /**
  72504. * Reads bytes from the data buffer.
  72505. * @param byteOffset The byte offset to read
  72506. * @param byteLength The byte length to read
  72507. * @returns A promise that resolves when the bytes are read
  72508. */
  72509. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72510. /**
  72511. * The byte length of the buffer.
  72512. */
  72513. readonly byteLength: number;
  72514. }
  72515. /**
  72516. * Utility class for reading from a data buffer
  72517. */
  72518. export class DataReader {
  72519. /**
  72520. * The data buffer associated with this data reader.
  72521. */
  72522. readonly buffer: IDataBuffer;
  72523. /**
  72524. * The current byte offset from the beginning of the data buffer.
  72525. */
  72526. byteOffset: number;
  72527. private _dataView;
  72528. private _dataByteOffset;
  72529. /**
  72530. * Constructor
  72531. * @param buffer The buffer to read
  72532. */
  72533. constructor(buffer: IDataBuffer);
  72534. /**
  72535. * Loads the given byte length.
  72536. * @param byteLength The byte length to load
  72537. * @returns A promise that resolves when the load is complete
  72538. */
  72539. loadAsync(byteLength: number): Promise<void>;
  72540. /**
  72541. * Read a unsigned 32-bit integer from the currently loaded data range.
  72542. * @returns The 32-bit integer read
  72543. */
  72544. readUint32(): number;
  72545. /**
  72546. * Read a byte array from the currently loaded data range.
  72547. * @param byteLength The byte length to read
  72548. * @returns The byte array read
  72549. */
  72550. readUint8Array(byteLength: number): Uint8Array;
  72551. /**
  72552. * Read a string from the currently loaded data range.
  72553. * @param byteLength The byte length to read
  72554. * @returns The string read
  72555. */
  72556. readString(byteLength: number): string;
  72557. /**
  72558. * Skips the given byte length the currently loaded data range.
  72559. * @param byteLength The byte length to skip
  72560. */
  72561. skipBytes(byteLength: number): void;
  72562. }
  72563. }
  72564. declare module BABYLON {
  72565. /**
  72566. * Class for storing data to local storage if available or in-memory storage otherwise
  72567. */
  72568. export class DataStorage {
  72569. private static _Storage;
  72570. private static _GetStorage;
  72571. /**
  72572. * Reads a string from the data storage
  72573. * @param key The key to read
  72574. * @param defaultValue The value if the key doesn't exist
  72575. * @returns The string value
  72576. */
  72577. static ReadString(key: string, defaultValue: string): string;
  72578. /**
  72579. * Writes a string to the data storage
  72580. * @param key The key to write
  72581. * @param value The value to write
  72582. */
  72583. static WriteString(key: string, value: string): void;
  72584. /**
  72585. * Reads a boolean from the data storage
  72586. * @param key The key to read
  72587. * @param defaultValue The value if the key doesn't exist
  72588. * @returns The boolean value
  72589. */
  72590. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72591. /**
  72592. * Writes a boolean to the data storage
  72593. * @param key The key to write
  72594. * @param value The value to write
  72595. */
  72596. static WriteBoolean(key: string, value: boolean): void;
  72597. /**
  72598. * Reads a number from the data storage
  72599. * @param key The key to read
  72600. * @param defaultValue The value if the key doesn't exist
  72601. * @returns The number value
  72602. */
  72603. static ReadNumber(key: string, defaultValue: number): number;
  72604. /**
  72605. * Writes a number to the data storage
  72606. * @param key The key to write
  72607. * @param value The value to write
  72608. */
  72609. static WriteNumber(key: string, value: number): void;
  72610. }
  72611. }
  72612. declare module BABYLON {
  72613. /**
  72614. * An interface for all Hit test features
  72615. */
  72616. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72617. /**
  72618. * Triggered when new babylon (transformed) hit test results are available
  72619. */
  72620. onHitTestResultObservable: Observable<T[]>;
  72621. }
  72622. /**
  72623. * Options used for hit testing
  72624. */
  72625. export interface IWebXRLegacyHitTestOptions {
  72626. /**
  72627. * Only test when user interacted with the scene. Default - hit test every frame
  72628. */
  72629. testOnPointerDownOnly?: boolean;
  72630. /**
  72631. * The node to use to transform the local results to world coordinates
  72632. */
  72633. worldParentNode?: TransformNode;
  72634. }
  72635. /**
  72636. * Interface defining the babylon result of raycasting/hit-test
  72637. */
  72638. export interface IWebXRLegacyHitResult {
  72639. /**
  72640. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72641. */
  72642. transformationMatrix: Matrix;
  72643. /**
  72644. * The native hit test result
  72645. */
  72646. xrHitResult: XRHitResult | XRHitTestResult;
  72647. }
  72648. /**
  72649. * The currently-working hit-test module.
  72650. * Hit test (or Ray-casting) is used to interact with the real world.
  72651. * For further information read here - https://github.com/immersive-web/hit-test
  72652. */
  72653. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72654. /**
  72655. * options to use when constructing this feature
  72656. */
  72657. readonly options: IWebXRLegacyHitTestOptions;
  72658. private _direction;
  72659. private _mat;
  72660. private _onSelectEnabled;
  72661. private _origin;
  72662. /**
  72663. * The module's name
  72664. */
  72665. static readonly Name: string;
  72666. /**
  72667. * The (Babylon) version of this module.
  72668. * This is an integer representing the implementation version.
  72669. * This number does not correspond to the WebXR specs version
  72670. */
  72671. static readonly Version: number;
  72672. /**
  72673. * Populated with the last native XR Hit Results
  72674. */
  72675. lastNativeXRHitResults: XRHitResult[];
  72676. /**
  72677. * Triggered when new babylon (transformed) hit test results are available
  72678. */
  72679. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72680. /**
  72681. * Creates a new instance of the (legacy version) hit test feature
  72682. * @param _xrSessionManager an instance of WebXRSessionManager
  72683. * @param options options to use when constructing this feature
  72684. */
  72685. constructor(_xrSessionManager: WebXRSessionManager,
  72686. /**
  72687. * options to use when constructing this feature
  72688. */
  72689. options?: IWebXRLegacyHitTestOptions);
  72690. /**
  72691. * execute a hit test with an XR Ray
  72692. *
  72693. * @param xrSession a native xrSession that will execute this hit test
  72694. * @param xrRay the ray (position and direction) to use for ray-casting
  72695. * @param referenceSpace native XR reference space to use for the hit-test
  72696. * @param filter filter function that will filter the results
  72697. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72698. */
  72699. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72700. /**
  72701. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72702. * @param event the (select) event to use to select with
  72703. * @param referenceSpace the reference space to use for this hit test
  72704. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72705. */
  72706. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72707. /**
  72708. * attach this feature
  72709. * Will usually be called by the features manager
  72710. *
  72711. * @returns true if successful.
  72712. */
  72713. attach(): boolean;
  72714. /**
  72715. * detach this feature.
  72716. * Will usually be called by the features manager
  72717. *
  72718. * @returns true if successful.
  72719. */
  72720. detach(): boolean;
  72721. /**
  72722. * Dispose this feature and all of the resources attached
  72723. */
  72724. dispose(): void;
  72725. protected _onXRFrame(frame: XRFrame): void;
  72726. private _onHitTestResults;
  72727. private _onSelect;
  72728. }
  72729. }
  72730. declare module BABYLON {
  72731. /**
  72732. * Options used for hit testing (version 2)
  72733. */
  72734. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72735. /**
  72736. * Do not create a permanent hit test. Will usually be used when only
  72737. * transient inputs are needed.
  72738. */
  72739. disablePermanentHitTest?: boolean;
  72740. /**
  72741. * Enable transient (for example touch-based) hit test inspections
  72742. */
  72743. enableTransientHitTest?: boolean;
  72744. /**
  72745. * Offset ray for the permanent hit test
  72746. */
  72747. offsetRay?: Vector3;
  72748. /**
  72749. * Offset ray for the transient hit test
  72750. */
  72751. transientOffsetRay?: Vector3;
  72752. /**
  72753. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72754. */
  72755. useReferenceSpace?: boolean;
  72756. }
  72757. /**
  72758. * Interface defining the babylon result of hit-test
  72759. */
  72760. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72761. /**
  72762. * The input source that generated this hit test (if transient)
  72763. */
  72764. inputSource?: XRInputSource;
  72765. /**
  72766. * Is this a transient hit test
  72767. */
  72768. isTransient?: boolean;
  72769. /**
  72770. * Position of the hit test result
  72771. */
  72772. position: Vector3;
  72773. /**
  72774. * Rotation of the hit test result
  72775. */
  72776. rotationQuaternion: Quaternion;
  72777. /**
  72778. * The native hit test result
  72779. */
  72780. xrHitResult: XRHitTestResult;
  72781. }
  72782. /**
  72783. * The currently-working hit-test module.
  72784. * Hit test (or Ray-casting) is used to interact with the real world.
  72785. * For further information read here - https://github.com/immersive-web/hit-test
  72786. *
  72787. * Tested on chrome (mobile) 80.
  72788. */
  72789. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72790. /**
  72791. * options to use when constructing this feature
  72792. */
  72793. readonly options: IWebXRHitTestOptions;
  72794. private _tmpMat;
  72795. private _tmpPos;
  72796. private _tmpQuat;
  72797. private _transientXrHitTestSource;
  72798. private _xrHitTestSource;
  72799. private initHitTestSource;
  72800. /**
  72801. * The module's name
  72802. */
  72803. static readonly Name: string;
  72804. /**
  72805. * The (Babylon) version of this module.
  72806. * This is an integer representing the implementation version.
  72807. * This number does not correspond to the WebXR specs version
  72808. */
  72809. static readonly Version: number;
  72810. /**
  72811. * When set to true, each hit test will have its own position/rotation objects
  72812. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72813. * the developers will clone them or copy them as they see fit.
  72814. */
  72815. autoCloneTransformation: boolean;
  72816. /**
  72817. * Triggered when new babylon (transformed) hit test results are available
  72818. */
  72819. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72820. /**
  72821. * Use this to temporarily pause hit test checks.
  72822. */
  72823. paused: boolean;
  72824. /**
  72825. * Creates a new instance of the hit test feature
  72826. * @param _xrSessionManager an instance of WebXRSessionManager
  72827. * @param options options to use when constructing this feature
  72828. */
  72829. constructor(_xrSessionManager: WebXRSessionManager,
  72830. /**
  72831. * options to use when constructing this feature
  72832. */
  72833. options?: IWebXRHitTestOptions);
  72834. /**
  72835. * attach this feature
  72836. * Will usually be called by the features manager
  72837. *
  72838. * @returns true if successful.
  72839. */
  72840. attach(): boolean;
  72841. /**
  72842. * detach this feature.
  72843. * Will usually be called by the features manager
  72844. *
  72845. * @returns true if successful.
  72846. */
  72847. detach(): boolean;
  72848. /**
  72849. * Dispose this feature and all of the resources attached
  72850. */
  72851. dispose(): void;
  72852. protected _onXRFrame(frame: XRFrame): void;
  72853. private _processWebXRHitTestResult;
  72854. }
  72855. }
  72856. declare module BABYLON {
  72857. /**
  72858. * Configuration options of the anchor system
  72859. */
  72860. export interface IWebXRAnchorSystemOptions {
  72861. /**
  72862. * a node that will be used to convert local to world coordinates
  72863. */
  72864. worldParentNode?: TransformNode;
  72865. /**
  72866. * If set to true a reference of the created anchors will be kept until the next session starts
  72867. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72868. */
  72869. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72870. }
  72871. /**
  72872. * A babylon container for an XR Anchor
  72873. */
  72874. export interface IWebXRAnchor {
  72875. /**
  72876. * A babylon-assigned ID for this anchor
  72877. */
  72878. id: number;
  72879. /**
  72880. * Transformation matrix to apply to an object attached to this anchor
  72881. */
  72882. transformationMatrix: Matrix;
  72883. /**
  72884. * The native anchor object
  72885. */
  72886. xrAnchor: XRAnchor;
  72887. /**
  72888. * if defined, this object will be constantly updated by the anchor's position and rotation
  72889. */
  72890. attachedNode?: TransformNode;
  72891. }
  72892. /**
  72893. * An implementation of the anchor system for WebXR.
  72894. * For further information see https://github.com/immersive-web/anchors/
  72895. */
  72896. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72897. private _options;
  72898. private _lastFrameDetected;
  72899. private _trackedAnchors;
  72900. private _referenceSpaceForFrameAnchors;
  72901. private _futureAnchors;
  72902. /**
  72903. * The module's name
  72904. */
  72905. static readonly Name: string;
  72906. /**
  72907. * The (Babylon) version of this module.
  72908. * This is an integer representing the implementation version.
  72909. * This number does not correspond to the WebXR specs version
  72910. */
  72911. static readonly Version: number;
  72912. /**
  72913. * Observers registered here will be executed when a new anchor was added to the session
  72914. */
  72915. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72916. /**
  72917. * Observers registered here will be executed when an anchor was removed from the session
  72918. */
  72919. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72920. /**
  72921. * Observers registered here will be executed when an existing anchor updates
  72922. * This can execute N times every frame
  72923. */
  72924. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72925. /**
  72926. * Set the reference space to use for anchor creation, when not using a hit test.
  72927. * Will default to the session's reference space if not defined
  72928. */
  72929. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72930. /**
  72931. * constructs a new anchor system
  72932. * @param _xrSessionManager an instance of WebXRSessionManager
  72933. * @param _options configuration object for this feature
  72934. */
  72935. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72936. private _tmpVector;
  72937. private _tmpQuaternion;
  72938. private _populateTmpTransformation;
  72939. /**
  72940. * Create a new anchor point using a hit test result at a specific point in the scene
  72941. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72942. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72943. *
  72944. * @param hitTestResult The hit test result to use for this anchor creation
  72945. * @param position an optional position offset for this anchor
  72946. * @param rotationQuaternion an optional rotation offset for this anchor
  72947. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72948. */
  72949. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72950. /**
  72951. * Add a new anchor at a specific position and rotation
  72952. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72953. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72954. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72955. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72956. *
  72957. * @param position the position in which to add an anchor
  72958. * @param rotationQuaternion an optional rotation for the anchor transformation
  72959. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72960. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72961. */
  72962. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72963. /**
  72964. * detach this feature.
  72965. * Will usually be called by the features manager
  72966. *
  72967. * @returns true if successful.
  72968. */
  72969. detach(): boolean;
  72970. /**
  72971. * Dispose this feature and all of the resources attached
  72972. */
  72973. dispose(): void;
  72974. protected _onXRFrame(frame: XRFrame): void;
  72975. /**
  72976. * avoiding using Array.find for global support.
  72977. * @param xrAnchor the plane to find in the array
  72978. */
  72979. private _findIndexInAnchorArray;
  72980. private _updateAnchorWithXRFrame;
  72981. private _createAnchorAtTransformation;
  72982. }
  72983. }
  72984. declare module BABYLON {
  72985. /**
  72986. * Options used in the plane detector module
  72987. */
  72988. export interface IWebXRPlaneDetectorOptions {
  72989. /**
  72990. * The node to use to transform the local results to world coordinates
  72991. */
  72992. worldParentNode?: TransformNode;
  72993. /**
  72994. * If set to true a reference of the created planes will be kept until the next session starts
  72995. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72996. */
  72997. doNotRemovePlanesOnSessionEnded?: boolean;
  72998. }
  72999. /**
  73000. * A babylon interface for a WebXR plane.
  73001. * A Plane is actually a polygon, built from N points in space
  73002. *
  73003. * Supported in chrome 79, not supported in canary 81 ATM
  73004. */
  73005. export interface IWebXRPlane {
  73006. /**
  73007. * a babylon-assigned ID for this polygon
  73008. */
  73009. id: number;
  73010. /**
  73011. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73012. */
  73013. polygonDefinition: Array<Vector3>;
  73014. /**
  73015. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73016. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73017. */
  73018. transformationMatrix: Matrix;
  73019. /**
  73020. * the native xr-plane object
  73021. */
  73022. xrPlane: XRPlane;
  73023. }
  73024. /**
  73025. * The plane detector is used to detect planes in the real world when in AR
  73026. * For more information see https://github.com/immersive-web/real-world-geometry/
  73027. */
  73028. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73029. private _options;
  73030. private _detectedPlanes;
  73031. private _enabled;
  73032. private _lastFrameDetected;
  73033. /**
  73034. * The module's name
  73035. */
  73036. static readonly Name: string;
  73037. /**
  73038. * The (Babylon) version of this module.
  73039. * This is an integer representing the implementation version.
  73040. * This number does not correspond to the WebXR specs version
  73041. */
  73042. static readonly Version: number;
  73043. /**
  73044. * Observers registered here will be executed when a new plane was added to the session
  73045. */
  73046. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73047. /**
  73048. * Observers registered here will be executed when a plane is no longer detected in the session
  73049. */
  73050. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73051. /**
  73052. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73053. * This can execute N times every frame
  73054. */
  73055. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73056. /**
  73057. * construct a new Plane Detector
  73058. * @param _xrSessionManager an instance of xr Session manager
  73059. * @param _options configuration to use when constructing this feature
  73060. */
  73061. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73062. /**
  73063. * detach this feature.
  73064. * Will usually be called by the features manager
  73065. *
  73066. * @returns true if successful.
  73067. */
  73068. detach(): boolean;
  73069. /**
  73070. * Dispose this feature and all of the resources attached
  73071. */
  73072. dispose(): void;
  73073. protected _onXRFrame(frame: XRFrame): void;
  73074. private _init;
  73075. private _updatePlaneWithXRPlane;
  73076. /**
  73077. * avoiding using Array.find for global support.
  73078. * @param xrPlane the plane to find in the array
  73079. */
  73080. private findIndexInPlaneArray;
  73081. }
  73082. }
  73083. declare module BABYLON {
  73084. /**
  73085. * Options interface for the background remover plugin
  73086. */
  73087. export interface IWebXRBackgroundRemoverOptions {
  73088. /**
  73089. * Further background meshes to disable when entering AR
  73090. */
  73091. backgroundMeshes?: AbstractMesh[];
  73092. /**
  73093. * flags to configure the removal of the environment helper.
  73094. * If not set, the entire background will be removed. If set, flags should be set as well.
  73095. */
  73096. environmentHelperRemovalFlags?: {
  73097. /**
  73098. * Should the skybox be removed (default false)
  73099. */
  73100. skyBox?: boolean;
  73101. /**
  73102. * Should the ground be removed (default false)
  73103. */
  73104. ground?: boolean;
  73105. };
  73106. /**
  73107. * don't disable the environment helper
  73108. */
  73109. ignoreEnvironmentHelper?: boolean;
  73110. }
  73111. /**
  73112. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73113. */
  73114. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73115. /**
  73116. * read-only options to be used in this module
  73117. */
  73118. readonly options: IWebXRBackgroundRemoverOptions;
  73119. /**
  73120. * The module's name
  73121. */
  73122. static readonly Name: string;
  73123. /**
  73124. * The (Babylon) version of this module.
  73125. * This is an integer representing the implementation version.
  73126. * This number does not correspond to the WebXR specs version
  73127. */
  73128. static readonly Version: number;
  73129. /**
  73130. * registered observers will be triggered when the background state changes
  73131. */
  73132. onBackgroundStateChangedObservable: Observable<boolean>;
  73133. /**
  73134. * constructs a new background remover module
  73135. * @param _xrSessionManager the session manager for this module
  73136. * @param options read-only options to be used in this module
  73137. */
  73138. constructor(_xrSessionManager: WebXRSessionManager,
  73139. /**
  73140. * read-only options to be used in this module
  73141. */
  73142. options?: IWebXRBackgroundRemoverOptions);
  73143. /**
  73144. * attach this feature
  73145. * Will usually be called by the features manager
  73146. *
  73147. * @returns true if successful.
  73148. */
  73149. attach(): boolean;
  73150. /**
  73151. * detach this feature.
  73152. * Will usually be called by the features manager
  73153. *
  73154. * @returns true if successful.
  73155. */
  73156. detach(): boolean;
  73157. /**
  73158. * Dispose this feature and all of the resources attached
  73159. */
  73160. dispose(): void;
  73161. protected _onXRFrame(_xrFrame: XRFrame): void;
  73162. private _setBackgroundState;
  73163. }
  73164. }
  73165. declare module BABYLON {
  73166. /**
  73167. * Options for the controller physics feature
  73168. */
  73169. export class IWebXRControllerPhysicsOptions {
  73170. /**
  73171. * Should the headset get its own impostor
  73172. */
  73173. enableHeadsetImpostor?: boolean;
  73174. /**
  73175. * Optional parameters for the headset impostor
  73176. */
  73177. headsetImpostorParams?: {
  73178. /**
  73179. * The type of impostor to create. Default is sphere
  73180. */
  73181. impostorType: number;
  73182. /**
  73183. * the size of the impostor. Defaults to 10cm
  73184. */
  73185. impostorSize?: number | {
  73186. width: number;
  73187. height: number;
  73188. depth: number;
  73189. };
  73190. /**
  73191. * Friction definitions
  73192. */
  73193. friction?: number;
  73194. /**
  73195. * Restitution
  73196. */
  73197. restitution?: number;
  73198. };
  73199. /**
  73200. * The physics properties of the future impostors
  73201. */
  73202. physicsProperties?: {
  73203. /**
  73204. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73205. * Note that this requires a physics engine that supports mesh impostors!
  73206. */
  73207. useControllerMesh?: boolean;
  73208. /**
  73209. * The type of impostor to create. Default is sphere
  73210. */
  73211. impostorType?: number;
  73212. /**
  73213. * the size of the impostor. Defaults to 10cm
  73214. */
  73215. impostorSize?: number | {
  73216. width: number;
  73217. height: number;
  73218. depth: number;
  73219. };
  73220. /**
  73221. * Friction definitions
  73222. */
  73223. friction?: number;
  73224. /**
  73225. * Restitution
  73226. */
  73227. restitution?: number;
  73228. };
  73229. /**
  73230. * the xr input to use with this pointer selection
  73231. */
  73232. xrInput: WebXRInput;
  73233. }
  73234. /**
  73235. * Add physics impostor to your webxr controllers,
  73236. * including naive calculation of their linear and angular velocity
  73237. */
  73238. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73239. private readonly _options;
  73240. private _attachController;
  73241. private _controllers;
  73242. private _debugMode;
  73243. private _delta;
  73244. private _headsetImpostor?;
  73245. private _headsetMesh?;
  73246. private _lastTimestamp;
  73247. private _tmpQuaternion;
  73248. private _tmpVector;
  73249. /**
  73250. * The module's name
  73251. */
  73252. static readonly Name: string;
  73253. /**
  73254. * The (Babylon) version of this module.
  73255. * This is an integer representing the implementation version.
  73256. * This number does not correspond to the webxr specs version
  73257. */
  73258. static readonly Version: number;
  73259. /**
  73260. * Construct a new Controller Physics Feature
  73261. * @param _xrSessionManager the corresponding xr session manager
  73262. * @param _options options to create this feature with
  73263. */
  73264. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73265. /**
  73266. * @hidden
  73267. * enable debugging - will show console outputs and the impostor mesh
  73268. */
  73269. _enablePhysicsDebug(): void;
  73270. /**
  73271. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73272. * @param xrController the controller to add
  73273. */
  73274. addController(xrController: WebXRInputSource): void;
  73275. /**
  73276. * attach this feature
  73277. * Will usually be called by the features manager
  73278. *
  73279. * @returns true if successful.
  73280. */
  73281. attach(): boolean;
  73282. /**
  73283. * detach this feature.
  73284. * Will usually be called by the features manager
  73285. *
  73286. * @returns true if successful.
  73287. */
  73288. detach(): boolean;
  73289. /**
  73290. * Get the headset impostor, if enabled
  73291. * @returns the impostor
  73292. */
  73293. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73294. /**
  73295. * Get the physics impostor of a specific controller.
  73296. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73297. * @param controller the controller or the controller id of which to get the impostor
  73298. * @returns the impostor or null
  73299. */
  73300. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73301. /**
  73302. * Update the physics properties provided in the constructor
  73303. * @param newProperties the new properties object
  73304. */
  73305. setPhysicsProperties(newProperties: {
  73306. impostorType?: number;
  73307. impostorSize?: number | {
  73308. width: number;
  73309. height: number;
  73310. depth: number;
  73311. };
  73312. friction?: number;
  73313. restitution?: number;
  73314. }): void;
  73315. protected _onXRFrame(_xrFrame: any): void;
  73316. private _detachController;
  73317. }
  73318. }
  73319. declare module BABYLON {
  73320. /**
  73321. * The motion controller class for all microsoft mixed reality controllers
  73322. */
  73323. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73324. protected readonly _mapping: {
  73325. defaultButton: {
  73326. valueNodeName: string;
  73327. unpressedNodeName: string;
  73328. pressedNodeName: string;
  73329. };
  73330. defaultAxis: {
  73331. valueNodeName: string;
  73332. minNodeName: string;
  73333. maxNodeName: string;
  73334. };
  73335. buttons: {
  73336. "xr-standard-trigger": {
  73337. rootNodeName: string;
  73338. componentProperty: string;
  73339. states: string[];
  73340. };
  73341. "xr-standard-squeeze": {
  73342. rootNodeName: string;
  73343. componentProperty: string;
  73344. states: string[];
  73345. };
  73346. "xr-standard-touchpad": {
  73347. rootNodeName: string;
  73348. labelAnchorNodeName: string;
  73349. touchPointNodeName: string;
  73350. };
  73351. "xr-standard-thumbstick": {
  73352. rootNodeName: string;
  73353. componentProperty: string;
  73354. states: string[];
  73355. };
  73356. };
  73357. axes: {
  73358. "xr-standard-touchpad": {
  73359. "x-axis": {
  73360. rootNodeName: string;
  73361. };
  73362. "y-axis": {
  73363. rootNodeName: string;
  73364. };
  73365. };
  73366. "xr-standard-thumbstick": {
  73367. "x-axis": {
  73368. rootNodeName: string;
  73369. };
  73370. "y-axis": {
  73371. rootNodeName: string;
  73372. };
  73373. };
  73374. };
  73375. };
  73376. /**
  73377. * The base url used to load the left and right controller models
  73378. */
  73379. static MODEL_BASE_URL: string;
  73380. /**
  73381. * The name of the left controller model file
  73382. */
  73383. static MODEL_LEFT_FILENAME: string;
  73384. /**
  73385. * The name of the right controller model file
  73386. */
  73387. static MODEL_RIGHT_FILENAME: string;
  73388. profileId: string;
  73389. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73390. protected _getFilenameAndPath(): {
  73391. filename: string;
  73392. path: string;
  73393. };
  73394. protected _getModelLoadingConstraints(): boolean;
  73395. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73396. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73397. protected _updateModel(): void;
  73398. }
  73399. }
  73400. declare module BABYLON {
  73401. /**
  73402. * The motion controller class for oculus touch (quest, rift).
  73403. * This class supports legacy mapping as well the standard xr mapping
  73404. */
  73405. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73406. private _forceLegacyControllers;
  73407. private _modelRootNode;
  73408. /**
  73409. * The base url used to load the left and right controller models
  73410. */
  73411. static MODEL_BASE_URL: string;
  73412. /**
  73413. * The name of the left controller model file
  73414. */
  73415. static MODEL_LEFT_FILENAME: string;
  73416. /**
  73417. * The name of the right controller model file
  73418. */
  73419. static MODEL_RIGHT_FILENAME: string;
  73420. /**
  73421. * Base Url for the Quest controller model.
  73422. */
  73423. static QUEST_MODEL_BASE_URL: string;
  73424. profileId: string;
  73425. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73426. protected _getFilenameAndPath(): {
  73427. filename: string;
  73428. path: string;
  73429. };
  73430. protected _getModelLoadingConstraints(): boolean;
  73431. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73432. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73433. protected _updateModel(): void;
  73434. /**
  73435. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73436. * between the touch and touch 2.
  73437. */
  73438. private _isQuest;
  73439. }
  73440. }
  73441. declare module BABYLON {
  73442. /**
  73443. * The motion controller class for the standard HTC-Vive controllers
  73444. */
  73445. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73446. private _modelRootNode;
  73447. /**
  73448. * The base url used to load the left and right controller models
  73449. */
  73450. static MODEL_BASE_URL: string;
  73451. /**
  73452. * File name for the controller model.
  73453. */
  73454. static MODEL_FILENAME: string;
  73455. profileId: string;
  73456. /**
  73457. * Create a new Vive motion controller object
  73458. * @param scene the scene to use to create this controller
  73459. * @param gamepadObject the corresponding gamepad object
  73460. * @param handedness the handedness of the controller
  73461. */
  73462. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73463. protected _getFilenameAndPath(): {
  73464. filename: string;
  73465. path: string;
  73466. };
  73467. protected _getModelLoadingConstraints(): boolean;
  73468. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73469. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73470. protected _updateModel(): void;
  73471. }
  73472. }
  73473. declare module BABYLON {
  73474. /**
  73475. * A cursor which tracks a point on a path
  73476. */
  73477. export class PathCursor {
  73478. private path;
  73479. /**
  73480. * Stores path cursor callbacks for when an onchange event is triggered
  73481. */
  73482. private _onchange;
  73483. /**
  73484. * The value of the path cursor
  73485. */
  73486. value: number;
  73487. /**
  73488. * The animation array of the path cursor
  73489. */
  73490. animations: Animation[];
  73491. /**
  73492. * Initializes the path cursor
  73493. * @param path The path to track
  73494. */
  73495. constructor(path: Path2);
  73496. /**
  73497. * Gets the cursor point on the path
  73498. * @returns A point on the path cursor at the cursor location
  73499. */
  73500. getPoint(): Vector3;
  73501. /**
  73502. * Moves the cursor ahead by the step amount
  73503. * @param step The amount to move the cursor forward
  73504. * @returns This path cursor
  73505. */
  73506. moveAhead(step?: number): PathCursor;
  73507. /**
  73508. * Moves the cursor behind by the step amount
  73509. * @param step The amount to move the cursor back
  73510. * @returns This path cursor
  73511. */
  73512. moveBack(step?: number): PathCursor;
  73513. /**
  73514. * Moves the cursor by the step amount
  73515. * If the step amount is greater than one, an exception is thrown
  73516. * @param step The amount to move the cursor
  73517. * @returns This path cursor
  73518. */
  73519. move(step: number): PathCursor;
  73520. /**
  73521. * Ensures that the value is limited between zero and one
  73522. * @returns This path cursor
  73523. */
  73524. private ensureLimits;
  73525. /**
  73526. * Runs onchange callbacks on change (used by the animation engine)
  73527. * @returns This path cursor
  73528. */
  73529. private raiseOnChange;
  73530. /**
  73531. * Executes a function on change
  73532. * @param f A path cursor onchange callback
  73533. * @returns This path cursor
  73534. */
  73535. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73536. }
  73537. }
  73538. declare module BABYLON {
  73539. /** @hidden */
  73540. export var blurPixelShader: {
  73541. name: string;
  73542. shader: string;
  73543. };
  73544. }
  73545. declare module BABYLON {
  73546. /** @hidden */
  73547. export var pointCloudVertexDeclaration: {
  73548. name: string;
  73549. shader: string;
  73550. };
  73551. }
  73552. // Mixins
  73553. interface Window {
  73554. mozIndexedDB: IDBFactory;
  73555. webkitIndexedDB: IDBFactory;
  73556. msIndexedDB: IDBFactory;
  73557. webkitURL: typeof URL;
  73558. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73559. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73560. WebGLRenderingContext: WebGLRenderingContext;
  73561. MSGesture: MSGesture;
  73562. CANNON: any;
  73563. AudioContext: AudioContext;
  73564. webkitAudioContext: AudioContext;
  73565. PointerEvent: any;
  73566. Math: Math;
  73567. Uint8Array: Uint8ArrayConstructor;
  73568. Float32Array: Float32ArrayConstructor;
  73569. mozURL: typeof URL;
  73570. msURL: typeof URL;
  73571. VRFrameData: any; // WebVR, from specs 1.1
  73572. DracoDecoderModule: any;
  73573. setImmediate(handler: (...args: any[]) => void): number;
  73574. }
  73575. interface HTMLCanvasElement {
  73576. requestPointerLock(): void;
  73577. msRequestPointerLock?(): void;
  73578. mozRequestPointerLock?(): void;
  73579. webkitRequestPointerLock?(): void;
  73580. /** Track wether a record is in progress */
  73581. isRecording: boolean;
  73582. /** Capture Stream method defined by some browsers */
  73583. captureStream(fps?: number): MediaStream;
  73584. }
  73585. interface CanvasRenderingContext2D {
  73586. msImageSmoothingEnabled: boolean;
  73587. }
  73588. interface MouseEvent {
  73589. mozMovementX: number;
  73590. mozMovementY: number;
  73591. webkitMovementX: number;
  73592. webkitMovementY: number;
  73593. msMovementX: number;
  73594. msMovementY: number;
  73595. }
  73596. interface Navigator {
  73597. mozGetVRDevices: (any: any) => any;
  73598. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73599. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73600. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73601. webkitGetGamepads(): Gamepad[];
  73602. msGetGamepads(): Gamepad[];
  73603. webkitGamepads(): Gamepad[];
  73604. }
  73605. interface HTMLVideoElement {
  73606. mozSrcObject: any;
  73607. }
  73608. interface Math {
  73609. fround(x: number): number;
  73610. imul(a: number, b: number): number;
  73611. }
  73612. interface WebGLRenderingContext {
  73613. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73614. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73615. vertexAttribDivisor(index: number, divisor: number): void;
  73616. createVertexArray(): any;
  73617. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73618. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73619. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73620. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73621. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73622. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73623. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73624. // Queries
  73625. createQuery(): WebGLQuery;
  73626. deleteQuery(query: WebGLQuery): void;
  73627. beginQuery(target: number, query: WebGLQuery): void;
  73628. endQuery(target: number): void;
  73629. getQueryParameter(query: WebGLQuery, pname: number): any;
  73630. getQuery(target: number, pname: number): any;
  73631. MAX_SAMPLES: number;
  73632. RGBA8: number;
  73633. READ_FRAMEBUFFER: number;
  73634. DRAW_FRAMEBUFFER: number;
  73635. UNIFORM_BUFFER: number;
  73636. HALF_FLOAT_OES: number;
  73637. RGBA16F: number;
  73638. RGBA32F: number;
  73639. R32F: number;
  73640. RG32F: number;
  73641. RGB32F: number;
  73642. R16F: number;
  73643. RG16F: number;
  73644. RGB16F: number;
  73645. RED: number;
  73646. RG: number;
  73647. R8: number;
  73648. RG8: number;
  73649. UNSIGNED_INT_24_8: number;
  73650. DEPTH24_STENCIL8: number;
  73651. MIN: number;
  73652. MAX: number;
  73653. /* Multiple Render Targets */
  73654. drawBuffers(buffers: number[]): void;
  73655. readBuffer(src: number): void;
  73656. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73657. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73658. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73659. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73660. // Occlusion Query
  73661. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73662. ANY_SAMPLES_PASSED: number;
  73663. QUERY_RESULT_AVAILABLE: number;
  73664. QUERY_RESULT: number;
  73665. }
  73666. interface WebGLProgram {
  73667. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73668. }
  73669. interface EXT_disjoint_timer_query {
  73670. QUERY_COUNTER_BITS_EXT: number;
  73671. TIME_ELAPSED_EXT: number;
  73672. TIMESTAMP_EXT: number;
  73673. GPU_DISJOINT_EXT: number;
  73674. QUERY_RESULT_EXT: number;
  73675. QUERY_RESULT_AVAILABLE_EXT: number;
  73676. queryCounterEXT(query: WebGLQuery, target: number): void;
  73677. createQueryEXT(): WebGLQuery;
  73678. beginQueryEXT(target: number, query: WebGLQuery): void;
  73679. endQueryEXT(target: number): void;
  73680. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73681. deleteQueryEXT(query: WebGLQuery): void;
  73682. }
  73683. interface WebGLUniformLocation {
  73684. _currentState: any;
  73685. }
  73686. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73687. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73688. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73689. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73690. interface WebGLRenderingContext {
  73691. readonly RASTERIZER_DISCARD: number;
  73692. readonly DEPTH_COMPONENT24: number;
  73693. readonly TEXTURE_3D: number;
  73694. readonly TEXTURE_2D_ARRAY: number;
  73695. readonly TEXTURE_COMPARE_FUNC: number;
  73696. readonly TEXTURE_COMPARE_MODE: number;
  73697. readonly COMPARE_REF_TO_TEXTURE: number;
  73698. readonly TEXTURE_WRAP_R: number;
  73699. readonly HALF_FLOAT: number;
  73700. readonly RGB8: number;
  73701. readonly RED_INTEGER: number;
  73702. readonly RG_INTEGER: number;
  73703. readonly RGB_INTEGER: number;
  73704. readonly RGBA_INTEGER: number;
  73705. readonly R8_SNORM: number;
  73706. readonly RG8_SNORM: number;
  73707. readonly RGB8_SNORM: number;
  73708. readonly RGBA8_SNORM: number;
  73709. readonly R8I: number;
  73710. readonly RG8I: number;
  73711. readonly RGB8I: number;
  73712. readonly RGBA8I: number;
  73713. readonly R8UI: number;
  73714. readonly RG8UI: number;
  73715. readonly RGB8UI: number;
  73716. readonly RGBA8UI: number;
  73717. readonly R16I: number;
  73718. readonly RG16I: number;
  73719. readonly RGB16I: number;
  73720. readonly RGBA16I: number;
  73721. readonly R16UI: number;
  73722. readonly RG16UI: number;
  73723. readonly RGB16UI: number;
  73724. readonly RGBA16UI: number;
  73725. readonly R32I: number;
  73726. readonly RG32I: number;
  73727. readonly RGB32I: number;
  73728. readonly RGBA32I: number;
  73729. readonly R32UI: number;
  73730. readonly RG32UI: number;
  73731. readonly RGB32UI: number;
  73732. readonly RGBA32UI: number;
  73733. readonly RGB10_A2UI: number;
  73734. readonly R11F_G11F_B10F: number;
  73735. readonly RGB9_E5: number;
  73736. readonly RGB10_A2: number;
  73737. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73738. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73739. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73740. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73741. readonly DEPTH_COMPONENT32F: number;
  73742. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73743. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73744. 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;
  73745. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73746. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73747. readonly TRANSFORM_FEEDBACK: number;
  73748. readonly INTERLEAVED_ATTRIBS: number;
  73749. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73750. createTransformFeedback(): WebGLTransformFeedback;
  73751. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73752. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73753. beginTransformFeedback(primitiveMode: number): void;
  73754. endTransformFeedback(): void;
  73755. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73756. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73757. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73758. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73759. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73760. }
  73761. interface ImageBitmap {
  73762. readonly width: number;
  73763. readonly height: number;
  73764. close(): void;
  73765. }
  73766. interface WebGLQuery extends WebGLObject {
  73767. }
  73768. declare var WebGLQuery: {
  73769. prototype: WebGLQuery;
  73770. new(): WebGLQuery;
  73771. };
  73772. interface WebGLSampler extends WebGLObject {
  73773. }
  73774. declare var WebGLSampler: {
  73775. prototype: WebGLSampler;
  73776. new(): WebGLSampler;
  73777. };
  73778. interface WebGLSync extends WebGLObject {
  73779. }
  73780. declare var WebGLSync: {
  73781. prototype: WebGLSync;
  73782. new(): WebGLSync;
  73783. };
  73784. interface WebGLTransformFeedback extends WebGLObject {
  73785. }
  73786. declare var WebGLTransformFeedback: {
  73787. prototype: WebGLTransformFeedback;
  73788. new(): WebGLTransformFeedback;
  73789. };
  73790. interface WebGLVertexArrayObject extends WebGLObject {
  73791. }
  73792. declare var WebGLVertexArrayObject: {
  73793. prototype: WebGLVertexArrayObject;
  73794. new(): WebGLVertexArrayObject;
  73795. };
  73796. // Type definitions for WebVR API
  73797. // Project: https://w3c.github.io/webvr/
  73798. // Definitions by: six a <https://github.com/lostfictions>
  73799. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73800. interface VRDisplay extends EventTarget {
  73801. /**
  73802. * Dictionary of capabilities describing the VRDisplay.
  73803. */
  73804. readonly capabilities: VRDisplayCapabilities;
  73805. /**
  73806. * z-depth defining the far plane of the eye view frustum
  73807. * enables mapping of values in the render target depth
  73808. * attachment to scene coordinates. Initially set to 10000.0.
  73809. */
  73810. depthFar: number;
  73811. /**
  73812. * z-depth defining the near plane of the eye view frustum
  73813. * enables mapping of values in the render target depth
  73814. * attachment to scene coordinates. Initially set to 0.01.
  73815. */
  73816. depthNear: number;
  73817. /**
  73818. * An identifier for this distinct VRDisplay. Used as an
  73819. * association point in the Gamepad API.
  73820. */
  73821. readonly displayId: number;
  73822. /**
  73823. * A display name, a user-readable name identifying it.
  73824. */
  73825. readonly displayName: string;
  73826. readonly isConnected: boolean;
  73827. readonly isPresenting: boolean;
  73828. /**
  73829. * If this VRDisplay supports room-scale experiences, the optional
  73830. * stage attribute contains details on the room-scale parameters.
  73831. */
  73832. readonly stageParameters: VRStageParameters | null;
  73833. /**
  73834. * Passing the value returned by `requestAnimationFrame` to
  73835. * `cancelAnimationFrame` will unregister the callback.
  73836. * @param handle Define the hanle of the request to cancel
  73837. */
  73838. cancelAnimationFrame(handle: number): void;
  73839. /**
  73840. * Stops presenting to the VRDisplay.
  73841. * @returns a promise to know when it stopped
  73842. */
  73843. exitPresent(): Promise<void>;
  73844. /**
  73845. * Return the current VREyeParameters for the given eye.
  73846. * @param whichEye Define the eye we want the parameter for
  73847. * @returns the eye parameters
  73848. */
  73849. getEyeParameters(whichEye: string): VREyeParameters;
  73850. /**
  73851. * Populates the passed VRFrameData with the information required to render
  73852. * the current frame.
  73853. * @param frameData Define the data structure to populate
  73854. * @returns true if ok otherwise false
  73855. */
  73856. getFrameData(frameData: VRFrameData): boolean;
  73857. /**
  73858. * Get the layers currently being presented.
  73859. * @returns the list of VR layers
  73860. */
  73861. getLayers(): VRLayer[];
  73862. /**
  73863. * Return a VRPose containing the future predicted pose of the VRDisplay
  73864. * when the current frame will be presented. The value returned will not
  73865. * change until JavaScript has returned control to the browser.
  73866. *
  73867. * The VRPose will contain the position, orientation, velocity,
  73868. * and acceleration of each of these properties.
  73869. * @returns the pose object
  73870. */
  73871. getPose(): VRPose;
  73872. /**
  73873. * Return the current instantaneous pose of the VRDisplay, with no
  73874. * prediction applied.
  73875. * @returns the current instantaneous pose
  73876. */
  73877. getImmediatePose(): VRPose;
  73878. /**
  73879. * The callback passed to `requestAnimationFrame` will be called
  73880. * any time a new frame should be rendered. When the VRDisplay is
  73881. * presenting the callback will be called at the native refresh
  73882. * rate of the HMD. When not presenting this function acts
  73883. * identically to how window.requestAnimationFrame acts. Content should
  73884. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73885. * asynchronously from other displays and at differing refresh rates.
  73886. * @param callback Define the eaction to run next frame
  73887. * @returns the request handle it
  73888. */
  73889. requestAnimationFrame(callback: FrameRequestCallback): number;
  73890. /**
  73891. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73892. * Repeat calls while already presenting will update the VRLayers being displayed.
  73893. * @param layers Define the list of layer to present
  73894. * @returns a promise to know when the request has been fulfilled
  73895. */
  73896. requestPresent(layers: VRLayer[]): Promise<void>;
  73897. /**
  73898. * Reset the pose for this display, treating its current position and
  73899. * orientation as the "origin/zero" values. VRPose.position,
  73900. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73901. * updated when calling resetPose(). This should be called in only
  73902. * sitting-space experiences.
  73903. */
  73904. resetPose(): void;
  73905. /**
  73906. * The VRLayer provided to the VRDisplay will be captured and presented
  73907. * in the HMD. Calling this function has the same effect on the source
  73908. * canvas as any other operation that uses its source image, and canvases
  73909. * created without preserveDrawingBuffer set to true will be cleared.
  73910. * @param pose Define the pose to submit
  73911. */
  73912. submitFrame(pose?: VRPose): void;
  73913. }
  73914. declare var VRDisplay: {
  73915. prototype: VRDisplay;
  73916. new(): VRDisplay;
  73917. };
  73918. interface VRLayer {
  73919. leftBounds?: number[] | Float32Array | null;
  73920. rightBounds?: number[] | Float32Array | null;
  73921. source?: HTMLCanvasElement | null;
  73922. }
  73923. interface VRDisplayCapabilities {
  73924. readonly canPresent: boolean;
  73925. readonly hasExternalDisplay: boolean;
  73926. readonly hasOrientation: boolean;
  73927. readonly hasPosition: boolean;
  73928. readonly maxLayers: number;
  73929. }
  73930. interface VREyeParameters {
  73931. /** @deprecated */
  73932. readonly fieldOfView: VRFieldOfView;
  73933. readonly offset: Float32Array;
  73934. readonly renderHeight: number;
  73935. readonly renderWidth: number;
  73936. }
  73937. interface VRFieldOfView {
  73938. readonly downDegrees: number;
  73939. readonly leftDegrees: number;
  73940. readonly rightDegrees: number;
  73941. readonly upDegrees: number;
  73942. }
  73943. interface VRFrameData {
  73944. readonly leftProjectionMatrix: Float32Array;
  73945. readonly leftViewMatrix: Float32Array;
  73946. readonly pose: VRPose;
  73947. readonly rightProjectionMatrix: Float32Array;
  73948. readonly rightViewMatrix: Float32Array;
  73949. readonly timestamp: number;
  73950. }
  73951. interface VRPose {
  73952. readonly angularAcceleration: Float32Array | null;
  73953. readonly angularVelocity: Float32Array | null;
  73954. readonly linearAcceleration: Float32Array | null;
  73955. readonly linearVelocity: Float32Array | null;
  73956. readonly orientation: Float32Array | null;
  73957. readonly position: Float32Array | null;
  73958. readonly timestamp: number;
  73959. }
  73960. interface VRStageParameters {
  73961. sittingToStandingTransform?: Float32Array;
  73962. sizeX?: number;
  73963. sizeY?: number;
  73964. }
  73965. interface Navigator {
  73966. getVRDisplays(): Promise<VRDisplay[]>;
  73967. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73968. }
  73969. interface Window {
  73970. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73971. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73972. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73973. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73974. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73975. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73976. }
  73977. interface Gamepad {
  73978. readonly displayId: number;
  73979. }
  73980. type XRSessionMode =
  73981. | "inline"
  73982. | "immersive-vr"
  73983. | "immersive-ar";
  73984. type XRReferenceSpaceType =
  73985. | "viewer"
  73986. | "local"
  73987. | "local-floor"
  73988. | "bounded-floor"
  73989. | "unbounded";
  73990. type XREnvironmentBlendMode =
  73991. | "opaque"
  73992. | "additive"
  73993. | "alpha-blend";
  73994. type XRVisibilityState =
  73995. | "visible"
  73996. | "visible-blurred"
  73997. | "hidden";
  73998. type XRHandedness =
  73999. | "none"
  74000. | "left"
  74001. | "right";
  74002. type XRTargetRayMode =
  74003. | "gaze"
  74004. | "tracked-pointer"
  74005. | "screen";
  74006. type XREye =
  74007. | "none"
  74008. | "left"
  74009. | "right";
  74010. type XREventType =
  74011. | "devicechange"
  74012. | "visibilitychange"
  74013. | "end"
  74014. | "inputsourceschange"
  74015. | "select"
  74016. | "selectstart"
  74017. | "selectend"
  74018. | "squeeze"
  74019. | "squeezestart"
  74020. | "squeezeend"
  74021. | "reset";
  74022. interface XRSpace extends EventTarget {
  74023. }
  74024. interface XRRenderState {
  74025. depthNear?: number;
  74026. depthFar?: number;
  74027. inlineVerticalFieldOfView?: number;
  74028. baseLayer?: XRWebGLLayer;
  74029. }
  74030. interface XRInputSource {
  74031. handedness: XRHandedness;
  74032. targetRayMode: XRTargetRayMode;
  74033. targetRaySpace: XRSpace;
  74034. gripSpace: XRSpace | undefined;
  74035. gamepad: Gamepad | undefined;
  74036. profiles: Array<string>;
  74037. }
  74038. interface XRSessionInit {
  74039. optionalFeatures?: string[];
  74040. requiredFeatures?: string[];
  74041. }
  74042. interface XRSession {
  74043. addEventListener: Function;
  74044. removeEventListener: Function;
  74045. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74046. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74047. requestAnimationFrame: Function;
  74048. end(): Promise<void>;
  74049. renderState: XRRenderState;
  74050. inputSources: Array<XRInputSource>;
  74051. // hit test
  74052. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74053. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74054. // legacy AR hit test
  74055. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74056. // legacy plane detection
  74057. updateWorldTrackingState(options: {
  74058. planeDetectionState?: { enabled: boolean; }
  74059. }): void;
  74060. }
  74061. interface XRReferenceSpace extends XRSpace {
  74062. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74063. onreset: any;
  74064. }
  74065. type XRPlaneSet = Set<XRPlane>;
  74066. type XRAnchorSet = Set<XRAnchor>;
  74067. interface XRFrame {
  74068. session: XRSession;
  74069. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74070. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74071. // AR
  74072. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74073. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74074. // Anchors
  74075. trackedAnchors?: XRAnchorSet;
  74076. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74077. // Planes
  74078. worldInformation: {
  74079. detectedPlanes?: XRPlaneSet;
  74080. };
  74081. }
  74082. interface XRViewerPose extends XRPose {
  74083. views: Array<XRView>;
  74084. }
  74085. interface XRPose {
  74086. transform: XRRigidTransform;
  74087. emulatedPosition: boolean;
  74088. }
  74089. interface XRWebGLLayerOptions {
  74090. antialias?: boolean;
  74091. depth?: boolean;
  74092. stencil?: boolean;
  74093. alpha?: boolean;
  74094. multiview?: boolean;
  74095. framebufferScaleFactor?: number;
  74096. }
  74097. declare var XRWebGLLayer: {
  74098. prototype: XRWebGLLayer;
  74099. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74100. };
  74101. interface XRWebGLLayer {
  74102. framebuffer: WebGLFramebuffer;
  74103. framebufferWidth: number;
  74104. framebufferHeight: number;
  74105. getViewport: Function;
  74106. }
  74107. declare class XRRigidTransform {
  74108. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74109. position: DOMPointReadOnly;
  74110. orientation: DOMPointReadOnly;
  74111. matrix: Float32Array;
  74112. inverse: XRRigidTransform;
  74113. }
  74114. interface XRView {
  74115. eye: XREye;
  74116. projectionMatrix: Float32Array;
  74117. transform: XRRigidTransform;
  74118. }
  74119. interface XRInputSourceChangeEvent {
  74120. session: XRSession;
  74121. removed: Array<XRInputSource>;
  74122. added: Array<XRInputSource>;
  74123. }
  74124. interface XRInputSourceEvent extends Event {
  74125. readonly frame: XRFrame;
  74126. readonly inputSource: XRInputSource;
  74127. }
  74128. // Experimental(er) features
  74129. declare class XRRay {
  74130. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74131. origin: DOMPointReadOnly;
  74132. direction: DOMPointReadOnly;
  74133. matrix: Float32Array;
  74134. }
  74135. declare enum XRHitTestTrackableType {
  74136. "point",
  74137. "plane"
  74138. }
  74139. interface XRHitResult {
  74140. hitMatrix: Float32Array;
  74141. }
  74142. interface XRTransientInputHitTestResult {
  74143. readonly inputSource: XRInputSource;
  74144. readonly results: Array<XRHitTestResult>;
  74145. }
  74146. interface XRHitTestResult {
  74147. getPose(baseSpace: XRSpace): XRPose | undefined;
  74148. // When anchor system is enabled
  74149. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74150. }
  74151. interface XRHitTestSource {
  74152. cancel(): void;
  74153. }
  74154. interface XRTransientInputHitTestSource {
  74155. cancel(): void;
  74156. }
  74157. interface XRHitTestOptionsInit {
  74158. space: XRSpace;
  74159. entityTypes?: Array<XRHitTestTrackableType>;
  74160. offsetRay?: XRRay;
  74161. }
  74162. interface XRTransientInputHitTestOptionsInit {
  74163. profile: string;
  74164. entityTypes?: Array<XRHitTestTrackableType>;
  74165. offsetRay?: XRRay;
  74166. }
  74167. interface XRAnchor {
  74168. anchorSpace: XRSpace;
  74169. delete(): void;
  74170. }
  74171. interface XRPlane {
  74172. orientation: "Horizontal" | "Vertical";
  74173. planeSpace: XRSpace;
  74174. polygon: Array<DOMPointReadOnly>;
  74175. lastChangedTime: number;
  74176. }
  74177. /**
  74178. * @ignore
  74179. */
  74180. declare module BABYLON.GLTF2.Exporter {
  74181. }
  74182. /**
  74183. * @ignore
  74184. */
  74185. declare module BABYLON.GLTF1 {
  74186. }
  74187. declare module BABYLON.GUI {
  74188. /**
  74189. * Class used to specific a value and its associated unit
  74190. */
  74191. export class ValueAndUnit {
  74192. /** defines the unit to store */
  74193. unit: number;
  74194. /** defines a boolean indicating if the value can be negative */
  74195. negativeValueAllowed: boolean;
  74196. private _value;
  74197. private _originalUnit;
  74198. /**
  74199. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74200. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74201. */
  74202. ignoreAdaptiveScaling: boolean;
  74203. /**
  74204. * Creates a new ValueAndUnit
  74205. * @param value defines the value to store
  74206. * @param unit defines the unit to store
  74207. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74208. */
  74209. constructor(value: number,
  74210. /** defines the unit to store */
  74211. unit?: number,
  74212. /** defines a boolean indicating if the value can be negative */
  74213. negativeValueAllowed?: boolean);
  74214. /** Gets a boolean indicating if the value is a percentage */
  74215. get isPercentage(): boolean;
  74216. /** Gets a boolean indicating if the value is store as pixel */
  74217. get isPixel(): boolean;
  74218. /** Gets direct internal value */
  74219. get internalValue(): number;
  74220. /**
  74221. * Gets value as pixel
  74222. * @param host defines the root host
  74223. * @param refValue defines the reference value for percentages
  74224. * @returns the value as pixel
  74225. */
  74226. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74227. /**
  74228. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74229. * @param value defines the value to store
  74230. * @param unit defines the unit to store
  74231. * @returns the current ValueAndUnit
  74232. */
  74233. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74234. /**
  74235. * Gets the value accordingly to its unit
  74236. * @param host defines the root host
  74237. * @returns the value
  74238. */
  74239. getValue(host: AdvancedDynamicTexture): number;
  74240. /**
  74241. * Gets a string representation of the value
  74242. * @param host defines the root host
  74243. * @param decimals defines an optional number of decimals to display
  74244. * @returns a string
  74245. */
  74246. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74247. /**
  74248. * Store a value parsed from a string
  74249. * @param source defines the source string
  74250. * @returns true if the value was successfully parsed
  74251. */
  74252. fromString(source: string | number): boolean;
  74253. private static _Regex;
  74254. private static _UNITMODE_PERCENTAGE;
  74255. private static _UNITMODE_PIXEL;
  74256. /** UNITMODE_PERCENTAGE */
  74257. static get UNITMODE_PERCENTAGE(): number;
  74258. /** UNITMODE_PIXEL */
  74259. static get UNITMODE_PIXEL(): number;
  74260. }
  74261. }
  74262. declare module BABYLON.GUI {
  74263. /**
  74264. * Define a style used by control to automatically setup properties based on a template.
  74265. * Only support font related properties so far
  74266. */
  74267. export class Style implements BABYLON.IDisposable {
  74268. private _fontFamily;
  74269. private _fontStyle;
  74270. private _fontWeight;
  74271. /** @hidden */
  74272. _host: AdvancedDynamicTexture;
  74273. /** @hidden */
  74274. _fontSize: ValueAndUnit;
  74275. /**
  74276. * BABYLON.Observable raised when the style values are changed
  74277. */
  74278. onChangedObservable: BABYLON.Observable<Style>;
  74279. /**
  74280. * Creates a new style object
  74281. * @param host defines the AdvancedDynamicTexture which hosts this style
  74282. */
  74283. constructor(host: AdvancedDynamicTexture);
  74284. /**
  74285. * Gets or sets the font size
  74286. */
  74287. get fontSize(): string | number;
  74288. set fontSize(value: string | number);
  74289. /**
  74290. * Gets or sets the font family
  74291. */
  74292. get fontFamily(): string;
  74293. set fontFamily(value: string);
  74294. /**
  74295. * Gets or sets the font style
  74296. */
  74297. get fontStyle(): string;
  74298. set fontStyle(value: string);
  74299. /** Gets or sets font weight */
  74300. get fontWeight(): string;
  74301. set fontWeight(value: string);
  74302. /** Dispose all associated resources */
  74303. dispose(): void;
  74304. }
  74305. }
  74306. declare module BABYLON.GUI {
  74307. /**
  74308. * Class used to transport BABYLON.Vector2 information for pointer events
  74309. */
  74310. export class Vector2WithInfo extends BABYLON.Vector2 {
  74311. /** defines the current mouse button index */
  74312. buttonIndex: number;
  74313. /**
  74314. * Creates a new Vector2WithInfo
  74315. * @param source defines the vector2 data to transport
  74316. * @param buttonIndex defines the current mouse button index
  74317. */
  74318. constructor(source: BABYLON.Vector2,
  74319. /** defines the current mouse button index */
  74320. buttonIndex?: number);
  74321. }
  74322. /** Class used to provide 2D matrix features */
  74323. export class Matrix2D {
  74324. /** Gets the internal array of 6 floats used to store matrix data */
  74325. m: Float32Array;
  74326. /**
  74327. * Creates a new matrix
  74328. * @param m00 defines value for (0, 0)
  74329. * @param m01 defines value for (0, 1)
  74330. * @param m10 defines value for (1, 0)
  74331. * @param m11 defines value for (1, 1)
  74332. * @param m20 defines value for (2, 0)
  74333. * @param m21 defines value for (2, 1)
  74334. */
  74335. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74336. /**
  74337. * Fills the matrix from direct values
  74338. * @param m00 defines value for (0, 0)
  74339. * @param m01 defines value for (0, 1)
  74340. * @param m10 defines value for (1, 0)
  74341. * @param m11 defines value for (1, 1)
  74342. * @param m20 defines value for (2, 0)
  74343. * @param m21 defines value for (2, 1)
  74344. * @returns the current modified matrix
  74345. */
  74346. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74347. /**
  74348. * Gets matrix determinant
  74349. * @returns the determinant
  74350. */
  74351. determinant(): number;
  74352. /**
  74353. * Inverses the matrix and stores it in a target matrix
  74354. * @param result defines the target matrix
  74355. * @returns the current matrix
  74356. */
  74357. invertToRef(result: Matrix2D): Matrix2D;
  74358. /**
  74359. * Multiplies the current matrix with another one
  74360. * @param other defines the second operand
  74361. * @param result defines the target matrix
  74362. * @returns the current matrix
  74363. */
  74364. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74365. /**
  74366. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74367. * @param x defines the x coordinate to transform
  74368. * @param y defines the x coordinate to transform
  74369. * @param result defines the target vector2
  74370. * @returns the current matrix
  74371. */
  74372. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74373. /**
  74374. * Creates an identity matrix
  74375. * @returns a new matrix
  74376. */
  74377. static Identity(): Matrix2D;
  74378. /**
  74379. * Creates a translation matrix and stores it in a target matrix
  74380. * @param x defines the x coordinate of the translation
  74381. * @param y defines the y coordinate of the translation
  74382. * @param result defines the target matrix
  74383. */
  74384. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74385. /**
  74386. * Creates a scaling matrix and stores it in a target matrix
  74387. * @param x defines the x coordinate of the scaling
  74388. * @param y defines the y coordinate of the scaling
  74389. * @param result defines the target matrix
  74390. */
  74391. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74392. /**
  74393. * Creates a rotation matrix and stores it in a target matrix
  74394. * @param angle defines the rotation angle
  74395. * @param result defines the target matrix
  74396. */
  74397. static RotationToRef(angle: number, result: Matrix2D): void;
  74398. private static _TempPreTranslationMatrix;
  74399. private static _TempPostTranslationMatrix;
  74400. private static _TempRotationMatrix;
  74401. private static _TempScalingMatrix;
  74402. private static _TempCompose0;
  74403. private static _TempCompose1;
  74404. private static _TempCompose2;
  74405. /**
  74406. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74407. * @param tx defines the x coordinate of the translation
  74408. * @param ty defines the y coordinate of the translation
  74409. * @param angle defines the rotation angle
  74410. * @param scaleX defines the x coordinate of the scaling
  74411. * @param scaleY defines the y coordinate of the scaling
  74412. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74413. * @param result defines the target matrix
  74414. */
  74415. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74416. }
  74417. }
  74418. declare module BABYLON.GUI {
  74419. /**
  74420. * Class used to store 2D control sizes
  74421. */
  74422. export class Measure {
  74423. /** defines left coordinate */
  74424. left: number;
  74425. /** defines top coordinate */
  74426. top: number;
  74427. /** defines width dimension */
  74428. width: number;
  74429. /** defines height dimension */
  74430. height: number;
  74431. /**
  74432. * Creates a new measure
  74433. * @param left defines left coordinate
  74434. * @param top defines top coordinate
  74435. * @param width defines width dimension
  74436. * @param height defines height dimension
  74437. */
  74438. constructor(
  74439. /** defines left coordinate */
  74440. left: number,
  74441. /** defines top coordinate */
  74442. top: number,
  74443. /** defines width dimension */
  74444. width: number,
  74445. /** defines height dimension */
  74446. height: number);
  74447. /**
  74448. * Copy from another measure
  74449. * @param other defines the other measure to copy from
  74450. */
  74451. copyFrom(other: Measure): void;
  74452. /**
  74453. * Copy from a group of 4 floats
  74454. * @param left defines left coordinate
  74455. * @param top defines top coordinate
  74456. * @param width defines width dimension
  74457. * @param height defines height dimension
  74458. */
  74459. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74460. /**
  74461. * Computes the axis aligned bounding box measure for two given measures
  74462. * @param a Input measure
  74463. * @param b Input measure
  74464. * @param result the resulting bounding measure
  74465. */
  74466. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74467. /**
  74468. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74469. * @param transform the matrix to transform the measure before computing the AABB
  74470. * @param result the resulting AABB
  74471. */
  74472. transformToRef(transform: Matrix2D, result: Measure): void;
  74473. /**
  74474. * Check equality between this measure and another one
  74475. * @param other defines the other measures
  74476. * @returns true if both measures are equals
  74477. */
  74478. isEqualsTo(other: Measure): boolean;
  74479. /**
  74480. * Creates an empty measure
  74481. * @returns a new measure
  74482. */
  74483. static Empty(): Measure;
  74484. }
  74485. }
  74486. declare module BABYLON.GUI {
  74487. /**
  74488. * Interface used to define a control that can receive focus
  74489. */
  74490. export interface IFocusableControl {
  74491. /**
  74492. * Function called when the control receives the focus
  74493. */
  74494. onFocus(): void;
  74495. /**
  74496. * Function called when the control loses the focus
  74497. */
  74498. onBlur(): void;
  74499. /**
  74500. * Function called to let the control handle keyboard events
  74501. * @param evt defines the current keyboard event
  74502. */
  74503. processKeyboard(evt: KeyboardEvent): void;
  74504. /**
  74505. * Function called to get the list of controls that should not steal the focus from this control
  74506. * @returns an array of controls
  74507. */
  74508. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74509. }
  74510. /**
  74511. * Class used to create texture to support 2D GUI elements
  74512. * @see http://doc.babylonjs.com/how_to/gui
  74513. */
  74514. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74515. private _isDirty;
  74516. private _renderObserver;
  74517. private _resizeObserver;
  74518. private _preKeyboardObserver;
  74519. private _pointerMoveObserver;
  74520. private _pointerObserver;
  74521. private _canvasPointerOutObserver;
  74522. private _background;
  74523. /** @hidden */
  74524. _rootContainer: Container;
  74525. /** @hidden */
  74526. _lastPickedControl: Control;
  74527. /** @hidden */
  74528. _lastControlOver: {
  74529. [pointerId: number]: Control;
  74530. };
  74531. /** @hidden */
  74532. _lastControlDown: {
  74533. [pointerId: number]: Control;
  74534. };
  74535. /** @hidden */
  74536. _capturingControl: {
  74537. [pointerId: number]: Control;
  74538. };
  74539. /** @hidden */
  74540. _shouldBlockPointer: boolean;
  74541. /** @hidden */
  74542. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74543. /** @hidden */
  74544. _linkedControls: Control[];
  74545. private _isFullscreen;
  74546. private _fullscreenViewport;
  74547. private _idealWidth;
  74548. private _idealHeight;
  74549. private _useSmallestIdeal;
  74550. private _renderAtIdealSize;
  74551. private _focusedControl;
  74552. private _blockNextFocusCheck;
  74553. private _renderScale;
  74554. private _rootElement;
  74555. private _cursorChanged;
  74556. private _defaultMousePointerId;
  74557. /** @hidden */
  74558. _numLayoutCalls: number;
  74559. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74560. get numLayoutCalls(): number;
  74561. /** @hidden */
  74562. _numRenderCalls: number;
  74563. /** Gets the number of render calls made the last time the ADT has been rendered */
  74564. get numRenderCalls(): number;
  74565. /**
  74566. * Define type to string to ensure compatibility across browsers
  74567. * Safari doesn't support DataTransfer constructor
  74568. */
  74569. private _clipboardData;
  74570. /**
  74571. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74572. */
  74573. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74574. /**
  74575. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74576. */
  74577. onControlPickedObservable: BABYLON.Observable<Control>;
  74578. /**
  74579. * BABYLON.Observable event triggered before layout is evaluated
  74580. */
  74581. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74582. /**
  74583. * BABYLON.Observable event triggered after the layout was evaluated
  74584. */
  74585. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74586. /**
  74587. * BABYLON.Observable event triggered before the texture is rendered
  74588. */
  74589. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74590. /**
  74591. * BABYLON.Observable event triggered after the texture was rendered
  74592. */
  74593. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74594. /**
  74595. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74596. */
  74597. premulAlpha: boolean;
  74598. /**
  74599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74600. * Useful when you want more antialiasing
  74601. */
  74602. get renderScale(): number;
  74603. set renderScale(value: number);
  74604. /** Gets or sets the background color */
  74605. get background(): string;
  74606. set background(value: string);
  74607. /**
  74608. * Gets or sets the ideal width used to design controls.
  74609. * The GUI will then rescale everything accordingly
  74610. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74611. */
  74612. get idealWidth(): number;
  74613. set idealWidth(value: number);
  74614. /**
  74615. * Gets or sets the ideal height used to design controls.
  74616. * The GUI will then rescale everything accordingly
  74617. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74618. */
  74619. get idealHeight(): number;
  74620. set idealHeight(value: number);
  74621. /**
  74622. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74623. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74624. */
  74625. get useSmallestIdeal(): boolean;
  74626. set useSmallestIdeal(value: boolean);
  74627. /**
  74628. * Gets or sets a boolean indicating if adaptive scaling must be used
  74629. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74630. */
  74631. get renderAtIdealSize(): boolean;
  74632. set renderAtIdealSize(value: boolean);
  74633. /**
  74634. * Gets the ratio used when in "ideal mode"
  74635. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74636. * */
  74637. get idealRatio(): number;
  74638. /**
  74639. * Gets the underlying layer used to render the texture when in fullscreen mode
  74640. */
  74641. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74642. /**
  74643. * Gets the root container control
  74644. */
  74645. get rootContainer(): Container;
  74646. /**
  74647. * Returns an array containing the root container.
  74648. * This is mostly used to let the Inspector introspects the ADT
  74649. * @returns an array containing the rootContainer
  74650. */
  74651. getChildren(): Array<Container>;
  74652. /**
  74653. * Will return all controls that are inside this texture
  74654. * @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
  74655. * @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
  74656. * @return all child controls
  74657. */
  74658. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74659. /**
  74660. * Gets or sets the current focused control
  74661. */
  74662. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74663. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74664. /**
  74665. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74666. */
  74667. get isForeground(): boolean;
  74668. set isForeground(value: boolean);
  74669. /**
  74670. * Gets or set information about clipboardData
  74671. */
  74672. get clipboardData(): string;
  74673. set clipboardData(value: string);
  74674. /**
  74675. * Creates a new AdvancedDynamicTexture
  74676. * @param name defines the name of the texture
  74677. * @param width defines the width of the texture
  74678. * @param height defines the height of the texture
  74679. * @param scene defines the hosting scene
  74680. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74681. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74682. */
  74683. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74684. /**
  74685. * Get the current class name of the texture useful for serialization or dynamic coding.
  74686. * @returns "AdvancedDynamicTexture"
  74687. */
  74688. getClassName(): string;
  74689. /**
  74690. * Function used to execute a function on all controls
  74691. * @param func defines the function to execute
  74692. * @param container defines the container where controls belong. If null the root container will be used
  74693. */
  74694. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74695. private _useInvalidateRectOptimization;
  74696. /**
  74697. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74698. */
  74699. get useInvalidateRectOptimization(): boolean;
  74700. set useInvalidateRectOptimization(value: boolean);
  74701. private _invalidatedRectangle;
  74702. /**
  74703. * Invalidates a rectangle area on the gui texture
  74704. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74705. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74706. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74707. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74708. */
  74709. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74710. /**
  74711. * Marks the texture as dirty forcing a complete update
  74712. */
  74713. markAsDirty(): void;
  74714. /**
  74715. * Helper function used to create a new style
  74716. * @returns a new style
  74717. * @see http://doc.babylonjs.com/how_to/gui#styles
  74718. */
  74719. createStyle(): Style;
  74720. /**
  74721. * Adds a new control to the root container
  74722. * @param control defines the control to add
  74723. * @returns the current texture
  74724. */
  74725. addControl(control: Control): AdvancedDynamicTexture;
  74726. /**
  74727. * Removes a control from the root container
  74728. * @param control defines the control to remove
  74729. * @returns the current texture
  74730. */
  74731. removeControl(control: Control): AdvancedDynamicTexture;
  74732. /**
  74733. * Release all resources
  74734. */
  74735. dispose(): void;
  74736. private _onResize;
  74737. /** @hidden */
  74738. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74739. /**
  74740. * Get screen coordinates for a vector3
  74741. * @param position defines the position to project
  74742. * @param worldMatrix defines the world matrix to use
  74743. * @returns the projected position
  74744. */
  74745. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74746. private _checkUpdate;
  74747. private _clearMeasure;
  74748. private _render;
  74749. /** @hidden */
  74750. _changeCursor(cursor: string): void;
  74751. /** @hidden */
  74752. _registerLastControlDown(control: Control, pointerId: number): void;
  74753. private _doPicking;
  74754. /** @hidden */
  74755. _cleanControlAfterRemovalFromList(list: {
  74756. [pointerId: number]: Control;
  74757. }, control: Control): void;
  74758. /** @hidden */
  74759. _cleanControlAfterRemoval(control: Control): void;
  74760. /** Attach to all scene events required to support pointer events */
  74761. attach(): void;
  74762. /** @hidden */
  74763. private onClipboardCopy;
  74764. /** @hidden */
  74765. private onClipboardCut;
  74766. /** @hidden */
  74767. private onClipboardPaste;
  74768. /**
  74769. * Register the clipboard Events onto the canvas
  74770. */
  74771. registerClipboardEvents(): void;
  74772. /**
  74773. * Unregister the clipboard Events from the canvas
  74774. */
  74775. unRegisterClipboardEvents(): void;
  74776. /**
  74777. * Connect the texture to a hosting mesh to enable interactions
  74778. * @param mesh defines the mesh to attach to
  74779. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74780. */
  74781. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74782. /**
  74783. * Move the focus to a specific control
  74784. * @param control defines the control which will receive the focus
  74785. */
  74786. moveFocusToControl(control: IFocusableControl): void;
  74787. private _manageFocus;
  74788. private _attachToOnPointerOut;
  74789. /**
  74790. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74791. * @param mesh defines the mesh which will receive the texture
  74792. * @param width defines the texture width (1024 by default)
  74793. * @param height defines the texture height (1024 by default)
  74794. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74795. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74796. * @returns a new AdvancedDynamicTexture
  74797. */
  74798. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74799. /**
  74800. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74801. * In this mode the texture will rely on a layer for its rendering.
  74802. * This allows it to be treated like any other layer.
  74803. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74804. * LayerMask is set through advancedTexture.layer.layerMask
  74805. * @param name defines name for the texture
  74806. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74807. * @param scene defines the hsoting scene
  74808. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74809. * @returns a new AdvancedDynamicTexture
  74810. */
  74811. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74812. }
  74813. }
  74814. declare module BABYLON.GUI {
  74815. /**
  74816. * Root class used for all 2D controls
  74817. * @see http://doc.babylonjs.com/how_to/gui#controls
  74818. */
  74819. export class Control {
  74820. /** defines the name of the control */
  74821. name?: string | undefined;
  74822. /**
  74823. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74824. */
  74825. static AllowAlphaInheritance: boolean;
  74826. private _alpha;
  74827. private _alphaSet;
  74828. private _zIndex;
  74829. /** @hidden */
  74830. _host: AdvancedDynamicTexture;
  74831. /** Gets or sets the control parent */
  74832. parent: BABYLON.Nullable<Container>;
  74833. /** @hidden */
  74834. _currentMeasure: Measure;
  74835. private _fontFamily;
  74836. private _fontStyle;
  74837. private _fontWeight;
  74838. private _fontSize;
  74839. private _font;
  74840. /** @hidden */
  74841. _width: ValueAndUnit;
  74842. /** @hidden */
  74843. _height: ValueAndUnit;
  74844. /** @hidden */
  74845. protected _fontOffset: {
  74846. ascent: number;
  74847. height: number;
  74848. descent: number;
  74849. };
  74850. private _color;
  74851. private _style;
  74852. private _styleObserver;
  74853. /** @hidden */
  74854. protected _horizontalAlignment: number;
  74855. /** @hidden */
  74856. protected _verticalAlignment: number;
  74857. /** @hidden */
  74858. protected _isDirty: boolean;
  74859. /** @hidden */
  74860. protected _wasDirty: boolean;
  74861. /** @hidden */
  74862. _tempParentMeasure: Measure;
  74863. /** @hidden */
  74864. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74865. /** @hidden */
  74866. protected _cachedParentMeasure: Measure;
  74867. private _paddingLeft;
  74868. private _paddingRight;
  74869. private _paddingTop;
  74870. private _paddingBottom;
  74871. /** @hidden */
  74872. _left: ValueAndUnit;
  74873. /** @hidden */
  74874. _top: ValueAndUnit;
  74875. private _scaleX;
  74876. private _scaleY;
  74877. private _rotation;
  74878. private _transformCenterX;
  74879. private _transformCenterY;
  74880. /** @hidden */
  74881. _transformMatrix: Matrix2D;
  74882. /** @hidden */
  74883. protected _invertTransformMatrix: Matrix2D;
  74884. /** @hidden */
  74885. protected _transformedPosition: BABYLON.Vector2;
  74886. private _isMatrixDirty;
  74887. private _cachedOffsetX;
  74888. private _cachedOffsetY;
  74889. private _isVisible;
  74890. private _isHighlighted;
  74891. /** @hidden */
  74892. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74893. private _fontSet;
  74894. private _dummyVector2;
  74895. private _downCount;
  74896. private _enterCount;
  74897. private _doNotRender;
  74898. private _downPointerIds;
  74899. protected _isEnabled: boolean;
  74900. protected _disabledColor: string;
  74901. protected _disabledColorItem: string;
  74902. /** @hidden */
  74903. protected _rebuildLayout: boolean;
  74904. /** @hidden */
  74905. _customData: any;
  74906. /** @hidden */
  74907. _isClipped: boolean;
  74908. /** @hidden */
  74909. _automaticSize: boolean;
  74910. /** @hidden */
  74911. _tag: any;
  74912. /**
  74913. * 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
  74914. */
  74915. uniqueId: number;
  74916. /**
  74917. * Gets or sets an object used to store user defined information for the node
  74918. */
  74919. metadata: any;
  74920. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74921. isHitTestVisible: boolean;
  74922. /** Gets or sets a boolean indicating if the control can block pointer events */
  74923. isPointerBlocker: boolean;
  74924. /** Gets or sets a boolean indicating if the control can be focusable */
  74925. isFocusInvisible: boolean;
  74926. /**
  74927. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74928. * 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
  74929. */
  74930. clipChildren: boolean;
  74931. /**
  74932. * Gets or sets a boolean indicating that control content must be clipped
  74933. * 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
  74934. */
  74935. clipContent: boolean;
  74936. /**
  74937. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74938. */
  74939. useBitmapCache: boolean;
  74940. private _cacheData;
  74941. private _shadowOffsetX;
  74942. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74943. get shadowOffsetX(): number;
  74944. set shadowOffsetX(value: number);
  74945. private _shadowOffsetY;
  74946. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74947. get shadowOffsetY(): number;
  74948. set shadowOffsetY(value: number);
  74949. private _shadowBlur;
  74950. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74951. get shadowBlur(): number;
  74952. set shadowBlur(value: number);
  74953. private _shadowColor;
  74954. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74955. get shadowColor(): string;
  74956. set shadowColor(value: string);
  74957. /** Gets or sets the cursor to use when the control is hovered */
  74958. hoverCursor: string;
  74959. /** @hidden */
  74960. protected _linkOffsetX: ValueAndUnit;
  74961. /** @hidden */
  74962. protected _linkOffsetY: ValueAndUnit;
  74963. /** Gets the control type name */
  74964. get typeName(): string;
  74965. /**
  74966. * Get the current class name of the control.
  74967. * @returns current class name
  74968. */
  74969. getClassName(): string;
  74970. /**
  74971. * An event triggered when pointer wheel is scrolled
  74972. */
  74973. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74974. /**
  74975. * An event triggered when the pointer move over the control.
  74976. */
  74977. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74978. /**
  74979. * An event triggered when the pointer move out of the control.
  74980. */
  74981. onPointerOutObservable: BABYLON.Observable<Control>;
  74982. /**
  74983. * An event triggered when the pointer taps the control
  74984. */
  74985. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74986. /**
  74987. * An event triggered when pointer up
  74988. */
  74989. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74990. /**
  74991. * An event triggered when a control is clicked on
  74992. */
  74993. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74994. /**
  74995. * An event triggered when pointer enters the control
  74996. */
  74997. onPointerEnterObservable: BABYLON.Observable<Control>;
  74998. /**
  74999. * An event triggered when the control is marked as dirty
  75000. */
  75001. onDirtyObservable: BABYLON.Observable<Control>;
  75002. /**
  75003. * An event triggered before drawing the control
  75004. */
  75005. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75006. /**
  75007. * An event triggered after the control was drawn
  75008. */
  75009. onAfterDrawObservable: BABYLON.Observable<Control>;
  75010. /**
  75011. * An event triggered when the control has been disposed
  75012. */
  75013. onDisposeObservable: BABYLON.Observable<Control>;
  75014. /**
  75015. * Get the hosting AdvancedDynamicTexture
  75016. */
  75017. get host(): AdvancedDynamicTexture;
  75018. /** Gets or set information about font offsets (used to render and align text) */
  75019. get fontOffset(): {
  75020. ascent: number;
  75021. height: number;
  75022. descent: number;
  75023. };
  75024. set fontOffset(offset: {
  75025. ascent: number;
  75026. height: number;
  75027. descent: number;
  75028. });
  75029. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75030. get alpha(): number;
  75031. set alpha(value: number);
  75032. /**
  75033. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75034. */
  75035. get isHighlighted(): boolean;
  75036. set isHighlighted(value: boolean);
  75037. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75038. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75039. */
  75040. get scaleX(): number;
  75041. set scaleX(value: number);
  75042. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75043. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75044. */
  75045. get scaleY(): number;
  75046. set scaleY(value: number);
  75047. /** Gets or sets the rotation angle (0 by default)
  75048. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75049. */
  75050. get rotation(): number;
  75051. set rotation(value: number);
  75052. /** Gets or sets the transformation center on Y axis (0 by default)
  75053. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75054. */
  75055. get transformCenterY(): number;
  75056. set transformCenterY(value: number);
  75057. /** Gets or sets the transformation center on X axis (0 by default)
  75058. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75059. */
  75060. get transformCenterX(): number;
  75061. set transformCenterX(value: number);
  75062. /**
  75063. * Gets or sets the horizontal alignment
  75064. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75065. */
  75066. get horizontalAlignment(): number;
  75067. set horizontalAlignment(value: number);
  75068. /**
  75069. * Gets or sets the vertical alignment
  75070. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75071. */
  75072. get verticalAlignment(): number;
  75073. set verticalAlignment(value: number);
  75074. /**
  75075. * Gets or sets control width
  75076. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75077. */
  75078. get width(): string | number;
  75079. set width(value: string | number);
  75080. /**
  75081. * Gets or sets the control width in pixel
  75082. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75083. */
  75084. get widthInPixels(): number;
  75085. set widthInPixels(value: number);
  75086. /**
  75087. * Gets or sets control height
  75088. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75089. */
  75090. get height(): string | number;
  75091. set height(value: string | number);
  75092. /**
  75093. * Gets or sets control height in pixel
  75094. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75095. */
  75096. get heightInPixels(): number;
  75097. set heightInPixels(value: number);
  75098. /** Gets or set font family */
  75099. get fontFamily(): string;
  75100. set fontFamily(value: string);
  75101. /** Gets or sets font style */
  75102. get fontStyle(): string;
  75103. set fontStyle(value: string);
  75104. /** Gets or sets font weight */
  75105. get fontWeight(): string;
  75106. set fontWeight(value: string);
  75107. /**
  75108. * Gets or sets style
  75109. * @see http://doc.babylonjs.com/how_to/gui#styles
  75110. */
  75111. get style(): BABYLON.Nullable<Style>;
  75112. set style(value: BABYLON.Nullable<Style>);
  75113. /** @hidden */
  75114. get _isFontSizeInPercentage(): boolean;
  75115. /** Gets or sets font size in pixels */
  75116. get fontSizeInPixels(): number;
  75117. set fontSizeInPixels(value: number);
  75118. /** Gets or sets font size */
  75119. get fontSize(): string | number;
  75120. set fontSize(value: string | number);
  75121. /** Gets or sets foreground color */
  75122. get color(): string;
  75123. set color(value: string);
  75124. /** Gets or sets z index which is used to reorder controls on the z axis */
  75125. get zIndex(): number;
  75126. set zIndex(value: number);
  75127. /** Gets or sets a boolean indicating if the control can be rendered */
  75128. get notRenderable(): boolean;
  75129. set notRenderable(value: boolean);
  75130. /** Gets or sets a boolean indicating if the control is visible */
  75131. get isVisible(): boolean;
  75132. set isVisible(value: boolean);
  75133. /** Gets a boolean indicating that the control needs to update its rendering */
  75134. get isDirty(): boolean;
  75135. /**
  75136. * Gets the current linked mesh (or null if none)
  75137. */
  75138. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75139. /**
  75140. * Gets or sets a value indicating the padding to use on the left of the control
  75141. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75142. */
  75143. get paddingLeft(): string | number;
  75144. set paddingLeft(value: string | number);
  75145. /**
  75146. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75147. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75148. */
  75149. get paddingLeftInPixels(): number;
  75150. set paddingLeftInPixels(value: number);
  75151. /**
  75152. * Gets or sets a value indicating the padding to use on the right of the control
  75153. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75154. */
  75155. get paddingRight(): string | number;
  75156. set paddingRight(value: string | number);
  75157. /**
  75158. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75159. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75160. */
  75161. get paddingRightInPixels(): number;
  75162. set paddingRightInPixels(value: number);
  75163. /**
  75164. * Gets or sets a value indicating the padding to use on the top of the control
  75165. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75166. */
  75167. get paddingTop(): string | number;
  75168. set paddingTop(value: string | number);
  75169. /**
  75170. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75171. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75172. */
  75173. get paddingTopInPixels(): number;
  75174. set paddingTopInPixels(value: number);
  75175. /**
  75176. * Gets or sets a value indicating the padding to use on the bottom of the control
  75177. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75178. */
  75179. get paddingBottom(): string | number;
  75180. set paddingBottom(value: string | number);
  75181. /**
  75182. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75183. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75184. */
  75185. get paddingBottomInPixels(): number;
  75186. set paddingBottomInPixels(value: number);
  75187. /**
  75188. * Gets or sets a value indicating the left coordinate of the control
  75189. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75190. */
  75191. get left(): string | number;
  75192. set left(value: string | number);
  75193. /**
  75194. * Gets or sets a value indicating the left coordinate in pixels of the control
  75195. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75196. */
  75197. get leftInPixels(): number;
  75198. set leftInPixels(value: number);
  75199. /**
  75200. * Gets or sets a value indicating the top coordinate of the control
  75201. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75202. */
  75203. get top(): string | number;
  75204. set top(value: string | number);
  75205. /**
  75206. * Gets or sets a value indicating the top coordinate in pixels of the control
  75207. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75208. */
  75209. get topInPixels(): number;
  75210. set topInPixels(value: number);
  75211. /**
  75212. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75213. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75214. */
  75215. get linkOffsetX(): string | number;
  75216. set linkOffsetX(value: string | number);
  75217. /**
  75218. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75219. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75220. */
  75221. get linkOffsetXInPixels(): number;
  75222. set linkOffsetXInPixels(value: number);
  75223. /**
  75224. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75225. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75226. */
  75227. get linkOffsetY(): string | number;
  75228. set linkOffsetY(value: string | number);
  75229. /**
  75230. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75231. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75232. */
  75233. get linkOffsetYInPixels(): number;
  75234. set linkOffsetYInPixels(value: number);
  75235. /** Gets the center coordinate on X axis */
  75236. get centerX(): number;
  75237. /** Gets the center coordinate on Y axis */
  75238. get centerY(): number;
  75239. /** Gets or sets if control is Enabled*/
  75240. get isEnabled(): boolean;
  75241. set isEnabled(value: boolean);
  75242. /** Gets or sets background color of control if it's disabled*/
  75243. get disabledColor(): string;
  75244. set disabledColor(value: string);
  75245. /** Gets or sets front color of control if it's disabled*/
  75246. get disabledColorItem(): string;
  75247. set disabledColorItem(value: string);
  75248. /**
  75249. * Creates a new control
  75250. * @param name defines the name of the control
  75251. */
  75252. constructor(
  75253. /** defines the name of the control */
  75254. name?: string | undefined);
  75255. /** @hidden */
  75256. protected _getTypeName(): string;
  75257. /**
  75258. * Gets the first ascendant in the hierarchy of the given type
  75259. * @param className defines the required type
  75260. * @returns the ascendant or null if not found
  75261. */
  75262. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75263. /** @hidden */
  75264. _resetFontCache(): void;
  75265. /**
  75266. * Determines if a container is an ascendant of the current control
  75267. * @param container defines the container to look for
  75268. * @returns true if the container is one of the ascendant of the control
  75269. */
  75270. isAscendant(container: Control): boolean;
  75271. /**
  75272. * Gets coordinates in local control space
  75273. * @param globalCoordinates defines the coordinates to transform
  75274. * @returns the new coordinates in local space
  75275. */
  75276. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75277. /**
  75278. * Gets coordinates in local control space
  75279. * @param globalCoordinates defines the coordinates to transform
  75280. * @param result defines the target vector2 where to store the result
  75281. * @returns the current control
  75282. */
  75283. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75284. /**
  75285. * Gets coordinates in parent local control space
  75286. * @param globalCoordinates defines the coordinates to transform
  75287. * @returns the new coordinates in parent local space
  75288. */
  75289. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75290. /**
  75291. * Move the current control to a vector3 position projected onto the screen.
  75292. * @param position defines the target position
  75293. * @param scene defines the hosting scene
  75294. */
  75295. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75296. /**
  75297. * Will store all controls that have this control as ascendant in a given array
  75298. * @param results defines the array where to store the descendants
  75299. * @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
  75300. * @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
  75301. */
  75302. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75303. /**
  75304. * Will return all controls that have this control as ascendant
  75305. * @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
  75306. * @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
  75307. * @return all child controls
  75308. */
  75309. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75310. /**
  75311. * Link current control with a target mesh
  75312. * @param mesh defines the mesh to link with
  75313. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75314. */
  75315. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75316. /** @hidden */
  75317. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75318. /** @hidden */
  75319. _offsetLeft(offset: number): void;
  75320. /** @hidden */
  75321. _offsetTop(offset: number): void;
  75322. /** @hidden */
  75323. _markMatrixAsDirty(): void;
  75324. /** @hidden */
  75325. _flagDescendantsAsMatrixDirty(): void;
  75326. /** @hidden */
  75327. _intersectsRect(rect: Measure): boolean;
  75328. /** @hidden */
  75329. protected invalidateRect(): void;
  75330. /** @hidden */
  75331. _markAsDirty(force?: boolean): void;
  75332. /** @hidden */
  75333. _markAllAsDirty(): void;
  75334. /** @hidden */
  75335. _link(host: AdvancedDynamicTexture): void;
  75336. /** @hidden */
  75337. protected _transform(context?: CanvasRenderingContext2D): void;
  75338. /** @hidden */
  75339. _renderHighlight(context: CanvasRenderingContext2D): void;
  75340. /** @hidden */
  75341. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75342. /** @hidden */
  75343. protected _applyStates(context: CanvasRenderingContext2D): void;
  75344. /** @hidden */
  75345. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75346. /** @hidden */
  75347. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75348. protected _evaluateClippingState(parentMeasure: Measure): void;
  75349. /** @hidden */
  75350. _measure(): void;
  75351. /** @hidden */
  75352. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75353. /** @hidden */
  75354. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75355. /** @hidden */
  75356. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75357. /** @hidden */
  75358. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75359. private static _ClipMeasure;
  75360. private _tmpMeasureA;
  75361. private _clip;
  75362. /** @hidden */
  75363. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75364. /** @hidden */
  75365. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75366. /**
  75367. * Tests if a given coordinates belong to the current control
  75368. * @param x defines x coordinate to test
  75369. * @param y defines y coordinate to test
  75370. * @returns true if the coordinates are inside the control
  75371. */
  75372. contains(x: number, y: number): boolean;
  75373. /** @hidden */
  75374. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75375. /** @hidden */
  75376. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75377. /** @hidden */
  75378. _onPointerEnter(target: Control): boolean;
  75379. /** @hidden */
  75380. _onPointerOut(target: Control, force?: boolean): void;
  75381. /** @hidden */
  75382. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75383. /** @hidden */
  75384. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75385. /** @hidden */
  75386. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75387. /** @hidden */
  75388. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75389. /** @hidden */
  75390. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75391. private _prepareFont;
  75392. /** Releases associated resources */
  75393. dispose(): void;
  75394. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75395. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75396. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75397. private static _VERTICAL_ALIGNMENT_TOP;
  75398. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75399. private static _VERTICAL_ALIGNMENT_CENTER;
  75400. /** HORIZONTAL_ALIGNMENT_LEFT */
  75401. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75402. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75403. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75404. /** HORIZONTAL_ALIGNMENT_CENTER */
  75405. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75406. /** VERTICAL_ALIGNMENT_TOP */
  75407. static get VERTICAL_ALIGNMENT_TOP(): number;
  75408. /** VERTICAL_ALIGNMENT_BOTTOM */
  75409. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75410. /** VERTICAL_ALIGNMENT_CENTER */
  75411. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75412. private static _FontHeightSizes;
  75413. /** @hidden */
  75414. static _GetFontOffset(font: string): {
  75415. ascent: number;
  75416. height: number;
  75417. descent: number;
  75418. };
  75419. /**
  75420. * Creates a stack panel that can be used to render headers
  75421. * @param control defines the control to associate with the header
  75422. * @param text defines the text of the header
  75423. * @param size defines the size of the header
  75424. * @param options defines options used to configure the header
  75425. * @returns a new StackPanel
  75426. * @ignore
  75427. * @hidden
  75428. */
  75429. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75430. isHorizontal: boolean;
  75431. controlFirst: boolean;
  75432. }) => any;
  75433. /** @hidden */
  75434. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75435. }
  75436. }
  75437. declare module BABYLON.GUI {
  75438. /**
  75439. * Root class for 2D containers
  75440. * @see http://doc.babylonjs.com/how_to/gui#containers
  75441. */
  75442. export class Container extends Control {
  75443. name?: string | undefined;
  75444. /** @hidden */
  75445. _children: Control[];
  75446. /** @hidden */
  75447. protected _measureForChildren: Measure;
  75448. /** @hidden */
  75449. protected _background: string;
  75450. /** @hidden */
  75451. protected _adaptWidthToChildren: boolean;
  75452. /** @hidden */
  75453. protected _adaptHeightToChildren: boolean;
  75454. /**
  75455. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75456. */
  75457. logLayoutCycleErrors: boolean;
  75458. /**
  75459. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75460. */
  75461. maxLayoutCycle: number;
  75462. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75463. get adaptHeightToChildren(): boolean;
  75464. set adaptHeightToChildren(value: boolean);
  75465. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75466. get adaptWidthToChildren(): boolean;
  75467. set adaptWidthToChildren(value: boolean);
  75468. /** Gets or sets background color */
  75469. get background(): string;
  75470. set background(value: string);
  75471. /** Gets the list of children */
  75472. get children(): Control[];
  75473. /**
  75474. * Creates a new Container
  75475. * @param name defines the name of the container
  75476. */
  75477. constructor(name?: string | undefined);
  75478. protected _getTypeName(): string;
  75479. _flagDescendantsAsMatrixDirty(): void;
  75480. /**
  75481. * Gets a child using its name
  75482. * @param name defines the child name to look for
  75483. * @returns the child control if found
  75484. */
  75485. getChildByName(name: string): BABYLON.Nullable<Control>;
  75486. /**
  75487. * Gets a child using its type and its name
  75488. * @param name defines the child name to look for
  75489. * @param type defines the child type to look for
  75490. * @returns the child control if found
  75491. */
  75492. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75493. /**
  75494. * Search for a specific control in children
  75495. * @param control defines the control to look for
  75496. * @returns true if the control is in child list
  75497. */
  75498. containsControl(control: Control): boolean;
  75499. /**
  75500. * Adds a new control to the current container
  75501. * @param control defines the control to add
  75502. * @returns the current container
  75503. */
  75504. addControl(control: BABYLON.Nullable<Control>): Container;
  75505. /**
  75506. * Removes all controls from the current container
  75507. * @returns the current container
  75508. */
  75509. clearControls(): Container;
  75510. /**
  75511. * Removes a control from the current container
  75512. * @param control defines the control to remove
  75513. * @returns the current container
  75514. */
  75515. removeControl(control: Control): Container;
  75516. /** @hidden */
  75517. _reOrderControl(control: Control): void;
  75518. /** @hidden */
  75519. _offsetLeft(offset: number): void;
  75520. /** @hidden */
  75521. _offsetTop(offset: number): void;
  75522. /** @hidden */
  75523. _markAllAsDirty(): void;
  75524. /** @hidden */
  75525. protected _localDraw(context: CanvasRenderingContext2D): void;
  75526. /** @hidden */
  75527. _link(host: AdvancedDynamicTexture): void;
  75528. /** @hidden */
  75529. protected _beforeLayout(): void;
  75530. /** @hidden */
  75531. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75532. /** @hidden */
  75533. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75534. protected _postMeasure(): void;
  75535. /** @hidden */
  75536. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75537. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75538. /** @hidden */
  75539. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75540. /** @hidden */
  75541. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75542. /** Releases associated resources */
  75543. dispose(): void;
  75544. }
  75545. }
  75546. declare module BABYLON.GUI {
  75547. /** Class used to create rectangle container */
  75548. export class Rectangle extends Container {
  75549. name?: string | undefined;
  75550. private _thickness;
  75551. private _cornerRadius;
  75552. /** Gets or sets border thickness */
  75553. get thickness(): number;
  75554. set thickness(value: number);
  75555. /** Gets or sets the corner radius angle */
  75556. get cornerRadius(): number;
  75557. set cornerRadius(value: number);
  75558. /**
  75559. * Creates a new Rectangle
  75560. * @param name defines the control name
  75561. */
  75562. constructor(name?: string | undefined);
  75563. protected _getTypeName(): string;
  75564. protected _localDraw(context: CanvasRenderingContext2D): void;
  75565. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75566. private _drawRoundedRect;
  75567. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75568. }
  75569. }
  75570. declare module BABYLON.GUI {
  75571. /**
  75572. * Enum that determines the text-wrapping mode to use.
  75573. */
  75574. export enum TextWrapping {
  75575. /**
  75576. * Clip the text when it's larger than Control.width; this is the default mode.
  75577. */
  75578. Clip = 0,
  75579. /**
  75580. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75581. */
  75582. WordWrap = 1,
  75583. /**
  75584. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75585. */
  75586. Ellipsis = 2
  75587. }
  75588. /**
  75589. * Class used to create text block control
  75590. */
  75591. export class TextBlock extends Control {
  75592. /**
  75593. * Defines the name of the control
  75594. */
  75595. name?: string | undefined;
  75596. private _text;
  75597. private _textWrapping;
  75598. private _textHorizontalAlignment;
  75599. private _textVerticalAlignment;
  75600. private _lines;
  75601. private _resizeToFit;
  75602. private _lineSpacing;
  75603. private _outlineWidth;
  75604. private _outlineColor;
  75605. /**
  75606. * An event triggered after the text is changed
  75607. */
  75608. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75609. /**
  75610. * An event triggered after the text was broken up into lines
  75611. */
  75612. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75613. /**
  75614. * Function used to split a string into words. By default, a string is split at each space character found
  75615. */
  75616. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75617. /**
  75618. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75619. */
  75620. get lines(): any[];
  75621. /**
  75622. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75623. */
  75624. get resizeToFit(): boolean;
  75625. /**
  75626. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75627. */
  75628. set resizeToFit(value: boolean);
  75629. /**
  75630. * Gets or sets a boolean indicating if text must be wrapped
  75631. */
  75632. get textWrapping(): TextWrapping | boolean;
  75633. /**
  75634. * Gets or sets a boolean indicating if text must be wrapped
  75635. */
  75636. set textWrapping(value: TextWrapping | boolean);
  75637. /**
  75638. * Gets or sets text to display
  75639. */
  75640. get text(): string;
  75641. /**
  75642. * Gets or sets text to display
  75643. */
  75644. set text(value: string);
  75645. /**
  75646. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75647. */
  75648. get textHorizontalAlignment(): number;
  75649. /**
  75650. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75651. */
  75652. set textHorizontalAlignment(value: number);
  75653. /**
  75654. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75655. */
  75656. get textVerticalAlignment(): number;
  75657. /**
  75658. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75659. */
  75660. set textVerticalAlignment(value: number);
  75661. /**
  75662. * Gets or sets line spacing value
  75663. */
  75664. set lineSpacing(value: string | number);
  75665. /**
  75666. * Gets or sets line spacing value
  75667. */
  75668. get lineSpacing(): string | number;
  75669. /**
  75670. * Gets or sets outlineWidth of the text to display
  75671. */
  75672. get outlineWidth(): number;
  75673. /**
  75674. * Gets or sets outlineWidth of the text to display
  75675. */
  75676. set outlineWidth(value: number);
  75677. /**
  75678. * Gets or sets outlineColor of the text to display
  75679. */
  75680. get outlineColor(): string;
  75681. /**
  75682. * Gets or sets outlineColor of the text to display
  75683. */
  75684. set outlineColor(value: string);
  75685. /**
  75686. * Creates a new TextBlock object
  75687. * @param name defines the name of the control
  75688. * @param text defines the text to display (emptry string by default)
  75689. */
  75690. constructor(
  75691. /**
  75692. * Defines the name of the control
  75693. */
  75694. name?: string | undefined, text?: string);
  75695. protected _getTypeName(): string;
  75696. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75697. private _drawText;
  75698. /** @hidden */
  75699. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75700. protected _applyStates(context: CanvasRenderingContext2D): void;
  75701. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75702. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75703. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75704. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75705. protected _renderLines(context: CanvasRenderingContext2D): void;
  75706. /**
  75707. * Given a width constraint applied on the text block, find the expected height
  75708. * @returns expected height
  75709. */
  75710. computeExpectedHeight(): number;
  75711. dispose(): void;
  75712. }
  75713. }
  75714. declare module BABYLON.GUI {
  75715. /**
  75716. * Class used to create 2D images
  75717. */
  75718. export class Image extends Control {
  75719. name?: string | undefined;
  75720. private _workingCanvas;
  75721. private _domImage;
  75722. private _imageWidth;
  75723. private _imageHeight;
  75724. private _loaded;
  75725. private _stretch;
  75726. private _source;
  75727. private _autoScale;
  75728. private _sourceLeft;
  75729. private _sourceTop;
  75730. private _sourceWidth;
  75731. private _sourceHeight;
  75732. private _svgAttributesComputationCompleted;
  75733. private _isSVG;
  75734. private _cellWidth;
  75735. private _cellHeight;
  75736. private _cellId;
  75737. private _populateNinePatchSlicesFromImage;
  75738. private _sliceLeft;
  75739. private _sliceRight;
  75740. private _sliceTop;
  75741. private _sliceBottom;
  75742. private _detectPointerOnOpaqueOnly;
  75743. /**
  75744. * BABYLON.Observable notified when the content is loaded
  75745. */
  75746. onImageLoadedObservable: BABYLON.Observable<Image>;
  75747. /**
  75748. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75749. */
  75750. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75751. /**
  75752. * Gets a boolean indicating that the content is loaded
  75753. */
  75754. get isLoaded(): boolean;
  75755. /**
  75756. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75757. */
  75758. get populateNinePatchSlicesFromImage(): boolean;
  75759. set populateNinePatchSlicesFromImage(value: boolean);
  75760. /**
  75761. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75762. * Beware using this as this will comsume more memory as the image has to be stored twice
  75763. */
  75764. get detectPointerOnOpaqueOnly(): boolean;
  75765. set detectPointerOnOpaqueOnly(value: boolean);
  75766. /**
  75767. * Gets or sets the left value for slicing (9-patch)
  75768. */
  75769. get sliceLeft(): number;
  75770. set sliceLeft(value: number);
  75771. /**
  75772. * Gets or sets the right value for slicing (9-patch)
  75773. */
  75774. get sliceRight(): number;
  75775. set sliceRight(value: number);
  75776. /**
  75777. * Gets or sets the top value for slicing (9-patch)
  75778. */
  75779. get sliceTop(): number;
  75780. set sliceTop(value: number);
  75781. /**
  75782. * Gets or sets the bottom value for slicing (9-patch)
  75783. */
  75784. get sliceBottom(): number;
  75785. set sliceBottom(value: number);
  75786. /**
  75787. * Gets or sets the left coordinate in the source image
  75788. */
  75789. get sourceLeft(): number;
  75790. set sourceLeft(value: number);
  75791. /**
  75792. * Gets or sets the top coordinate in the source image
  75793. */
  75794. get sourceTop(): number;
  75795. set sourceTop(value: number);
  75796. /**
  75797. * Gets or sets the width to capture in the source image
  75798. */
  75799. get sourceWidth(): number;
  75800. set sourceWidth(value: number);
  75801. /**
  75802. * Gets or sets the height to capture in the source image
  75803. */
  75804. get sourceHeight(): number;
  75805. set sourceHeight(value: number);
  75806. /** Indicates if the format of the image is SVG */
  75807. get isSVG(): boolean;
  75808. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75809. get svgAttributesComputationCompleted(): boolean;
  75810. /**
  75811. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75812. * @see http://doc.babylonjs.com/how_to/gui#image
  75813. */
  75814. get autoScale(): boolean;
  75815. set autoScale(value: boolean);
  75816. /** Gets or sets the streching mode used by the image */
  75817. get stretch(): number;
  75818. set stretch(value: number);
  75819. /** @hidden */
  75820. _rotate90(n: number, preserveProperties?: boolean): Image;
  75821. private _handleRotationForSVGImage;
  75822. private _rotate90SourceProperties;
  75823. /**
  75824. * Gets or sets the internal DOM image used to render the control
  75825. */
  75826. set domImage(value: HTMLImageElement);
  75827. get domImage(): HTMLImageElement;
  75828. private _onImageLoaded;
  75829. private _extractNinePatchSliceDataFromImage;
  75830. /**
  75831. * Gets or sets image source url
  75832. */
  75833. set source(value: BABYLON.Nullable<string>);
  75834. /**
  75835. * Checks for svg document with icon id present
  75836. */
  75837. private _svgCheck;
  75838. /**
  75839. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75840. * given external svg file and icon id
  75841. */
  75842. private _getSVGAttribs;
  75843. /**
  75844. * Gets or sets the cell width to use when animation sheet is enabled
  75845. * @see http://doc.babylonjs.com/how_to/gui#image
  75846. */
  75847. get cellWidth(): number;
  75848. set cellWidth(value: number);
  75849. /**
  75850. * Gets or sets the cell height to use when animation sheet is enabled
  75851. * @see http://doc.babylonjs.com/how_to/gui#image
  75852. */
  75853. get cellHeight(): number;
  75854. set cellHeight(value: number);
  75855. /**
  75856. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75857. * @see http://doc.babylonjs.com/how_to/gui#image
  75858. */
  75859. get cellId(): number;
  75860. set cellId(value: number);
  75861. /**
  75862. * Creates a new Image
  75863. * @param name defines the control name
  75864. * @param url defines the image url
  75865. */
  75866. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75867. /**
  75868. * Tests if a given coordinates belong to the current control
  75869. * @param x defines x coordinate to test
  75870. * @param y defines y coordinate to test
  75871. * @returns true if the coordinates are inside the control
  75872. */
  75873. contains(x: number, y: number): boolean;
  75874. protected _getTypeName(): string;
  75875. /** Force the control to synchronize with its content */
  75876. synchronizeSizeWithContent(): void;
  75877. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75878. private _prepareWorkingCanvasForOpaqueDetection;
  75879. private _drawImage;
  75880. _draw(context: CanvasRenderingContext2D): void;
  75881. private _renderCornerPatch;
  75882. private _renderNinePatch;
  75883. dispose(): void;
  75884. /** STRETCH_NONE */
  75885. static readonly STRETCH_NONE: number;
  75886. /** STRETCH_FILL */
  75887. static readonly STRETCH_FILL: number;
  75888. /** STRETCH_UNIFORM */
  75889. static readonly STRETCH_UNIFORM: number;
  75890. /** STRETCH_EXTEND */
  75891. static readonly STRETCH_EXTEND: number;
  75892. /** NINE_PATCH */
  75893. static readonly STRETCH_NINE_PATCH: number;
  75894. }
  75895. }
  75896. declare module BABYLON.GUI {
  75897. /**
  75898. * Class used to create 2D buttons
  75899. */
  75900. export class Button extends Rectangle {
  75901. name?: string | undefined;
  75902. /**
  75903. * Function called to generate a pointer enter animation
  75904. */
  75905. pointerEnterAnimation: () => void;
  75906. /**
  75907. * Function called to generate a pointer out animation
  75908. */
  75909. pointerOutAnimation: () => void;
  75910. /**
  75911. * Function called to generate a pointer down animation
  75912. */
  75913. pointerDownAnimation: () => void;
  75914. /**
  75915. * Function called to generate a pointer up animation
  75916. */
  75917. pointerUpAnimation: () => void;
  75918. /**
  75919. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75920. */
  75921. delegatePickingToChildren: boolean;
  75922. private _image;
  75923. /**
  75924. * Returns the image part of the button (if any)
  75925. */
  75926. get image(): BABYLON.Nullable<Image>;
  75927. private _textBlock;
  75928. /**
  75929. * Returns the image part of the button (if any)
  75930. */
  75931. get textBlock(): BABYLON.Nullable<TextBlock>;
  75932. /**
  75933. * Creates a new Button
  75934. * @param name defines the name of the button
  75935. */
  75936. constructor(name?: string | undefined);
  75937. protected _getTypeName(): string;
  75938. /** @hidden */
  75939. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75940. /** @hidden */
  75941. _onPointerEnter(target: Control): boolean;
  75942. /** @hidden */
  75943. _onPointerOut(target: Control, force?: boolean): void;
  75944. /** @hidden */
  75945. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75946. /** @hidden */
  75947. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75948. /**
  75949. * Creates a new button made with an image and a text
  75950. * @param name defines the name of the button
  75951. * @param text defines the text of the button
  75952. * @param imageUrl defines the url of the image
  75953. * @returns a new Button
  75954. */
  75955. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75956. /**
  75957. * Creates a new button made with an image
  75958. * @param name defines the name of the button
  75959. * @param imageUrl defines the url of the image
  75960. * @returns a new Button
  75961. */
  75962. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75963. /**
  75964. * Creates a new button made with a text
  75965. * @param name defines the name of the button
  75966. * @param text defines the text of the button
  75967. * @returns a new Button
  75968. */
  75969. static CreateSimpleButton(name: string, text: string): Button;
  75970. /**
  75971. * Creates a new button made with an image and a centered text
  75972. * @param name defines the name of the button
  75973. * @param text defines the text of the button
  75974. * @param imageUrl defines the url of the image
  75975. * @returns a new Button
  75976. */
  75977. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75978. }
  75979. }
  75980. declare module BABYLON.GUI {
  75981. /**
  75982. * Class used to create a 2D stack panel container
  75983. */
  75984. export class StackPanel extends Container {
  75985. name?: string | undefined;
  75986. private _isVertical;
  75987. private _manualWidth;
  75988. private _manualHeight;
  75989. private _doNotTrackManualChanges;
  75990. /**
  75991. * Gets or sets a boolean indicating that layou warnings should be ignored
  75992. */
  75993. ignoreLayoutWarnings: boolean;
  75994. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75995. get isVertical(): boolean;
  75996. set isVertical(value: boolean);
  75997. /**
  75998. * Gets or sets panel width.
  75999. * This value should not be set when in horizontal mode as it will be computed automatically
  76000. */
  76001. set width(value: string | number);
  76002. get width(): string | number;
  76003. /**
  76004. * Gets or sets panel height.
  76005. * This value should not be set when in vertical mode as it will be computed automatically
  76006. */
  76007. set height(value: string | number);
  76008. get height(): string | number;
  76009. /**
  76010. * Creates a new StackPanel
  76011. * @param name defines control name
  76012. */
  76013. constructor(name?: string | undefined);
  76014. protected _getTypeName(): string;
  76015. /** @hidden */
  76016. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76017. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76018. protected _postMeasure(): void;
  76019. }
  76020. }
  76021. declare module BABYLON.GUI {
  76022. /**
  76023. * Class used to represent a 2D checkbox
  76024. */
  76025. export class Checkbox extends Control {
  76026. name?: string | undefined;
  76027. private _isChecked;
  76028. private _background;
  76029. private _checkSizeRatio;
  76030. private _thickness;
  76031. /** Gets or sets border thickness */
  76032. get thickness(): number;
  76033. set thickness(value: number);
  76034. /**
  76035. * BABYLON.Observable raised when isChecked property changes
  76036. */
  76037. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76038. /** Gets or sets a value indicating the ratio between overall size and check size */
  76039. get checkSizeRatio(): number;
  76040. set checkSizeRatio(value: number);
  76041. /** Gets or sets background color */
  76042. get background(): string;
  76043. set background(value: string);
  76044. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76045. get isChecked(): boolean;
  76046. set isChecked(value: boolean);
  76047. /**
  76048. * Creates a new CheckBox
  76049. * @param name defines the control name
  76050. */
  76051. constructor(name?: string | undefined);
  76052. protected _getTypeName(): string;
  76053. /** @hidden */
  76054. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76055. /** @hidden */
  76056. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76057. /**
  76058. * Utility function to easily create a checkbox with a header
  76059. * @param title defines the label to use for the header
  76060. * @param onValueChanged defines the callback to call when value changes
  76061. * @returns a StackPanel containing the checkbox and a textBlock
  76062. */
  76063. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76064. }
  76065. }
  76066. declare module BABYLON.GUI {
  76067. /**
  76068. * Class used to store key control properties
  76069. */
  76070. export class KeyPropertySet {
  76071. /** Width */
  76072. width?: string;
  76073. /** Height */
  76074. height?: string;
  76075. /** Left padding */
  76076. paddingLeft?: string;
  76077. /** Right padding */
  76078. paddingRight?: string;
  76079. /** Top padding */
  76080. paddingTop?: string;
  76081. /** Bottom padding */
  76082. paddingBottom?: string;
  76083. /** Foreground color */
  76084. color?: string;
  76085. /** Background color */
  76086. background?: string;
  76087. }
  76088. /**
  76089. * Class used to create virtual keyboard
  76090. */
  76091. export class VirtualKeyboard extends StackPanel {
  76092. /** BABYLON.Observable raised when a key is pressed */
  76093. onKeyPressObservable: BABYLON.Observable<string>;
  76094. /** Gets or sets default key button width */
  76095. defaultButtonWidth: string;
  76096. /** Gets or sets default key button height */
  76097. defaultButtonHeight: string;
  76098. /** Gets or sets default key button left padding */
  76099. defaultButtonPaddingLeft: string;
  76100. /** Gets or sets default key button right padding */
  76101. defaultButtonPaddingRight: string;
  76102. /** Gets or sets default key button top padding */
  76103. defaultButtonPaddingTop: string;
  76104. /** Gets or sets default key button bottom padding */
  76105. defaultButtonPaddingBottom: string;
  76106. /** Gets or sets default key button foreground color */
  76107. defaultButtonColor: string;
  76108. /** Gets or sets default key button background color */
  76109. defaultButtonBackground: string;
  76110. /** Gets or sets shift button foreground color */
  76111. shiftButtonColor: string;
  76112. /** Gets or sets shift button thickness*/
  76113. selectedShiftThickness: number;
  76114. /** Gets shift key state */
  76115. shiftState: number;
  76116. protected _getTypeName(): string;
  76117. private _createKey;
  76118. /**
  76119. * Adds a new row of keys
  76120. * @param keys defines the list of keys to add
  76121. * @param propertySets defines the associated property sets
  76122. */
  76123. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76124. /**
  76125. * Set the shift key to a specific state
  76126. * @param shiftState defines the new shift state
  76127. */
  76128. applyShiftState(shiftState: number): void;
  76129. private _currentlyConnectedInputText;
  76130. private _connectedInputTexts;
  76131. private _onKeyPressObserver;
  76132. /** Gets the input text control currently attached to the keyboard */
  76133. get connectedInputText(): BABYLON.Nullable<InputText>;
  76134. /**
  76135. * Connects the keyboard with an input text control
  76136. *
  76137. * @param input defines the target control
  76138. */
  76139. connect(input: InputText): void;
  76140. /**
  76141. * Disconnects the keyboard from connected InputText controls
  76142. *
  76143. * @param input optionally defines a target control, otherwise all are disconnected
  76144. */
  76145. disconnect(input?: InputText): void;
  76146. private _removeConnectedInputObservables;
  76147. /**
  76148. * Release all resources
  76149. */
  76150. dispose(): void;
  76151. /**
  76152. * Creates a new keyboard using a default layout
  76153. *
  76154. * @param name defines control name
  76155. * @returns a new VirtualKeyboard
  76156. */
  76157. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76158. }
  76159. }
  76160. declare module BABYLON.GUI {
  76161. /**
  76162. * Class used to create input text control
  76163. */
  76164. export class InputText extends Control implements IFocusableControl {
  76165. name?: string | undefined;
  76166. private _text;
  76167. private _placeholderText;
  76168. private _background;
  76169. private _focusedBackground;
  76170. private _focusedColor;
  76171. private _placeholderColor;
  76172. private _thickness;
  76173. private _margin;
  76174. private _autoStretchWidth;
  76175. private _maxWidth;
  76176. private _isFocused;
  76177. private _blinkTimeout;
  76178. private _blinkIsEven;
  76179. private _cursorOffset;
  76180. private _scrollLeft;
  76181. private _textWidth;
  76182. private _clickedCoordinate;
  76183. private _deadKey;
  76184. private _addKey;
  76185. private _currentKey;
  76186. private _isTextHighlightOn;
  76187. private _textHighlightColor;
  76188. private _highligherOpacity;
  76189. private _highlightedText;
  76190. private _startHighlightIndex;
  76191. private _endHighlightIndex;
  76192. private _cursorIndex;
  76193. private _onFocusSelectAll;
  76194. private _isPointerDown;
  76195. private _onClipboardObserver;
  76196. private _onPointerDblTapObserver;
  76197. /** @hidden */
  76198. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76199. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76200. promptMessage: string;
  76201. /** Force disable prompt on mobile device */
  76202. disableMobilePrompt: boolean;
  76203. /** BABYLON.Observable raised when the text changes */
  76204. onTextChangedObservable: BABYLON.Observable<InputText>;
  76205. /** BABYLON.Observable raised just before an entered character is to be added */
  76206. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76207. /** BABYLON.Observable raised when the control gets the focus */
  76208. onFocusObservable: BABYLON.Observable<InputText>;
  76209. /** BABYLON.Observable raised when the control loses the focus */
  76210. onBlurObservable: BABYLON.Observable<InputText>;
  76211. /**Observable raised when the text is highlighted */
  76212. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76213. /**Observable raised when copy event is triggered */
  76214. onTextCopyObservable: BABYLON.Observable<InputText>;
  76215. /** BABYLON.Observable raised when cut event is triggered */
  76216. onTextCutObservable: BABYLON.Observable<InputText>;
  76217. /** BABYLON.Observable raised when paste event is triggered */
  76218. onTextPasteObservable: BABYLON.Observable<InputText>;
  76219. /** BABYLON.Observable raised when a key event was processed */
  76220. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76221. /** Gets or sets the maximum width allowed by the control */
  76222. get maxWidth(): string | number;
  76223. /** Gets the maximum width allowed by the control in pixels */
  76224. get maxWidthInPixels(): number;
  76225. set maxWidth(value: string | number);
  76226. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76227. get highligherOpacity(): number;
  76228. set highligherOpacity(value: number);
  76229. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76230. get onFocusSelectAll(): boolean;
  76231. set onFocusSelectAll(value: boolean);
  76232. /** Gets or sets the text hightlight color */
  76233. get textHighlightColor(): string;
  76234. set textHighlightColor(value: string);
  76235. /** Gets or sets control margin */
  76236. get margin(): string;
  76237. /** Gets control margin in pixels */
  76238. get marginInPixels(): number;
  76239. set margin(value: string);
  76240. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76241. get autoStretchWidth(): boolean;
  76242. set autoStretchWidth(value: boolean);
  76243. /** Gets or sets border thickness */
  76244. get thickness(): number;
  76245. set thickness(value: number);
  76246. /** Gets or sets the background color when focused */
  76247. get focusedBackground(): string;
  76248. set focusedBackground(value: string);
  76249. /** Gets or sets the background color when focused */
  76250. get focusedColor(): string;
  76251. set focusedColor(value: string);
  76252. /** Gets or sets the background color */
  76253. get background(): string;
  76254. set background(value: string);
  76255. /** Gets or sets the placeholder color */
  76256. get placeholderColor(): string;
  76257. set placeholderColor(value: string);
  76258. /** Gets or sets the text displayed when the control is empty */
  76259. get placeholderText(): string;
  76260. set placeholderText(value: string);
  76261. /** Gets or sets the dead key flag */
  76262. get deadKey(): boolean;
  76263. set deadKey(flag: boolean);
  76264. /** Gets or sets the highlight text */
  76265. get highlightedText(): string;
  76266. set highlightedText(text: string);
  76267. /** Gets or sets if the current key should be added */
  76268. get addKey(): boolean;
  76269. set addKey(flag: boolean);
  76270. /** Gets or sets the value of the current key being entered */
  76271. get currentKey(): string;
  76272. set currentKey(key: string);
  76273. /** Gets or sets the text displayed in the control */
  76274. get text(): string;
  76275. set text(value: string);
  76276. /** Gets or sets control width */
  76277. get width(): string | number;
  76278. set width(value: string | number);
  76279. /**
  76280. * Creates a new InputText
  76281. * @param name defines the control name
  76282. * @param text defines the text of the control
  76283. */
  76284. constructor(name?: string | undefined, text?: string);
  76285. /** @hidden */
  76286. onBlur(): void;
  76287. /** @hidden */
  76288. onFocus(): void;
  76289. protected _getTypeName(): string;
  76290. /**
  76291. * Function called to get the list of controls that should not steal the focus from this control
  76292. * @returns an array of controls
  76293. */
  76294. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76295. /** @hidden */
  76296. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76297. /** @hidden */
  76298. private _updateValueFromCursorIndex;
  76299. /** @hidden */
  76300. private _processDblClick;
  76301. /** @hidden */
  76302. private _selectAllText;
  76303. /**
  76304. * Handles the keyboard event
  76305. * @param evt Defines the KeyboardEvent
  76306. */
  76307. processKeyboard(evt: KeyboardEvent): void;
  76308. /** @hidden */
  76309. private _onCopyText;
  76310. /** @hidden */
  76311. private _onCutText;
  76312. /** @hidden */
  76313. private _onPasteText;
  76314. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76315. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76316. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76317. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76318. protected _beforeRenderText(text: string): string;
  76319. dispose(): void;
  76320. }
  76321. }
  76322. declare module BABYLON.GUI {
  76323. /**
  76324. * Class used to create a 2D grid container
  76325. */
  76326. export class Grid extends Container {
  76327. name?: string | undefined;
  76328. private _rowDefinitions;
  76329. private _columnDefinitions;
  76330. private _cells;
  76331. private _childControls;
  76332. /**
  76333. * Gets the number of columns
  76334. */
  76335. get columnCount(): number;
  76336. /**
  76337. * Gets the number of rows
  76338. */
  76339. get rowCount(): number;
  76340. /** Gets the list of children */
  76341. get children(): Control[];
  76342. /** Gets the list of cells (e.g. the containers) */
  76343. get cells(): {
  76344. [key: string]: Container;
  76345. };
  76346. /**
  76347. * Gets the definition of a specific row
  76348. * @param index defines the index of the row
  76349. * @returns the row definition
  76350. */
  76351. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76352. /**
  76353. * Gets the definition of a specific column
  76354. * @param index defines the index of the column
  76355. * @returns the column definition
  76356. */
  76357. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76358. /**
  76359. * Adds a new row to the grid
  76360. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76361. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76362. * @returns the current grid
  76363. */
  76364. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76365. /**
  76366. * Adds a new column to the grid
  76367. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76368. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76369. * @returns the current grid
  76370. */
  76371. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76372. /**
  76373. * Update a row definition
  76374. * @param index defines the index of the row to update
  76375. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76376. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76377. * @returns the current grid
  76378. */
  76379. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76380. /**
  76381. * Update a column definition
  76382. * @param index defines the index of the column to update
  76383. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76384. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76385. * @returns the current grid
  76386. */
  76387. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76388. /**
  76389. * Gets the list of children stored in a specific cell
  76390. * @param row defines the row to check
  76391. * @param column defines the column to check
  76392. * @returns the list of controls
  76393. */
  76394. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76395. /**
  76396. * Gets a string representing the child cell info (row x column)
  76397. * @param child defines the control to get info from
  76398. * @returns a string containing the child cell info (row x column)
  76399. */
  76400. getChildCellInfo(child: Control): string;
  76401. private _removeCell;
  76402. private _offsetCell;
  76403. /**
  76404. * Remove a column definition at specified index
  76405. * @param index defines the index of the column to remove
  76406. * @returns the current grid
  76407. */
  76408. removeColumnDefinition(index: number): Grid;
  76409. /**
  76410. * Remove a row definition at specified index
  76411. * @param index defines the index of the row to remove
  76412. * @returns the current grid
  76413. */
  76414. removeRowDefinition(index: number): Grid;
  76415. /**
  76416. * Adds a new control to the current grid
  76417. * @param control defines the control to add
  76418. * @param row defines the row where to add the control (0 by default)
  76419. * @param column defines the column where to add the control (0 by default)
  76420. * @returns the current grid
  76421. */
  76422. addControl(control: Control, row?: number, column?: number): Grid;
  76423. /**
  76424. * Removes a control from the current container
  76425. * @param control defines the control to remove
  76426. * @returns the current container
  76427. */
  76428. removeControl(control: Control): Container;
  76429. /**
  76430. * Creates a new Grid
  76431. * @param name defines control name
  76432. */
  76433. constructor(name?: string | undefined);
  76434. protected _getTypeName(): string;
  76435. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76436. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76437. _flagDescendantsAsMatrixDirty(): void;
  76438. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76439. /** Releases associated resources */
  76440. dispose(): void;
  76441. }
  76442. }
  76443. declare module BABYLON.GUI {
  76444. /** Class used to create color pickers */
  76445. export class ColorPicker extends Control {
  76446. name?: string | undefined;
  76447. private static _Epsilon;
  76448. private _colorWheelCanvas;
  76449. private _value;
  76450. private _tmpColor;
  76451. private _pointerStartedOnSquare;
  76452. private _pointerStartedOnWheel;
  76453. private _squareLeft;
  76454. private _squareTop;
  76455. private _squareSize;
  76456. private _h;
  76457. private _s;
  76458. private _v;
  76459. private _lastPointerDownID;
  76460. /**
  76461. * BABYLON.Observable raised when the value changes
  76462. */
  76463. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76464. /** Gets or sets the color of the color picker */
  76465. get value(): BABYLON.Color3;
  76466. set value(value: BABYLON.Color3);
  76467. /**
  76468. * Gets or sets control width
  76469. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76470. */
  76471. get width(): string | number;
  76472. set width(value: string | number);
  76473. /**
  76474. * Gets or sets control height
  76475. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76476. */
  76477. get height(): string | number;
  76478. /** Gets or sets control height */
  76479. set height(value: string | number);
  76480. /** Gets or sets control size */
  76481. get size(): string | number;
  76482. set size(value: string | number);
  76483. /**
  76484. * Creates a new ColorPicker
  76485. * @param name defines the control name
  76486. */
  76487. constructor(name?: string | undefined);
  76488. protected _getTypeName(): string;
  76489. /** @hidden */
  76490. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76491. private _updateSquareProps;
  76492. private _drawGradientSquare;
  76493. private _drawCircle;
  76494. private _createColorWheelCanvas;
  76495. /** @hidden */
  76496. _draw(context: CanvasRenderingContext2D): void;
  76497. private _pointerIsDown;
  76498. private _updateValueFromPointer;
  76499. private _isPointOnSquare;
  76500. private _isPointOnWheel;
  76501. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76502. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76503. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76504. /**
  76505. * This function expands the color picker by creating a color picker dialog with manual
  76506. * color value input and the ability to save colors into an array to be used later in
  76507. * subsequent launches of the dialogue.
  76508. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76509. * @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.
  76510. * @returns picked color as a hex string and the saved colors array as hex strings.
  76511. */
  76512. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76513. pickerWidth?: string;
  76514. pickerHeight?: string;
  76515. headerHeight?: string;
  76516. lastColor?: string;
  76517. swatchLimit?: number;
  76518. numSwatchesPerLine?: number;
  76519. savedColors?: Array<string>;
  76520. }): Promise<{
  76521. savedColors?: string[];
  76522. pickedColor: string;
  76523. }>;
  76524. }
  76525. }
  76526. declare module BABYLON.GUI {
  76527. /** Class used to create 2D ellipse containers */
  76528. export class Ellipse extends Container {
  76529. name?: string | undefined;
  76530. private _thickness;
  76531. /** Gets or sets border thickness */
  76532. get thickness(): number;
  76533. set thickness(value: number);
  76534. /**
  76535. * Creates a new Ellipse
  76536. * @param name defines the control name
  76537. */
  76538. constructor(name?: string | undefined);
  76539. protected _getTypeName(): string;
  76540. protected _localDraw(context: CanvasRenderingContext2D): void;
  76541. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76542. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76543. }
  76544. }
  76545. declare module BABYLON.GUI {
  76546. /**
  76547. * Class used to create a password control
  76548. */
  76549. export class InputPassword extends InputText {
  76550. protected _beforeRenderText(text: string): string;
  76551. }
  76552. }
  76553. declare module BABYLON.GUI {
  76554. /** Class used to render 2D lines */
  76555. export class Line extends Control {
  76556. name?: string | undefined;
  76557. private _lineWidth;
  76558. private _x1;
  76559. private _y1;
  76560. private _x2;
  76561. private _y2;
  76562. private _dash;
  76563. private _connectedControl;
  76564. private _connectedControlDirtyObserver;
  76565. /** Gets or sets the dash pattern */
  76566. get dash(): Array<number>;
  76567. set dash(value: Array<number>);
  76568. /** Gets or sets the control connected with the line end */
  76569. get connectedControl(): Control;
  76570. set connectedControl(value: Control);
  76571. /** Gets or sets start coordinates on X axis */
  76572. get x1(): string | number;
  76573. set x1(value: string | number);
  76574. /** Gets or sets start coordinates on Y axis */
  76575. get y1(): string | number;
  76576. set y1(value: string | number);
  76577. /** Gets or sets end coordinates on X axis */
  76578. get x2(): string | number;
  76579. set x2(value: string | number);
  76580. /** Gets or sets end coordinates on Y axis */
  76581. get y2(): string | number;
  76582. set y2(value: string | number);
  76583. /** Gets or sets line width */
  76584. get lineWidth(): number;
  76585. set lineWidth(value: number);
  76586. /** Gets or sets horizontal alignment */
  76587. set horizontalAlignment(value: number);
  76588. /** Gets or sets vertical alignment */
  76589. set verticalAlignment(value: number);
  76590. private get _effectiveX2();
  76591. private get _effectiveY2();
  76592. /**
  76593. * Creates a new Line
  76594. * @param name defines the control name
  76595. */
  76596. constructor(name?: string | undefined);
  76597. protected _getTypeName(): string;
  76598. _draw(context: CanvasRenderingContext2D): void;
  76599. _measure(): void;
  76600. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76601. /**
  76602. * Move one end of the line given 3D cartesian coordinates.
  76603. * @param position Targeted world position
  76604. * @param scene BABYLON.Scene
  76605. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76606. */
  76607. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76608. /**
  76609. * Move one end of the line to a position in screen absolute space.
  76610. * @param projectedPosition Position in screen absolute space (X, Y)
  76611. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76612. */
  76613. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76614. }
  76615. }
  76616. declare module BABYLON.GUI {
  76617. /**
  76618. * Class used to store a point for a MultiLine object.
  76619. * The point can be pure 2D coordinates, a mesh or a control
  76620. */
  76621. export class MultiLinePoint {
  76622. private _multiLine;
  76623. private _x;
  76624. private _y;
  76625. private _control;
  76626. private _mesh;
  76627. private _controlObserver;
  76628. private _meshObserver;
  76629. /** @hidden */
  76630. _point: BABYLON.Vector2;
  76631. /**
  76632. * Creates a new MultiLinePoint
  76633. * @param multiLine defines the source MultiLine object
  76634. */
  76635. constructor(multiLine: MultiLine);
  76636. /** Gets or sets x coordinate */
  76637. get x(): string | number;
  76638. set x(value: string | number);
  76639. /** Gets or sets y coordinate */
  76640. get y(): string | number;
  76641. set y(value: string | number);
  76642. /** Gets or sets the control associated with this point */
  76643. get control(): BABYLON.Nullable<Control>;
  76644. set control(value: BABYLON.Nullable<Control>);
  76645. /** Gets or sets the mesh associated with this point */
  76646. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76647. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76648. /** Resets links */
  76649. resetLinks(): void;
  76650. /**
  76651. * Gets a translation vector
  76652. * @returns the translation vector
  76653. */
  76654. translate(): BABYLON.Vector2;
  76655. private _translatePoint;
  76656. /** Release associated resources */
  76657. dispose(): void;
  76658. }
  76659. }
  76660. declare module BABYLON.GUI {
  76661. /**
  76662. * Class used to create multi line control
  76663. */
  76664. export class MultiLine extends Control {
  76665. name?: string | undefined;
  76666. private _lineWidth;
  76667. private _dash;
  76668. private _points;
  76669. private _minX;
  76670. private _minY;
  76671. private _maxX;
  76672. private _maxY;
  76673. /**
  76674. * Creates a new MultiLine
  76675. * @param name defines the control name
  76676. */
  76677. constructor(name?: string | undefined);
  76678. /** Gets or sets dash pattern */
  76679. get dash(): Array<number>;
  76680. set dash(value: Array<number>);
  76681. /**
  76682. * Gets point stored at specified index
  76683. * @param index defines the index to look for
  76684. * @returns the requested point if found
  76685. */
  76686. getAt(index: number): MultiLinePoint;
  76687. /** Function called when a point is updated */
  76688. onPointUpdate: () => void;
  76689. /**
  76690. * Adds new points to the point collection
  76691. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76692. * @returns the list of created MultiLinePoint
  76693. */
  76694. add(...items: (AbstractMesh | Control | {
  76695. x: string | number;
  76696. y: string | number;
  76697. })[]): MultiLinePoint[];
  76698. /**
  76699. * Adds a new point to the point collection
  76700. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76701. * @returns the created MultiLinePoint
  76702. */
  76703. push(item?: (AbstractMesh | Control | {
  76704. x: string | number;
  76705. y: string | number;
  76706. })): MultiLinePoint;
  76707. /**
  76708. * Remove a specific value or point from the active point collection
  76709. * @param value defines the value or point to remove
  76710. */
  76711. remove(value: number | MultiLinePoint): void;
  76712. /**
  76713. * Resets this object to initial state (no point)
  76714. */
  76715. reset(): void;
  76716. /**
  76717. * Resets all links
  76718. */
  76719. resetLinks(): void;
  76720. /** Gets or sets line width */
  76721. get lineWidth(): number;
  76722. set lineWidth(value: number);
  76723. set horizontalAlignment(value: number);
  76724. set verticalAlignment(value: number);
  76725. protected _getTypeName(): string;
  76726. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76727. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76728. _measure(): void;
  76729. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76730. dispose(): void;
  76731. }
  76732. }
  76733. declare module BABYLON.GUI {
  76734. /**
  76735. * Class used to create radio button controls
  76736. */
  76737. export class RadioButton extends Control {
  76738. name?: string | undefined;
  76739. private _isChecked;
  76740. private _background;
  76741. private _checkSizeRatio;
  76742. private _thickness;
  76743. /** Gets or sets border thickness */
  76744. get thickness(): number;
  76745. set thickness(value: number);
  76746. /** Gets or sets group name */
  76747. group: string;
  76748. /** BABYLON.Observable raised when isChecked is changed */
  76749. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76750. /** Gets or sets a value indicating the ratio between overall size and check size */
  76751. get checkSizeRatio(): number;
  76752. set checkSizeRatio(value: number);
  76753. /** Gets or sets background color */
  76754. get background(): string;
  76755. set background(value: string);
  76756. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76757. get isChecked(): boolean;
  76758. set isChecked(value: boolean);
  76759. /**
  76760. * Creates a new RadioButton
  76761. * @param name defines the control name
  76762. */
  76763. constructor(name?: string | undefined);
  76764. protected _getTypeName(): string;
  76765. _draw(context: CanvasRenderingContext2D): void;
  76766. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76767. /**
  76768. * Utility function to easily create a radio button with a header
  76769. * @param title defines the label to use for the header
  76770. * @param group defines the group to use for the radio button
  76771. * @param isChecked defines the initial state of the radio button
  76772. * @param onValueChanged defines the callback to call when value changes
  76773. * @returns a StackPanel containing the radio button and a textBlock
  76774. */
  76775. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76776. }
  76777. }
  76778. declare module BABYLON.GUI {
  76779. /**
  76780. * Class used to create slider controls
  76781. */
  76782. export class BaseSlider extends Control {
  76783. name?: string | undefined;
  76784. protected _thumbWidth: ValueAndUnit;
  76785. private _minimum;
  76786. private _maximum;
  76787. private _value;
  76788. private _isVertical;
  76789. protected _barOffset: ValueAndUnit;
  76790. private _isThumbClamped;
  76791. protected _displayThumb: boolean;
  76792. private _step;
  76793. private _lastPointerDownID;
  76794. protected _effectiveBarOffset: number;
  76795. protected _renderLeft: number;
  76796. protected _renderTop: number;
  76797. protected _renderWidth: number;
  76798. protected _renderHeight: number;
  76799. protected _backgroundBoxLength: number;
  76800. protected _backgroundBoxThickness: number;
  76801. protected _effectiveThumbThickness: number;
  76802. /** BABYLON.Observable raised when the sldier value changes */
  76803. onValueChangedObservable: BABYLON.Observable<number>;
  76804. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76805. get displayThumb(): boolean;
  76806. set displayThumb(value: boolean);
  76807. /** Gets or sets a step to apply to values (0 by default) */
  76808. get step(): number;
  76809. set step(value: number);
  76810. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76811. get barOffset(): string | number;
  76812. /** Gets main bar offset in pixels*/
  76813. get barOffsetInPixels(): number;
  76814. set barOffset(value: string | number);
  76815. /** Gets or sets thumb width */
  76816. get thumbWidth(): string | number;
  76817. /** Gets thumb width in pixels */
  76818. get thumbWidthInPixels(): number;
  76819. set thumbWidth(value: string | number);
  76820. /** Gets or sets minimum value */
  76821. get minimum(): number;
  76822. set minimum(value: number);
  76823. /** Gets or sets maximum value */
  76824. get maximum(): number;
  76825. set maximum(value: number);
  76826. /** Gets or sets current value */
  76827. get value(): number;
  76828. set value(value: number);
  76829. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76830. get isVertical(): boolean;
  76831. set isVertical(value: boolean);
  76832. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76833. get isThumbClamped(): boolean;
  76834. set isThumbClamped(value: boolean);
  76835. /**
  76836. * Creates a new BaseSlider
  76837. * @param name defines the control name
  76838. */
  76839. constructor(name?: string | undefined);
  76840. protected _getTypeName(): string;
  76841. protected _getThumbPosition(): number;
  76842. protected _getThumbThickness(type: string): number;
  76843. protected _prepareRenderingData(type: string): void;
  76844. private _pointerIsDown;
  76845. /** @hidden */
  76846. protected _updateValueFromPointer(x: number, y: number): void;
  76847. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76848. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76849. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76850. }
  76851. }
  76852. declare module BABYLON.GUI {
  76853. /**
  76854. * Class used to create slider controls
  76855. */
  76856. export class Slider extends BaseSlider {
  76857. name?: string | undefined;
  76858. private _background;
  76859. private _borderColor;
  76860. private _isThumbCircle;
  76861. protected _displayValueBar: boolean;
  76862. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76863. get displayValueBar(): boolean;
  76864. set displayValueBar(value: boolean);
  76865. /** Gets or sets border color */
  76866. get borderColor(): string;
  76867. set borderColor(value: string);
  76868. /** Gets or sets background color */
  76869. get background(): string;
  76870. set background(value: string);
  76871. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76872. get isThumbCircle(): boolean;
  76873. set isThumbCircle(value: boolean);
  76874. /**
  76875. * Creates a new Slider
  76876. * @param name defines the control name
  76877. */
  76878. constructor(name?: string | undefined);
  76879. protected _getTypeName(): string;
  76880. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76881. }
  76882. }
  76883. declare module BABYLON.GUI {
  76884. /** Class used to create a RadioGroup
  76885. * which contains groups of radio buttons
  76886. */
  76887. export class SelectorGroup {
  76888. /** name of SelectorGroup */
  76889. name: string;
  76890. private _groupPanel;
  76891. private _selectors;
  76892. private _groupHeader;
  76893. /**
  76894. * Creates a new SelectorGroup
  76895. * @param name of group, used as a group heading
  76896. */
  76897. constructor(
  76898. /** name of SelectorGroup */
  76899. name: string);
  76900. /** Gets the groupPanel of the SelectorGroup */
  76901. get groupPanel(): StackPanel;
  76902. /** Gets the selectors array */
  76903. get selectors(): StackPanel[];
  76904. /** Gets and sets the group header */
  76905. get header(): string;
  76906. set header(label: string);
  76907. /** @hidden */
  76908. private _addGroupHeader;
  76909. /** @hidden*/
  76910. _getSelector(selectorNb: number): StackPanel | undefined;
  76911. /** Removes the selector at the given position
  76912. * @param selectorNb the position of the selector within the group
  76913. */
  76914. removeSelector(selectorNb: number): void;
  76915. }
  76916. /** Class used to create a CheckboxGroup
  76917. * which contains groups of checkbox buttons
  76918. */
  76919. export class CheckboxGroup extends SelectorGroup {
  76920. /** Adds a checkbox as a control
  76921. * @param text is the label for the selector
  76922. * @param func is the function called when the Selector is checked
  76923. * @param checked is true when Selector is checked
  76924. */
  76925. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76926. /** @hidden */
  76927. _setSelectorLabel(selectorNb: number, label: string): void;
  76928. /** @hidden */
  76929. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76930. /** @hidden */
  76931. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76932. /** @hidden */
  76933. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76934. }
  76935. /** Class used to create a RadioGroup
  76936. * which contains groups of radio buttons
  76937. */
  76938. export class RadioGroup extends SelectorGroup {
  76939. private _selectNb;
  76940. /** Adds a radio button as a control
  76941. * @param label is the label for the selector
  76942. * @param func is the function called when the Selector is checked
  76943. * @param checked is true when Selector is checked
  76944. */
  76945. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76946. /** @hidden */
  76947. _setSelectorLabel(selectorNb: number, label: string): void;
  76948. /** @hidden */
  76949. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76950. /** @hidden */
  76951. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76952. /** @hidden */
  76953. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76954. }
  76955. /** Class used to create a SliderGroup
  76956. * which contains groups of slider buttons
  76957. */
  76958. export class SliderGroup extends SelectorGroup {
  76959. /**
  76960. * Adds a slider to the SelectorGroup
  76961. * @param label is the label for the SliderBar
  76962. * @param func is the function called when the Slider moves
  76963. * @param unit is a string describing the units used, eg degrees or metres
  76964. * @param min is the minimum value for the Slider
  76965. * @param max is the maximum value for the Slider
  76966. * @param value is the start value for the Slider between min and max
  76967. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76968. */
  76969. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76970. /** @hidden */
  76971. _setSelectorLabel(selectorNb: number, label: string): void;
  76972. /** @hidden */
  76973. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76974. /** @hidden */
  76975. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76976. /** @hidden */
  76977. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76978. }
  76979. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76980. * @see http://doc.babylonjs.com/how_to/selector
  76981. */
  76982. export class SelectionPanel extends Rectangle {
  76983. /** name of SelectionPanel */
  76984. name: string;
  76985. /** an array of SelectionGroups */
  76986. groups: SelectorGroup[];
  76987. private _panel;
  76988. private _buttonColor;
  76989. private _buttonBackground;
  76990. private _headerColor;
  76991. private _barColor;
  76992. private _barHeight;
  76993. private _spacerHeight;
  76994. private _labelColor;
  76995. private _groups;
  76996. private _bars;
  76997. /**
  76998. * Creates a new SelectionPanel
  76999. * @param name of SelectionPanel
  77000. * @param groups is an array of SelectionGroups
  77001. */
  77002. constructor(
  77003. /** name of SelectionPanel */
  77004. name: string,
  77005. /** an array of SelectionGroups */
  77006. groups?: SelectorGroup[]);
  77007. protected _getTypeName(): string;
  77008. /** Gets or sets the headerColor */
  77009. get headerColor(): string;
  77010. set headerColor(color: string);
  77011. private _setHeaderColor;
  77012. /** Gets or sets the button color */
  77013. get buttonColor(): string;
  77014. set buttonColor(color: string);
  77015. private _setbuttonColor;
  77016. /** Gets or sets the label color */
  77017. get labelColor(): string;
  77018. set labelColor(color: string);
  77019. private _setLabelColor;
  77020. /** Gets or sets the button background */
  77021. get buttonBackground(): string;
  77022. set buttonBackground(color: string);
  77023. private _setButtonBackground;
  77024. /** Gets or sets the color of separator bar */
  77025. get barColor(): string;
  77026. set barColor(color: string);
  77027. private _setBarColor;
  77028. /** Gets or sets the height of separator bar */
  77029. get barHeight(): string;
  77030. set barHeight(value: string);
  77031. private _setBarHeight;
  77032. /** Gets or sets the height of spacers*/
  77033. get spacerHeight(): string;
  77034. set spacerHeight(value: string);
  77035. private _setSpacerHeight;
  77036. /** Adds a bar between groups */
  77037. private _addSpacer;
  77038. /** Add a group to the selection panel
  77039. * @param group is the selector group to add
  77040. */
  77041. addGroup(group: SelectorGroup): void;
  77042. /** Remove the group from the given position
  77043. * @param groupNb is the position of the group in the list
  77044. */
  77045. removeGroup(groupNb: number): void;
  77046. /** Change a group header label
  77047. * @param label is the new group header label
  77048. * @param groupNb is the number of the group to relabel
  77049. * */
  77050. setHeaderName(label: string, groupNb: number): void;
  77051. /** Change selector label to the one given
  77052. * @param label is the new selector label
  77053. * @param groupNb is the number of the groupcontaining the selector
  77054. * @param selectorNb is the number of the selector within a group to relabel
  77055. * */
  77056. relabel(label: string, groupNb: number, selectorNb: number): void;
  77057. /** For a given group position remove the selector at the given position
  77058. * @param groupNb is the number of the group to remove the selector from
  77059. * @param selectorNb is the number of the selector within the group
  77060. */
  77061. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77062. /** For a given group position of correct type add a checkbox button
  77063. * @param groupNb is the number of the group to remove the selector from
  77064. * @param label is the label for the selector
  77065. * @param func is the function called when the Selector is checked
  77066. * @param checked is true when Selector is checked
  77067. */
  77068. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77069. /** For a given group position of correct type add a radio button
  77070. * @param groupNb is the number of the group to remove the selector from
  77071. * @param label is the label for the selector
  77072. * @param func is the function called when the Selector is checked
  77073. * @param checked is true when Selector is checked
  77074. */
  77075. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77076. /**
  77077. * For a given slider group add a slider
  77078. * @param groupNb is the number of the group to add the slider to
  77079. * @param label is the label for the Slider
  77080. * @param func is the function called when the Slider moves
  77081. * @param unit is a string describing the units used, eg degrees or metres
  77082. * @param min is the minimum value for the Slider
  77083. * @param max is the maximum value for the Slider
  77084. * @param value is the start value for the Slider between min and max
  77085. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77086. */
  77087. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77088. }
  77089. }
  77090. declare module BABYLON.GUI {
  77091. /**
  77092. * Class used to hold a the container for ScrollViewer
  77093. * @hidden
  77094. */
  77095. export class _ScrollViewerWindow extends Container {
  77096. parentClientWidth: number;
  77097. parentClientHeight: number;
  77098. private _freezeControls;
  77099. private _parentMeasure;
  77100. private _oldLeft;
  77101. private _oldTop;
  77102. get freezeControls(): boolean;
  77103. set freezeControls(value: boolean);
  77104. private _bucketWidth;
  77105. private _bucketHeight;
  77106. private _buckets;
  77107. private _bucketLen;
  77108. get bucketWidth(): number;
  77109. get bucketHeight(): number;
  77110. setBucketSizes(width: number, height: number): void;
  77111. private _useBuckets;
  77112. private _makeBuckets;
  77113. private _dispatchInBuckets;
  77114. private _updateMeasures;
  77115. private _updateChildrenMeasures;
  77116. private _restoreMeasures;
  77117. /**
  77118. * Creates a new ScrollViewerWindow
  77119. * @param name of ScrollViewerWindow
  77120. */
  77121. constructor(name?: string);
  77122. protected _getTypeName(): string;
  77123. /** @hidden */
  77124. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77125. /** @hidden */
  77126. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77127. private _scrollChildren;
  77128. private _scrollChildrenWithBuckets;
  77129. /** @hidden */
  77130. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77131. protected _postMeasure(): void;
  77132. }
  77133. }
  77134. declare module BABYLON.GUI {
  77135. /**
  77136. * Class used to create slider controls
  77137. */
  77138. export class ScrollBar extends BaseSlider {
  77139. name?: string | undefined;
  77140. private _background;
  77141. private _borderColor;
  77142. private _tempMeasure;
  77143. /** Gets or sets border color */
  77144. get borderColor(): string;
  77145. set borderColor(value: string);
  77146. /** Gets or sets background color */
  77147. get background(): string;
  77148. set background(value: string);
  77149. /**
  77150. * Creates a new Slider
  77151. * @param name defines the control name
  77152. */
  77153. constructor(name?: string | undefined);
  77154. protected _getTypeName(): string;
  77155. protected _getThumbThickness(): number;
  77156. _draw(context: CanvasRenderingContext2D): void;
  77157. private _first;
  77158. private _originX;
  77159. private _originY;
  77160. /** @hidden */
  77161. protected _updateValueFromPointer(x: number, y: number): void;
  77162. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77163. }
  77164. }
  77165. declare module BABYLON.GUI {
  77166. /**
  77167. * Class used to create slider controls
  77168. */
  77169. export class ImageScrollBar extends BaseSlider {
  77170. name?: string | undefined;
  77171. private _backgroundBaseImage;
  77172. private _backgroundImage;
  77173. private _thumbImage;
  77174. private _thumbBaseImage;
  77175. private _thumbLength;
  77176. private _thumbHeight;
  77177. private _barImageHeight;
  77178. private _tempMeasure;
  77179. /** Number of 90° rotation to apply on the images when in vertical mode */
  77180. num90RotationInVerticalMode: number;
  77181. /**
  77182. * Gets or sets the image used to render the background for horizontal bar
  77183. */
  77184. get backgroundImage(): Image;
  77185. set backgroundImage(value: Image);
  77186. /**
  77187. * Gets or sets the image used to render the thumb
  77188. */
  77189. get thumbImage(): Image;
  77190. set thumbImage(value: Image);
  77191. /**
  77192. * Gets or sets the length of the thumb
  77193. */
  77194. get thumbLength(): number;
  77195. set thumbLength(value: number);
  77196. /**
  77197. * Gets or sets the height of the thumb
  77198. */
  77199. get thumbHeight(): number;
  77200. set thumbHeight(value: number);
  77201. /**
  77202. * Gets or sets the height of the bar image
  77203. */
  77204. get barImageHeight(): number;
  77205. set barImageHeight(value: number);
  77206. /**
  77207. * Creates a new ImageScrollBar
  77208. * @param name defines the control name
  77209. */
  77210. constructor(name?: string | undefined);
  77211. protected _getTypeName(): string;
  77212. protected _getThumbThickness(): number;
  77213. _draw(context: CanvasRenderingContext2D): void;
  77214. private _first;
  77215. private _originX;
  77216. private _originY;
  77217. /** @hidden */
  77218. protected _updateValueFromPointer(x: number, y: number): void;
  77219. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77220. }
  77221. }
  77222. declare module BABYLON.GUI {
  77223. /**
  77224. * Class used to hold a viewer window and sliders in a grid
  77225. */
  77226. export class ScrollViewer extends Rectangle {
  77227. private _grid;
  77228. private _horizontalBarSpace;
  77229. private _verticalBarSpace;
  77230. private _dragSpace;
  77231. private _horizontalBar;
  77232. private _verticalBar;
  77233. private _barColor;
  77234. private _barBackground;
  77235. private _barImage;
  77236. private _horizontalBarImage;
  77237. private _verticalBarImage;
  77238. private _barBackgroundImage;
  77239. private _horizontalBarBackgroundImage;
  77240. private _verticalBarBackgroundImage;
  77241. private _barSize;
  77242. private _window;
  77243. private _pointerIsOver;
  77244. private _wheelPrecision;
  77245. private _onWheelObserver;
  77246. private _clientWidth;
  77247. private _clientHeight;
  77248. private _useImageBar;
  77249. private _thumbLength;
  77250. private _thumbHeight;
  77251. private _barImageHeight;
  77252. private _horizontalBarImageHeight;
  77253. private _verticalBarImageHeight;
  77254. private _oldWindowContentsWidth;
  77255. private _oldWindowContentsHeight;
  77256. /**
  77257. * Gets the horizontal scrollbar
  77258. */
  77259. get horizontalBar(): ScrollBar | ImageScrollBar;
  77260. /**
  77261. * Gets the vertical scrollbar
  77262. */
  77263. get verticalBar(): ScrollBar | ImageScrollBar;
  77264. /**
  77265. * Adds a new control to the current container
  77266. * @param control defines the control to add
  77267. * @returns the current container
  77268. */
  77269. addControl(control: BABYLON.Nullable<Control>): Container;
  77270. /**
  77271. * Removes a control from the current container
  77272. * @param control defines the control to remove
  77273. * @returns the current container
  77274. */
  77275. removeControl(control: Control): Container;
  77276. /** Gets the list of children */
  77277. get children(): Control[];
  77278. _flagDescendantsAsMatrixDirty(): void;
  77279. /**
  77280. * Freezes or unfreezes the controls in the window.
  77281. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77282. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77283. */
  77284. get freezeControls(): boolean;
  77285. set freezeControls(value: boolean);
  77286. /** Gets the bucket width */
  77287. get bucketWidth(): number;
  77288. /** Gets the bucket height */
  77289. get bucketHeight(): number;
  77290. /**
  77291. * Sets the bucket sizes.
  77292. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77293. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77294. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77295. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77296. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77297. * used), that's why it is not enabled by default.
  77298. * @param width width of the bucket
  77299. * @param height height of the bucket
  77300. */
  77301. setBucketSizes(width: number, height: number): void;
  77302. private _forceHorizontalBar;
  77303. private _forceVerticalBar;
  77304. /**
  77305. * Forces the horizontal scroll bar to be displayed
  77306. */
  77307. get forceHorizontalBar(): boolean;
  77308. set forceHorizontalBar(value: boolean);
  77309. /**
  77310. * Forces the vertical scroll bar to be displayed
  77311. */
  77312. get forceVerticalBar(): boolean;
  77313. set forceVerticalBar(value: boolean);
  77314. /**
  77315. * Creates a new ScrollViewer
  77316. * @param name of ScrollViewer
  77317. */
  77318. constructor(name?: string, isImageBased?: boolean);
  77319. /** Reset the scroll viewer window to initial size */
  77320. resetWindow(): void;
  77321. protected _getTypeName(): string;
  77322. private _buildClientSizes;
  77323. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77324. protected _postMeasure(): void;
  77325. /**
  77326. * Gets or sets the mouse wheel precision
  77327. * from 0 to 1 with a default value of 0.05
  77328. * */
  77329. get wheelPrecision(): number;
  77330. set wheelPrecision(value: number);
  77331. /** Gets or sets the scroll bar container background color */
  77332. get scrollBackground(): string;
  77333. set scrollBackground(color: string);
  77334. /** Gets or sets the bar color */
  77335. get barColor(): string;
  77336. set barColor(color: string);
  77337. /** Gets or sets the bar image */
  77338. get thumbImage(): Image;
  77339. set thumbImage(value: Image);
  77340. /** Gets or sets the horizontal bar image */
  77341. get horizontalThumbImage(): Image;
  77342. set horizontalThumbImage(value: Image);
  77343. /** Gets or sets the vertical bar image */
  77344. get verticalThumbImage(): Image;
  77345. set verticalThumbImage(value: Image);
  77346. /** Gets or sets the size of the bar */
  77347. get barSize(): number;
  77348. set barSize(value: number);
  77349. /** Gets or sets the length of the thumb */
  77350. get thumbLength(): number;
  77351. set thumbLength(value: number);
  77352. /** Gets or sets the height of the thumb */
  77353. get thumbHeight(): number;
  77354. set thumbHeight(value: number);
  77355. /** Gets or sets the height of the bar image */
  77356. get barImageHeight(): number;
  77357. set barImageHeight(value: number);
  77358. /** Gets or sets the height of the horizontal bar image */
  77359. get horizontalBarImageHeight(): number;
  77360. set horizontalBarImageHeight(value: number);
  77361. /** Gets or sets the height of the vertical bar image */
  77362. get verticalBarImageHeight(): number;
  77363. set verticalBarImageHeight(value: number);
  77364. /** Gets or sets the bar background */
  77365. get barBackground(): string;
  77366. set barBackground(color: string);
  77367. /** Gets or sets the bar background image */
  77368. get barImage(): Image;
  77369. set barImage(value: Image);
  77370. /** Gets or sets the horizontal bar background image */
  77371. get horizontalBarImage(): Image;
  77372. set horizontalBarImage(value: Image);
  77373. /** Gets or sets the vertical bar background image */
  77374. get verticalBarImage(): Image;
  77375. set verticalBarImage(value: Image);
  77376. private _setWindowPosition;
  77377. /** @hidden */
  77378. private _updateScroller;
  77379. _link(host: AdvancedDynamicTexture): void;
  77380. /** @hidden */
  77381. private _addBar;
  77382. /** @hidden */
  77383. private _attachWheel;
  77384. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77385. /** Releases associated resources */
  77386. dispose(): void;
  77387. }
  77388. }
  77389. declare module BABYLON.GUI {
  77390. /** Class used to render a grid */
  77391. export class DisplayGrid extends Control {
  77392. name?: string | undefined;
  77393. private _cellWidth;
  77394. private _cellHeight;
  77395. private _minorLineTickness;
  77396. private _minorLineColor;
  77397. private _majorLineTickness;
  77398. private _majorLineColor;
  77399. private _majorLineFrequency;
  77400. private _background;
  77401. private _displayMajorLines;
  77402. private _displayMinorLines;
  77403. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77404. get displayMinorLines(): boolean;
  77405. set displayMinorLines(value: boolean);
  77406. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77407. get displayMajorLines(): boolean;
  77408. set displayMajorLines(value: boolean);
  77409. /** Gets or sets background color (Black by default) */
  77410. get background(): string;
  77411. set background(value: string);
  77412. /** Gets or sets the width of each cell (20 by default) */
  77413. get cellWidth(): number;
  77414. set cellWidth(value: number);
  77415. /** Gets or sets the height of each cell (20 by default) */
  77416. get cellHeight(): number;
  77417. set cellHeight(value: number);
  77418. /** Gets or sets the tickness of minor lines (1 by default) */
  77419. get minorLineTickness(): number;
  77420. set minorLineTickness(value: number);
  77421. /** Gets or sets the color of minor lines (DarkGray by default) */
  77422. get minorLineColor(): string;
  77423. set minorLineColor(value: string);
  77424. /** Gets or sets the tickness of major lines (2 by default) */
  77425. get majorLineTickness(): number;
  77426. set majorLineTickness(value: number);
  77427. /** Gets or sets the color of major lines (White by default) */
  77428. get majorLineColor(): string;
  77429. set majorLineColor(value: string);
  77430. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77431. get majorLineFrequency(): number;
  77432. set majorLineFrequency(value: number);
  77433. /**
  77434. * Creates a new GridDisplayRectangle
  77435. * @param name defines the control name
  77436. */
  77437. constructor(name?: string | undefined);
  77438. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77439. protected _getTypeName(): string;
  77440. }
  77441. }
  77442. declare module BABYLON.GUI {
  77443. /**
  77444. * Class used to create slider controls based on images
  77445. */
  77446. export class ImageBasedSlider extends BaseSlider {
  77447. name?: string | undefined;
  77448. private _backgroundImage;
  77449. private _thumbImage;
  77450. private _valueBarImage;
  77451. private _tempMeasure;
  77452. get displayThumb(): boolean;
  77453. set displayThumb(value: boolean);
  77454. /**
  77455. * Gets or sets the image used to render the background
  77456. */
  77457. get backgroundImage(): Image;
  77458. set backgroundImage(value: Image);
  77459. /**
  77460. * Gets or sets the image used to render the value bar
  77461. */
  77462. get valueBarImage(): Image;
  77463. set valueBarImage(value: Image);
  77464. /**
  77465. * Gets or sets the image used to render the thumb
  77466. */
  77467. get thumbImage(): Image;
  77468. set thumbImage(value: Image);
  77469. /**
  77470. * Creates a new ImageBasedSlider
  77471. * @param name defines the control name
  77472. */
  77473. constructor(name?: string | undefined);
  77474. protected _getTypeName(): string;
  77475. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77476. }
  77477. }
  77478. declare module BABYLON.GUI {
  77479. /**
  77480. * Forcing an export so that this code will execute
  77481. * @hidden
  77482. */
  77483. const name = "Statics";
  77484. }
  77485. declare module BABYLON.GUI {
  77486. /**
  77487. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77488. */
  77489. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77490. /**
  77491. * Define the instrumented AdvancedDynamicTexture.
  77492. */
  77493. texture: AdvancedDynamicTexture;
  77494. private _captureRenderTime;
  77495. private _renderTime;
  77496. private _captureLayoutTime;
  77497. private _layoutTime;
  77498. private _onBeginRenderObserver;
  77499. private _onEndRenderObserver;
  77500. private _onBeginLayoutObserver;
  77501. private _onEndLayoutObserver;
  77502. /**
  77503. * Gets the perf counter used to capture render time
  77504. */
  77505. get renderTimeCounter(): BABYLON.PerfCounter;
  77506. /**
  77507. * Gets the perf counter used to capture layout time
  77508. */
  77509. get layoutTimeCounter(): BABYLON.PerfCounter;
  77510. /**
  77511. * Enable or disable the render time capture
  77512. */
  77513. get captureRenderTime(): boolean;
  77514. set captureRenderTime(value: boolean);
  77515. /**
  77516. * Enable or disable the layout time capture
  77517. */
  77518. get captureLayoutTime(): boolean;
  77519. set captureLayoutTime(value: boolean);
  77520. /**
  77521. * Instantiates a new advanced dynamic texture instrumentation.
  77522. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77523. * @param texture Defines the AdvancedDynamicTexture to instrument
  77524. */
  77525. constructor(
  77526. /**
  77527. * Define the instrumented AdvancedDynamicTexture.
  77528. */
  77529. texture: AdvancedDynamicTexture);
  77530. /**
  77531. * Dispose and release associated resources.
  77532. */
  77533. dispose(): void;
  77534. }
  77535. }
  77536. declare module BABYLON.GUI {
  77537. /**
  77538. * Class used to load GUI via XML.
  77539. */
  77540. export class XmlLoader {
  77541. private _nodes;
  77542. private _nodeTypes;
  77543. private _isLoaded;
  77544. private _objectAttributes;
  77545. private _parentClass;
  77546. /**
  77547. * Create a new xml loader
  77548. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77549. */
  77550. constructor(parentClass?: null);
  77551. private _getChainElement;
  77552. private _getClassAttribute;
  77553. private _createGuiElement;
  77554. private _parseGrid;
  77555. private _parseElement;
  77556. private _prepareSourceElement;
  77557. private _parseElementsFromSource;
  77558. private _parseXml;
  77559. /**
  77560. * Gets if the loading has finished.
  77561. * @returns whether the loading has finished or not
  77562. */
  77563. isLoaded(): boolean;
  77564. /**
  77565. * Gets a loaded node / control by id.
  77566. * @param id the Controls id set in the xml
  77567. * @returns element of type Control
  77568. */
  77569. getNodeById(id: string): any;
  77570. /**
  77571. * Gets all loaded nodes / controls
  77572. * @returns Array of controls
  77573. */
  77574. getNodes(): any;
  77575. /**
  77576. * Initiates the xml layout loading
  77577. * @param xmlFile defines the xml layout to load
  77578. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77579. * @param callback defines the callback called on layout load.
  77580. */
  77581. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77582. }
  77583. }
  77584. declare module BABYLON.GUI {
  77585. /**
  77586. * Class used to create containers for controls
  77587. */
  77588. export class Container3D extends Control3D {
  77589. private _blockLayout;
  77590. /**
  77591. * Gets the list of child controls
  77592. */
  77593. protected _children: Control3D[];
  77594. /**
  77595. * Gets the list of child controls
  77596. */
  77597. get children(): Array<Control3D>;
  77598. /**
  77599. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77600. * This is helpful to optimize layout operation when adding multiple children in a row
  77601. */
  77602. get blockLayout(): boolean;
  77603. set blockLayout(value: boolean);
  77604. /**
  77605. * Creates a new container
  77606. * @param name defines the container name
  77607. */
  77608. constructor(name?: string);
  77609. /**
  77610. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77611. * @returns the current container
  77612. */
  77613. updateLayout(): Container3D;
  77614. /**
  77615. * Gets a boolean indicating if the given control is in the children of this control
  77616. * @param control defines the control to check
  77617. * @returns true if the control is in the child list
  77618. */
  77619. containsControl(control: Control3D): boolean;
  77620. /**
  77621. * Adds a control to the children of this control
  77622. * @param control defines the control to add
  77623. * @returns the current container
  77624. */
  77625. addControl(control: Control3D): Container3D;
  77626. /**
  77627. * This function will be called everytime a new control is added
  77628. */
  77629. protected _arrangeChildren(): void;
  77630. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77631. /**
  77632. * Removes a control from the children of this control
  77633. * @param control defines the control to remove
  77634. * @returns the current container
  77635. */
  77636. removeControl(control: Control3D): Container3D;
  77637. protected _getTypeName(): string;
  77638. /**
  77639. * Releases all associated resources
  77640. */
  77641. dispose(): void;
  77642. /** Control rotation will remain unchanged */
  77643. static readonly UNSET_ORIENTATION: number;
  77644. /** Control will rotate to make it look at sphere central axis */
  77645. static readonly FACEORIGIN_ORIENTATION: number;
  77646. /** Control will rotate to make it look back at sphere central axis */
  77647. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77648. /** Control will rotate to look at z axis (0, 0, 1) */
  77649. static readonly FACEFORWARD_ORIENTATION: number;
  77650. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77651. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77652. }
  77653. }
  77654. declare module BABYLON.GUI {
  77655. /**
  77656. * Class used to manage 3D user interface
  77657. * @see http://doc.babylonjs.com/how_to/gui3d
  77658. */
  77659. export class GUI3DManager implements BABYLON.IDisposable {
  77660. private _scene;
  77661. private _sceneDisposeObserver;
  77662. private _utilityLayer;
  77663. private _rootContainer;
  77664. private _pointerObserver;
  77665. private _pointerOutObserver;
  77666. /** @hidden */
  77667. _lastPickedControl: Control3D;
  77668. /** @hidden */
  77669. _lastControlOver: {
  77670. [pointerId: number]: Control3D;
  77671. };
  77672. /** @hidden */
  77673. _lastControlDown: {
  77674. [pointerId: number]: Control3D;
  77675. };
  77676. /**
  77677. * BABYLON.Observable raised when the point picked by the pointer events changed
  77678. */
  77679. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77680. /** @hidden */
  77681. _sharedMaterials: {
  77682. [key: string]: BABYLON.Material;
  77683. };
  77684. /** Gets the hosting scene */
  77685. get scene(): BABYLON.Scene;
  77686. /** Gets associated utility layer */
  77687. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77688. /**
  77689. * Creates a new GUI3DManager
  77690. * @param scene
  77691. */
  77692. constructor(scene?: BABYLON.Scene);
  77693. private _handlePointerOut;
  77694. private _doPicking;
  77695. /**
  77696. * Gets the root container
  77697. */
  77698. get rootContainer(): Container3D;
  77699. /**
  77700. * Gets a boolean indicating if the given control is in the root child list
  77701. * @param control defines the control to check
  77702. * @returns true if the control is in the root child list
  77703. */
  77704. containsControl(control: Control3D): boolean;
  77705. /**
  77706. * Adds a control to the root child list
  77707. * @param control defines the control to add
  77708. * @returns the current manager
  77709. */
  77710. addControl(control: Control3D): GUI3DManager;
  77711. /**
  77712. * Removes a control from the root child list
  77713. * @param control defines the control to remove
  77714. * @returns the current container
  77715. */
  77716. removeControl(control: Control3D): GUI3DManager;
  77717. /**
  77718. * Releases all associated resources
  77719. */
  77720. dispose(): void;
  77721. }
  77722. }
  77723. declare module BABYLON.GUI {
  77724. /**
  77725. * Class used to transport BABYLON.Vector3 information for pointer events
  77726. */
  77727. export class Vector3WithInfo extends BABYLON.Vector3 {
  77728. /** defines the current mouse button index */
  77729. buttonIndex: number;
  77730. /**
  77731. * Creates a new Vector3WithInfo
  77732. * @param source defines the vector3 data to transport
  77733. * @param buttonIndex defines the current mouse button index
  77734. */
  77735. constructor(source: BABYLON.Vector3,
  77736. /** defines the current mouse button index */
  77737. buttonIndex?: number);
  77738. }
  77739. }
  77740. declare module BABYLON.GUI {
  77741. /**
  77742. * Class used as base class for controls
  77743. */
  77744. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77745. /** Defines the control name */
  77746. name?: string | undefined;
  77747. /** @hidden */
  77748. _host: GUI3DManager;
  77749. private _node;
  77750. private _downCount;
  77751. private _enterCount;
  77752. private _downPointerIds;
  77753. private _isVisible;
  77754. /** Gets or sets the control position in world space */
  77755. get position(): BABYLON.Vector3;
  77756. set position(value: BABYLON.Vector3);
  77757. /** Gets or sets the control scaling in world space */
  77758. get scaling(): BABYLON.Vector3;
  77759. set scaling(value: BABYLON.Vector3);
  77760. /** Callback used to start pointer enter animation */
  77761. pointerEnterAnimation: () => void;
  77762. /** Callback used to start pointer out animation */
  77763. pointerOutAnimation: () => void;
  77764. /** Callback used to start pointer down animation */
  77765. pointerDownAnimation: () => void;
  77766. /** Callback used to start pointer up animation */
  77767. pointerUpAnimation: () => void;
  77768. /**
  77769. * An event triggered when the pointer move over the control
  77770. */
  77771. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77772. /**
  77773. * An event triggered when the pointer move out of the control
  77774. */
  77775. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77776. /**
  77777. * An event triggered when the pointer taps the control
  77778. */
  77779. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77780. /**
  77781. * An event triggered when pointer is up
  77782. */
  77783. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77784. /**
  77785. * An event triggered when a control is clicked on (with a mouse)
  77786. */
  77787. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77788. /**
  77789. * An event triggered when pointer enters the control
  77790. */
  77791. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77792. /**
  77793. * Gets or sets the parent container
  77794. */
  77795. parent: BABYLON.Nullable<Container3D>;
  77796. private _behaviors;
  77797. /**
  77798. * Gets the list of attached behaviors
  77799. * @see http://doc.babylonjs.com/features/behaviour
  77800. */
  77801. get behaviors(): BABYLON.Behavior<Control3D>[];
  77802. /**
  77803. * Attach a behavior to the control
  77804. * @see http://doc.babylonjs.com/features/behaviour
  77805. * @param behavior defines the behavior to attach
  77806. * @returns the current control
  77807. */
  77808. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77809. /**
  77810. * Remove an attached behavior
  77811. * @see http://doc.babylonjs.com/features/behaviour
  77812. * @param behavior defines the behavior to attach
  77813. * @returns the current control
  77814. */
  77815. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77816. /**
  77817. * Gets an attached behavior by name
  77818. * @param name defines the name of the behavior to look for
  77819. * @see http://doc.babylonjs.com/features/behaviour
  77820. * @returns null if behavior was not found else the requested behavior
  77821. */
  77822. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77823. /** Gets or sets a boolean indicating if the control is visible */
  77824. get isVisible(): boolean;
  77825. set isVisible(value: boolean);
  77826. /**
  77827. * Creates a new control
  77828. * @param name defines the control name
  77829. */
  77830. constructor(
  77831. /** Defines the control name */
  77832. name?: string | undefined);
  77833. /**
  77834. * Gets a string representing the class name
  77835. */
  77836. get typeName(): string;
  77837. /**
  77838. * Get the current class name of the control.
  77839. * @returns current class name
  77840. */
  77841. getClassName(): string;
  77842. protected _getTypeName(): string;
  77843. /**
  77844. * Gets the transform node used by this control
  77845. */
  77846. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77847. /**
  77848. * Gets the mesh used to render this control
  77849. */
  77850. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77851. /**
  77852. * Link the control as child of the given node
  77853. * @param node defines the node to link to. Use null to unlink the control
  77854. * @returns the current control
  77855. */
  77856. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77857. /** @hidden **/
  77858. _prepareNode(scene: BABYLON.Scene): void;
  77859. /**
  77860. * Node creation.
  77861. * Can be overriden by children
  77862. * @param scene defines the scene where the node must be attached
  77863. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77864. */
  77865. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77866. /**
  77867. * Affect a material to the given mesh
  77868. * @param mesh defines the mesh which will represent the control
  77869. */
  77870. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77871. /** @hidden */
  77872. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77873. /** @hidden */
  77874. _onPointerEnter(target: Control3D): boolean;
  77875. /** @hidden */
  77876. _onPointerOut(target: Control3D): void;
  77877. /** @hidden */
  77878. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77879. /** @hidden */
  77880. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77881. /** @hidden */
  77882. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77883. /** @hidden */
  77884. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77885. /** @hidden */
  77886. _disposeNode(): void;
  77887. /**
  77888. * Releases all associated resources
  77889. */
  77890. dispose(): void;
  77891. }
  77892. }
  77893. declare module BABYLON.GUI {
  77894. /**
  77895. * Class used as a root to all buttons
  77896. */
  77897. export class AbstractButton3D extends Control3D {
  77898. /**
  77899. * Creates a new button
  77900. * @param name defines the control name
  77901. */
  77902. constructor(name?: string);
  77903. protected _getTypeName(): string;
  77904. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77905. }
  77906. }
  77907. declare module BABYLON.GUI {
  77908. /**
  77909. * Class used to create a button in 3D
  77910. */
  77911. export class Button3D extends AbstractButton3D {
  77912. /** @hidden */
  77913. protected _currentMaterial: BABYLON.Material;
  77914. private _facadeTexture;
  77915. private _content;
  77916. private _contentResolution;
  77917. private _contentScaleRatio;
  77918. /**
  77919. * Gets or sets the texture resolution used to render content (512 by default)
  77920. */
  77921. get contentResolution(): BABYLON.int;
  77922. set contentResolution(value: BABYLON.int);
  77923. /**
  77924. * Gets or sets the texture scale ratio used to render content (2 by default)
  77925. */
  77926. get contentScaleRatio(): number;
  77927. set contentScaleRatio(value: number);
  77928. protected _disposeFacadeTexture(): void;
  77929. protected _resetContent(): void;
  77930. /**
  77931. * Creates a new button
  77932. * @param name defines the control name
  77933. */
  77934. constructor(name?: string);
  77935. /**
  77936. * Gets or sets the GUI 2D content used to display the button's facade
  77937. */
  77938. get content(): Control;
  77939. set content(value: Control);
  77940. /**
  77941. * Apply the facade texture (created from the content property).
  77942. * This function can be overloaded by child classes
  77943. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77944. */
  77945. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77946. protected _getTypeName(): string;
  77947. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77948. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77949. /**
  77950. * Releases all associated resources
  77951. */
  77952. dispose(): void;
  77953. }
  77954. }
  77955. declare module BABYLON.GUI {
  77956. /**
  77957. * Abstract class used to create a container panel deployed on the surface of a volume
  77958. */
  77959. export abstract class VolumeBasedPanel extends Container3D {
  77960. private _columns;
  77961. private _rows;
  77962. private _rowThenColum;
  77963. private _orientation;
  77964. protected _cellWidth: number;
  77965. protected _cellHeight: number;
  77966. /**
  77967. * Gets or sets the distance between elements
  77968. */
  77969. margin: number;
  77970. /**
  77971. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77972. * | Value | Type | Description |
  77973. * | ----- | ----------------------------------- | ----------- |
  77974. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77975. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77976. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77977. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77978. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77979. */
  77980. get orientation(): number;
  77981. set orientation(value: number);
  77982. /**
  77983. * Gets or sets the number of columns requested (10 by default).
  77984. * The panel will automatically compute the number of rows based on number of child controls.
  77985. */
  77986. get columns(): BABYLON.int;
  77987. set columns(value: BABYLON.int);
  77988. /**
  77989. * Gets or sets a the number of rows requested.
  77990. * The panel will automatically compute the number of columns based on number of child controls.
  77991. */
  77992. get rows(): BABYLON.int;
  77993. set rows(value: BABYLON.int);
  77994. /**
  77995. * Creates new VolumeBasedPanel
  77996. */
  77997. constructor();
  77998. protected _arrangeChildren(): void;
  77999. /** Child classes must implement this function to provide correct control positioning */
  78000. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78001. /** Child classes can implement this function to provide additional processing */
  78002. protected _finalProcessing(): void;
  78003. }
  78004. }
  78005. declare module BABYLON.GUI {
  78006. /**
  78007. * Class used to create a container panel deployed on the surface of a cylinder
  78008. */
  78009. export class CylinderPanel extends VolumeBasedPanel {
  78010. private _radius;
  78011. /**
  78012. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78013. */
  78014. get radius(): BABYLON.float;
  78015. set radius(value: BABYLON.float);
  78016. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78017. private _cylindricalMapping;
  78018. }
  78019. }
  78020. declare module BABYLON.GUI {
  78021. /** @hidden */
  78022. export var fluentVertexShader: {
  78023. name: string;
  78024. shader: string;
  78025. };
  78026. }
  78027. declare module BABYLON.GUI {
  78028. /** @hidden */
  78029. export var fluentPixelShader: {
  78030. name: string;
  78031. shader: string;
  78032. };
  78033. }
  78034. declare module BABYLON.GUI {
  78035. /** @hidden */
  78036. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78037. INNERGLOW: boolean;
  78038. BORDER: boolean;
  78039. HOVERLIGHT: boolean;
  78040. TEXTURE: boolean;
  78041. constructor();
  78042. }
  78043. /**
  78044. * Class used to render controls with fluent desgin
  78045. */
  78046. export class FluentMaterial extends BABYLON.PushMaterial {
  78047. /**
  78048. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78049. */
  78050. innerGlowColorIntensity: number;
  78051. /**
  78052. * Gets or sets the inner glow color (white by default)
  78053. */
  78054. innerGlowColor: BABYLON.Color3;
  78055. /**
  78056. * Gets or sets alpha value (default is 1.0)
  78057. */
  78058. alpha: number;
  78059. /**
  78060. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78061. */
  78062. albedoColor: BABYLON.Color3;
  78063. /**
  78064. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78065. */
  78066. renderBorders: boolean;
  78067. /**
  78068. * Gets or sets border width (default is 0.5)
  78069. */
  78070. borderWidth: number;
  78071. /**
  78072. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78073. */
  78074. edgeSmoothingValue: number;
  78075. /**
  78076. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78077. */
  78078. borderMinValue: number;
  78079. /**
  78080. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78081. */
  78082. renderHoverLight: boolean;
  78083. /**
  78084. * Gets or sets the radius used to render the hover light (default is 1.0)
  78085. */
  78086. hoverRadius: number;
  78087. /**
  78088. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78089. */
  78090. hoverColor: BABYLON.Color4;
  78091. /**
  78092. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78093. */
  78094. hoverPosition: BABYLON.Vector3;
  78095. private _albedoTexture;
  78096. /** Gets or sets the texture to use for albedo color */
  78097. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78098. /**
  78099. * Creates a new Fluent material
  78100. * @param name defines the name of the material
  78101. * @param scene defines the hosting scene
  78102. */
  78103. constructor(name: string, scene: BABYLON.Scene);
  78104. needAlphaBlending(): boolean;
  78105. needAlphaTesting(): boolean;
  78106. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78107. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78108. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78109. getActiveTextures(): BABYLON.BaseTexture[];
  78110. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78111. dispose(forceDisposeEffect?: boolean): void;
  78112. clone(name: string): FluentMaterial;
  78113. serialize(): any;
  78114. getClassName(): string;
  78115. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78116. }
  78117. }
  78118. declare module BABYLON.GUI {
  78119. /**
  78120. * Class used to create a holographic button in 3D
  78121. */
  78122. export class HolographicButton extends Button3D {
  78123. private _backPlate;
  78124. private _textPlate;
  78125. private _frontPlate;
  78126. private _text;
  78127. private _imageUrl;
  78128. private _shareMaterials;
  78129. private _frontMaterial;
  78130. private _backMaterial;
  78131. private _plateMaterial;
  78132. private _pickedPointObserver;
  78133. private _tooltipFade;
  78134. private _tooltipTextBlock;
  78135. private _tooltipTexture;
  78136. private _tooltipMesh;
  78137. private _tooltipHoverObserver;
  78138. private _tooltipOutObserver;
  78139. private _disposeTooltip;
  78140. /**
  78141. * Rendering ground id of all the mesh in the button
  78142. */
  78143. set renderingGroupId(id: number);
  78144. get renderingGroupId(): number;
  78145. /**
  78146. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78147. */
  78148. set tooltipText(text: BABYLON.Nullable<string>);
  78149. get tooltipText(): BABYLON.Nullable<string>;
  78150. /**
  78151. * Gets or sets text for the button
  78152. */
  78153. get text(): string;
  78154. set text(value: string);
  78155. /**
  78156. * Gets or sets the image url for the button
  78157. */
  78158. get imageUrl(): string;
  78159. set imageUrl(value: string);
  78160. /**
  78161. * Gets the back material used by this button
  78162. */
  78163. get backMaterial(): FluentMaterial;
  78164. /**
  78165. * Gets the front material used by this button
  78166. */
  78167. get frontMaterial(): FluentMaterial;
  78168. /**
  78169. * Gets the plate material used by this button
  78170. */
  78171. get plateMaterial(): BABYLON.StandardMaterial;
  78172. /**
  78173. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78174. */
  78175. get shareMaterials(): boolean;
  78176. /**
  78177. * Creates a new button
  78178. * @param name defines the control name
  78179. */
  78180. constructor(name?: string, shareMaterials?: boolean);
  78181. protected _getTypeName(): string;
  78182. private _rebuildContent;
  78183. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78184. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78185. private _createBackMaterial;
  78186. private _createFrontMaterial;
  78187. private _createPlateMaterial;
  78188. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78189. /**
  78190. * Releases all associated resources
  78191. */
  78192. dispose(): void;
  78193. }
  78194. }
  78195. declare module BABYLON.GUI {
  78196. /**
  78197. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78198. */
  78199. export class MeshButton3D extends Button3D {
  78200. /** @hidden */
  78201. protected _currentMesh: BABYLON.Mesh;
  78202. /**
  78203. * Creates a new 3D button based on a mesh
  78204. * @param mesh mesh to become a 3D button
  78205. * @param name defines the control name
  78206. */
  78207. constructor(mesh: BABYLON.Mesh, name?: string);
  78208. protected _getTypeName(): string;
  78209. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78210. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78211. }
  78212. }
  78213. declare module BABYLON.GUI {
  78214. /**
  78215. * Class used to create a container panel deployed on the surface of a plane
  78216. */
  78217. export class PlanePanel extends VolumeBasedPanel {
  78218. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78219. }
  78220. }
  78221. declare module BABYLON.GUI {
  78222. /**
  78223. * Class used to create a container panel where items get randomized planar mapping
  78224. */
  78225. export class ScatterPanel extends VolumeBasedPanel {
  78226. private _iteration;
  78227. /**
  78228. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78229. */
  78230. get iteration(): BABYLON.float;
  78231. set iteration(value: BABYLON.float);
  78232. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78233. private _scatterMapping;
  78234. protected _finalProcessing(): void;
  78235. }
  78236. }
  78237. declare module BABYLON.GUI {
  78238. /**
  78239. * Class used to create a container panel deployed on the surface of a sphere
  78240. */
  78241. export class SpherePanel extends VolumeBasedPanel {
  78242. private _radius;
  78243. /**
  78244. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78245. */
  78246. get radius(): BABYLON.float;
  78247. set radius(value: BABYLON.float);
  78248. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78249. private _sphericalMapping;
  78250. }
  78251. }
  78252. declare module BABYLON.GUI {
  78253. /**
  78254. * Class used to create a stack panel in 3D on XY plane
  78255. */
  78256. export class StackPanel3D extends Container3D {
  78257. private _isVertical;
  78258. /**
  78259. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78260. */
  78261. get isVertical(): boolean;
  78262. set isVertical(value: boolean);
  78263. /**
  78264. * Gets or sets the distance between elements
  78265. */
  78266. margin: number;
  78267. /**
  78268. * Creates new StackPanel
  78269. * @param isVertical
  78270. */
  78271. constructor(isVertical?: boolean);
  78272. protected _arrangeChildren(): void;
  78273. }
  78274. }
  78275. declare module BABYLON {
  78276. /**
  78277. * Configuration for glTF validation
  78278. */
  78279. export interface IGLTFValidationConfiguration {
  78280. /**
  78281. * The url of the glTF validator.
  78282. */
  78283. url: string;
  78284. }
  78285. /**
  78286. * glTF validation
  78287. */
  78288. export class GLTFValidation {
  78289. /**
  78290. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78291. */
  78292. static Configuration: IGLTFValidationConfiguration;
  78293. private static _LoadScriptPromise;
  78294. /**
  78295. * Validate a glTF asset using the glTF-Validator.
  78296. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78297. * @param rootUrl The root url for the glTF
  78298. * @param fileName The file name for the glTF
  78299. * @param getExternalResource The callback to get external resources for the glTF validator
  78300. * @returns A promise that resolves with the glTF validation results once complete
  78301. */
  78302. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78303. }
  78304. }
  78305. declare module BABYLON {
  78306. /**
  78307. * Mode that determines the coordinate system to use.
  78308. */
  78309. export enum GLTFLoaderCoordinateSystemMode {
  78310. /**
  78311. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78312. */
  78313. AUTO = 0,
  78314. /**
  78315. * Sets the useRightHandedSystem flag on the scene.
  78316. */
  78317. FORCE_RIGHT_HANDED = 1
  78318. }
  78319. /**
  78320. * Mode that determines what animations will start.
  78321. */
  78322. export enum GLTFLoaderAnimationStartMode {
  78323. /**
  78324. * No animation will start.
  78325. */
  78326. NONE = 0,
  78327. /**
  78328. * The first animation will start.
  78329. */
  78330. FIRST = 1,
  78331. /**
  78332. * All animations will start.
  78333. */
  78334. ALL = 2
  78335. }
  78336. /**
  78337. * Interface that contains the data for the glTF asset.
  78338. */
  78339. export interface IGLTFLoaderData {
  78340. /**
  78341. * The object that represents the glTF JSON.
  78342. */
  78343. json: Object;
  78344. /**
  78345. * The BIN chunk of a binary glTF.
  78346. */
  78347. bin: Nullable<IDataBuffer>;
  78348. }
  78349. /**
  78350. * Interface for extending the loader.
  78351. */
  78352. export interface IGLTFLoaderExtension {
  78353. /**
  78354. * The name of this extension.
  78355. */
  78356. readonly name: string;
  78357. /**
  78358. * Defines whether this extension is enabled.
  78359. */
  78360. enabled: boolean;
  78361. /**
  78362. * Defines the order of this extension.
  78363. * The loader sorts the extensions using these values when loading.
  78364. */
  78365. order?: number;
  78366. }
  78367. /**
  78368. * Loader state.
  78369. */
  78370. export enum GLTFLoaderState {
  78371. /**
  78372. * The asset is loading.
  78373. */
  78374. LOADING = 0,
  78375. /**
  78376. * The asset is ready for rendering.
  78377. */
  78378. READY = 1,
  78379. /**
  78380. * The asset is completely loaded.
  78381. */
  78382. COMPLETE = 2
  78383. }
  78384. /** @hidden */
  78385. export interface IImportMeshAsyncOutput {
  78386. meshes: AbstractMesh[];
  78387. particleSystems: IParticleSystem[];
  78388. skeletons: Skeleton[];
  78389. animationGroups: AnimationGroup[];
  78390. lights: Light[];
  78391. transformNodes: TransformNode[];
  78392. }
  78393. /** @hidden */
  78394. export interface IGLTFLoader extends IDisposable {
  78395. readonly state: Nullable<GLTFLoaderState>;
  78396. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78397. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78398. }
  78399. /**
  78400. * File loader for loading glTF files into a scene.
  78401. */
  78402. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78403. /** @hidden */
  78404. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78405. /** @hidden */
  78406. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78407. /**
  78408. * Raised when the asset has been parsed
  78409. */
  78410. onParsedObservable: Observable<IGLTFLoaderData>;
  78411. private _onParsedObserver;
  78412. /**
  78413. * Raised when the asset has been parsed
  78414. */
  78415. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78416. /**
  78417. * 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.
  78418. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78419. * Defaults to true.
  78420. * @hidden
  78421. */
  78422. static IncrementalLoading: boolean;
  78423. /**
  78424. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78425. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78426. * @hidden
  78427. */
  78428. static HomogeneousCoordinates: boolean;
  78429. /**
  78430. * The coordinate system mode. Defaults to AUTO.
  78431. */
  78432. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78433. /**
  78434. * The animation start mode. Defaults to FIRST.
  78435. */
  78436. animationStartMode: GLTFLoaderAnimationStartMode;
  78437. /**
  78438. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78439. */
  78440. compileMaterials: boolean;
  78441. /**
  78442. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78443. */
  78444. useClipPlane: boolean;
  78445. /**
  78446. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78447. */
  78448. compileShadowGenerators: boolean;
  78449. /**
  78450. * Defines if the Alpha blended materials are only applied as coverage.
  78451. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78452. * If true, no extra effects are applied to transparent pixels.
  78453. */
  78454. transparencyAsCoverage: boolean;
  78455. /**
  78456. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78457. * Enabling will disable offline support and glTF validator.
  78458. * Defaults to false.
  78459. */
  78460. useRangeRequests: boolean;
  78461. /**
  78462. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78463. */
  78464. createInstances: boolean;
  78465. /**
  78466. * Function called before loading a url referenced by the asset.
  78467. */
  78468. preprocessUrlAsync: (url: string) => Promise<string>;
  78469. /**
  78470. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78471. */
  78472. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78473. private _onMeshLoadedObserver;
  78474. /**
  78475. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78476. */
  78477. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78478. /**
  78479. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78480. */
  78481. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78482. private _onTextureLoadedObserver;
  78483. /**
  78484. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78485. */
  78486. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78487. /**
  78488. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78489. */
  78490. readonly onMaterialLoadedObservable: Observable<Material>;
  78491. private _onMaterialLoadedObserver;
  78492. /**
  78493. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78494. */
  78495. set onMaterialLoaded(callback: (material: Material) => void);
  78496. /**
  78497. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78498. */
  78499. readonly onCameraLoadedObservable: Observable<Camera>;
  78500. private _onCameraLoadedObserver;
  78501. /**
  78502. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78503. */
  78504. set onCameraLoaded(callback: (camera: Camera) => void);
  78505. /**
  78506. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78507. * For assets with LODs, raised when all of the LODs are complete.
  78508. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78509. */
  78510. readonly onCompleteObservable: Observable<void>;
  78511. private _onCompleteObserver;
  78512. /**
  78513. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78514. * For assets with LODs, raised when all of the LODs are complete.
  78515. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78516. */
  78517. set onComplete(callback: () => void);
  78518. /**
  78519. * Observable raised when an error occurs.
  78520. */
  78521. readonly onErrorObservable: Observable<any>;
  78522. private _onErrorObserver;
  78523. /**
  78524. * Callback raised when an error occurs.
  78525. */
  78526. set onError(callback: (reason: any) => void);
  78527. /**
  78528. * Observable raised after the loader is disposed.
  78529. */
  78530. readonly onDisposeObservable: Observable<void>;
  78531. private _onDisposeObserver;
  78532. /**
  78533. * Callback raised after the loader is disposed.
  78534. */
  78535. set onDispose(callback: () => void);
  78536. /**
  78537. * Observable raised after a loader extension is created.
  78538. * Set additional options for a loader extension in this event.
  78539. */
  78540. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78541. private _onExtensionLoadedObserver;
  78542. /**
  78543. * Callback raised after a loader extension is created.
  78544. */
  78545. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78546. /**
  78547. * Defines if the loader logging is enabled.
  78548. */
  78549. get loggingEnabled(): boolean;
  78550. set loggingEnabled(value: boolean);
  78551. /**
  78552. * Defines if the loader should capture performance counters.
  78553. */
  78554. get capturePerformanceCounters(): boolean;
  78555. set capturePerformanceCounters(value: boolean);
  78556. /**
  78557. * Defines if the loader should validate the asset.
  78558. */
  78559. validate: boolean;
  78560. /**
  78561. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78562. */
  78563. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78564. private _onValidatedObserver;
  78565. /**
  78566. * Callback raised after a loader extension is created.
  78567. */
  78568. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78569. private _loader;
  78570. /**
  78571. * Name of the loader ("gltf")
  78572. */
  78573. name: string;
  78574. /** @hidden */
  78575. extensions: ISceneLoaderPluginExtensions;
  78576. /**
  78577. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78578. */
  78579. dispose(): void;
  78580. /** @hidden */
  78581. _clear(): void;
  78582. /** @hidden */
  78583. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78584. /** @hidden */
  78585. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78586. /** @hidden */
  78587. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78588. meshes: AbstractMesh[];
  78589. particleSystems: IParticleSystem[];
  78590. skeletons: Skeleton[];
  78591. animationGroups: AnimationGroup[];
  78592. }>;
  78593. /** @hidden */
  78594. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78595. /** @hidden */
  78596. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78597. /** @hidden */
  78598. canDirectLoad(data: string): boolean;
  78599. /** @hidden */
  78600. directLoad(scene: Scene, data: string): any;
  78601. /**
  78602. * The callback that allows custom handling of the root url based on the response url.
  78603. * @param rootUrl the original root url
  78604. * @param responseURL the response url if available
  78605. * @returns the new root url
  78606. */
  78607. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78608. /** @hidden */
  78609. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78610. /**
  78611. * The loader state or null if the loader is not active.
  78612. */
  78613. get loaderState(): Nullable<GLTFLoaderState>;
  78614. /**
  78615. * Returns a promise that resolves when the asset is completely loaded.
  78616. * @returns a promise that resolves when the asset is completely loaded.
  78617. */
  78618. whenCompleteAsync(): Promise<void>;
  78619. private _validate;
  78620. private _getLoader;
  78621. private _parseJson;
  78622. private _unpackBinaryAsync;
  78623. private _unpackBinaryV1Async;
  78624. private _unpackBinaryV2Async;
  78625. private static _parseVersion;
  78626. private static _compareVersion;
  78627. private static readonly _logSpaces;
  78628. private _logIndentLevel;
  78629. private _loggingEnabled;
  78630. /** @hidden */
  78631. _log: (message: string) => void;
  78632. /** @hidden */
  78633. _logOpen(message: string): void;
  78634. /** @hidden */
  78635. _logClose(): void;
  78636. private _logEnabled;
  78637. private _logDisabled;
  78638. private _capturePerformanceCounters;
  78639. /** @hidden */
  78640. _startPerformanceCounter: (counterName: string) => void;
  78641. /** @hidden */
  78642. _endPerformanceCounter: (counterName: string) => void;
  78643. private _startPerformanceCounterEnabled;
  78644. private _startPerformanceCounterDisabled;
  78645. private _endPerformanceCounterEnabled;
  78646. private _endPerformanceCounterDisabled;
  78647. }
  78648. }
  78649. declare module BABYLON.GLTF1 {
  78650. /**
  78651. * Enums
  78652. * @hidden
  78653. */
  78654. export enum EComponentType {
  78655. BYTE = 5120,
  78656. UNSIGNED_BYTE = 5121,
  78657. SHORT = 5122,
  78658. UNSIGNED_SHORT = 5123,
  78659. FLOAT = 5126
  78660. }
  78661. /** @hidden */
  78662. export enum EShaderType {
  78663. FRAGMENT = 35632,
  78664. VERTEX = 35633
  78665. }
  78666. /** @hidden */
  78667. export enum EParameterType {
  78668. BYTE = 5120,
  78669. UNSIGNED_BYTE = 5121,
  78670. SHORT = 5122,
  78671. UNSIGNED_SHORT = 5123,
  78672. INT = 5124,
  78673. UNSIGNED_INT = 5125,
  78674. FLOAT = 5126,
  78675. FLOAT_VEC2 = 35664,
  78676. FLOAT_VEC3 = 35665,
  78677. FLOAT_VEC4 = 35666,
  78678. INT_VEC2 = 35667,
  78679. INT_VEC3 = 35668,
  78680. INT_VEC4 = 35669,
  78681. BOOL = 35670,
  78682. BOOL_VEC2 = 35671,
  78683. BOOL_VEC3 = 35672,
  78684. BOOL_VEC4 = 35673,
  78685. FLOAT_MAT2 = 35674,
  78686. FLOAT_MAT3 = 35675,
  78687. FLOAT_MAT4 = 35676,
  78688. SAMPLER_2D = 35678
  78689. }
  78690. /** @hidden */
  78691. export enum ETextureWrapMode {
  78692. CLAMP_TO_EDGE = 33071,
  78693. MIRRORED_REPEAT = 33648,
  78694. REPEAT = 10497
  78695. }
  78696. /** @hidden */
  78697. export enum ETextureFilterType {
  78698. NEAREST = 9728,
  78699. LINEAR = 9728,
  78700. NEAREST_MIPMAP_NEAREST = 9984,
  78701. LINEAR_MIPMAP_NEAREST = 9985,
  78702. NEAREST_MIPMAP_LINEAR = 9986,
  78703. LINEAR_MIPMAP_LINEAR = 9987
  78704. }
  78705. /** @hidden */
  78706. export enum ETextureFormat {
  78707. ALPHA = 6406,
  78708. RGB = 6407,
  78709. RGBA = 6408,
  78710. LUMINANCE = 6409,
  78711. LUMINANCE_ALPHA = 6410
  78712. }
  78713. /** @hidden */
  78714. export enum ECullingType {
  78715. FRONT = 1028,
  78716. BACK = 1029,
  78717. FRONT_AND_BACK = 1032
  78718. }
  78719. /** @hidden */
  78720. export enum EBlendingFunction {
  78721. ZERO = 0,
  78722. ONE = 1,
  78723. SRC_COLOR = 768,
  78724. ONE_MINUS_SRC_COLOR = 769,
  78725. DST_COLOR = 774,
  78726. ONE_MINUS_DST_COLOR = 775,
  78727. SRC_ALPHA = 770,
  78728. ONE_MINUS_SRC_ALPHA = 771,
  78729. DST_ALPHA = 772,
  78730. ONE_MINUS_DST_ALPHA = 773,
  78731. CONSTANT_COLOR = 32769,
  78732. ONE_MINUS_CONSTANT_COLOR = 32770,
  78733. CONSTANT_ALPHA = 32771,
  78734. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78735. SRC_ALPHA_SATURATE = 776
  78736. }
  78737. /** @hidden */
  78738. export interface IGLTFProperty {
  78739. extensions?: {
  78740. [key: string]: any;
  78741. };
  78742. extras?: Object;
  78743. }
  78744. /** @hidden */
  78745. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78746. name?: string;
  78747. }
  78748. /** @hidden */
  78749. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78750. bufferView: string;
  78751. byteOffset: number;
  78752. byteStride: number;
  78753. count: number;
  78754. type: string;
  78755. componentType: EComponentType;
  78756. max?: number[];
  78757. min?: number[];
  78758. name?: string;
  78759. }
  78760. /** @hidden */
  78761. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78762. buffer: string;
  78763. byteOffset: number;
  78764. byteLength: number;
  78765. byteStride: number;
  78766. target?: number;
  78767. }
  78768. /** @hidden */
  78769. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78770. uri: string;
  78771. byteLength?: number;
  78772. type?: string;
  78773. }
  78774. /** @hidden */
  78775. export interface IGLTFShader extends IGLTFChildRootProperty {
  78776. uri: string;
  78777. type: EShaderType;
  78778. }
  78779. /** @hidden */
  78780. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78781. attributes: string[];
  78782. fragmentShader: string;
  78783. vertexShader: string;
  78784. }
  78785. /** @hidden */
  78786. export interface IGLTFTechniqueParameter {
  78787. type: number;
  78788. count?: number;
  78789. semantic?: string;
  78790. node?: string;
  78791. value?: number | boolean | string | Array<any>;
  78792. source?: string;
  78793. babylonValue?: any;
  78794. }
  78795. /** @hidden */
  78796. export interface IGLTFTechniqueCommonProfile {
  78797. lightingModel: string;
  78798. texcoordBindings: Object;
  78799. parameters?: Array<any>;
  78800. }
  78801. /** @hidden */
  78802. export interface IGLTFTechniqueStatesFunctions {
  78803. blendColor?: number[];
  78804. blendEquationSeparate?: number[];
  78805. blendFuncSeparate?: number[];
  78806. colorMask: boolean[];
  78807. cullFace: number[];
  78808. }
  78809. /** @hidden */
  78810. export interface IGLTFTechniqueStates {
  78811. enable: number[];
  78812. functions: IGLTFTechniqueStatesFunctions;
  78813. }
  78814. /** @hidden */
  78815. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78816. parameters: {
  78817. [key: string]: IGLTFTechniqueParameter;
  78818. };
  78819. program: string;
  78820. attributes: {
  78821. [key: string]: string;
  78822. };
  78823. uniforms: {
  78824. [key: string]: string;
  78825. };
  78826. states: IGLTFTechniqueStates;
  78827. }
  78828. /** @hidden */
  78829. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78830. technique?: string;
  78831. values: string[];
  78832. }
  78833. /** @hidden */
  78834. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78835. attributes: {
  78836. [key: string]: string;
  78837. };
  78838. indices: string;
  78839. material: string;
  78840. mode?: number;
  78841. }
  78842. /** @hidden */
  78843. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78844. primitives: IGLTFMeshPrimitive[];
  78845. }
  78846. /** @hidden */
  78847. export interface IGLTFImage extends IGLTFChildRootProperty {
  78848. uri: string;
  78849. }
  78850. /** @hidden */
  78851. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78852. magFilter?: number;
  78853. minFilter?: number;
  78854. wrapS?: number;
  78855. wrapT?: number;
  78856. }
  78857. /** @hidden */
  78858. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78859. sampler: string;
  78860. source: string;
  78861. format?: ETextureFormat;
  78862. internalFormat?: ETextureFormat;
  78863. target?: number;
  78864. type?: number;
  78865. babylonTexture?: Texture;
  78866. }
  78867. /** @hidden */
  78868. export interface IGLTFAmbienLight {
  78869. color?: number[];
  78870. }
  78871. /** @hidden */
  78872. export interface IGLTFDirectionalLight {
  78873. color?: number[];
  78874. }
  78875. /** @hidden */
  78876. export interface IGLTFPointLight {
  78877. color?: number[];
  78878. constantAttenuation?: number;
  78879. linearAttenuation?: number;
  78880. quadraticAttenuation?: number;
  78881. }
  78882. /** @hidden */
  78883. export interface IGLTFSpotLight {
  78884. color?: number[];
  78885. constantAttenuation?: number;
  78886. fallOfAngle?: number;
  78887. fallOffExponent?: number;
  78888. linearAttenuation?: number;
  78889. quadraticAttenuation?: number;
  78890. }
  78891. /** @hidden */
  78892. export interface IGLTFLight extends IGLTFChildRootProperty {
  78893. type: string;
  78894. }
  78895. /** @hidden */
  78896. export interface IGLTFCameraOrthographic {
  78897. xmag: number;
  78898. ymag: number;
  78899. zfar: number;
  78900. znear: number;
  78901. }
  78902. /** @hidden */
  78903. export interface IGLTFCameraPerspective {
  78904. aspectRatio: number;
  78905. yfov: number;
  78906. zfar: number;
  78907. znear: number;
  78908. }
  78909. /** @hidden */
  78910. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78911. type: string;
  78912. }
  78913. /** @hidden */
  78914. export interface IGLTFAnimationChannelTarget {
  78915. id: string;
  78916. path: string;
  78917. }
  78918. /** @hidden */
  78919. export interface IGLTFAnimationChannel {
  78920. sampler: string;
  78921. target: IGLTFAnimationChannelTarget;
  78922. }
  78923. /** @hidden */
  78924. export interface IGLTFAnimationSampler {
  78925. input: string;
  78926. output: string;
  78927. interpolation?: string;
  78928. }
  78929. /** @hidden */
  78930. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78931. channels?: IGLTFAnimationChannel[];
  78932. parameters?: {
  78933. [key: string]: string;
  78934. };
  78935. samplers?: {
  78936. [key: string]: IGLTFAnimationSampler;
  78937. };
  78938. }
  78939. /** @hidden */
  78940. export interface IGLTFNodeInstanceSkin {
  78941. skeletons: string[];
  78942. skin: string;
  78943. meshes: string[];
  78944. }
  78945. /** @hidden */
  78946. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78947. bindShapeMatrix: number[];
  78948. inverseBindMatrices: string;
  78949. jointNames: string[];
  78950. babylonSkeleton?: Skeleton;
  78951. }
  78952. /** @hidden */
  78953. export interface IGLTFNode extends IGLTFChildRootProperty {
  78954. camera?: string;
  78955. children: string[];
  78956. skin?: string;
  78957. jointName?: string;
  78958. light?: string;
  78959. matrix: number[];
  78960. mesh?: string;
  78961. meshes?: string[];
  78962. rotation?: number[];
  78963. scale?: number[];
  78964. translation?: number[];
  78965. babylonNode?: Node;
  78966. }
  78967. /** @hidden */
  78968. export interface IGLTFScene extends IGLTFChildRootProperty {
  78969. nodes: string[];
  78970. }
  78971. /** @hidden */
  78972. export interface IGLTFRuntime {
  78973. extensions: {
  78974. [key: string]: any;
  78975. };
  78976. accessors: {
  78977. [key: string]: IGLTFAccessor;
  78978. };
  78979. buffers: {
  78980. [key: string]: IGLTFBuffer;
  78981. };
  78982. bufferViews: {
  78983. [key: string]: IGLTFBufferView;
  78984. };
  78985. meshes: {
  78986. [key: string]: IGLTFMesh;
  78987. };
  78988. lights: {
  78989. [key: string]: IGLTFLight;
  78990. };
  78991. cameras: {
  78992. [key: string]: IGLTFCamera;
  78993. };
  78994. nodes: {
  78995. [key: string]: IGLTFNode;
  78996. };
  78997. images: {
  78998. [key: string]: IGLTFImage;
  78999. };
  79000. textures: {
  79001. [key: string]: IGLTFTexture;
  79002. };
  79003. shaders: {
  79004. [key: string]: IGLTFShader;
  79005. };
  79006. programs: {
  79007. [key: string]: IGLTFProgram;
  79008. };
  79009. samplers: {
  79010. [key: string]: IGLTFSampler;
  79011. };
  79012. techniques: {
  79013. [key: string]: IGLTFTechnique;
  79014. };
  79015. materials: {
  79016. [key: string]: IGLTFMaterial;
  79017. };
  79018. animations: {
  79019. [key: string]: IGLTFAnimation;
  79020. };
  79021. skins: {
  79022. [key: string]: IGLTFSkins;
  79023. };
  79024. currentScene?: Object;
  79025. scenes: {
  79026. [key: string]: IGLTFScene;
  79027. };
  79028. extensionsUsed: string[];
  79029. extensionsRequired?: string[];
  79030. buffersCount: number;
  79031. shaderscount: number;
  79032. scene: Scene;
  79033. rootUrl: string;
  79034. loadedBufferCount: number;
  79035. loadedBufferViews: {
  79036. [name: string]: ArrayBufferView;
  79037. };
  79038. loadedShaderCount: number;
  79039. importOnlyMeshes: boolean;
  79040. importMeshesNames?: string[];
  79041. dummyNodes: Node[];
  79042. forAssetContainer: boolean;
  79043. }
  79044. /** @hidden */
  79045. export interface INodeToRoot {
  79046. bone: Bone;
  79047. node: IGLTFNode;
  79048. id: string;
  79049. }
  79050. /** @hidden */
  79051. export interface IJointNode {
  79052. node: IGLTFNode;
  79053. id: string;
  79054. }
  79055. }
  79056. declare module BABYLON.GLTF1 {
  79057. /**
  79058. * Utils functions for GLTF
  79059. * @hidden
  79060. */
  79061. export class GLTFUtils {
  79062. /**
  79063. * Sets the given "parameter" matrix
  79064. * @param scene: the Scene object
  79065. * @param source: the source node where to pick the matrix
  79066. * @param parameter: the GLTF technique parameter
  79067. * @param uniformName: the name of the shader's uniform
  79068. * @param shaderMaterial: the shader material
  79069. */
  79070. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79071. /**
  79072. * Sets the given "parameter" matrix
  79073. * @param shaderMaterial: the shader material
  79074. * @param uniform: the name of the shader's uniform
  79075. * @param value: the value of the uniform
  79076. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79077. */
  79078. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79079. /**
  79080. * Returns the wrap mode of the texture
  79081. * @param mode: the mode value
  79082. */
  79083. static GetWrapMode(mode: number): number;
  79084. /**
  79085. * Returns the byte stride giving an accessor
  79086. * @param accessor: the GLTF accessor objet
  79087. */
  79088. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79089. /**
  79090. * Returns the texture filter mode giving a mode value
  79091. * @param mode: the filter mode value
  79092. */
  79093. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79094. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79095. /**
  79096. * Returns a buffer from its accessor
  79097. * @param gltfRuntime: the GLTF runtime
  79098. * @param accessor: the GLTF accessor
  79099. */
  79100. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79101. /**
  79102. * Decodes a buffer view into a string
  79103. * @param view: the buffer view
  79104. */
  79105. static DecodeBufferToText(view: ArrayBufferView): string;
  79106. /**
  79107. * Returns the default material of gltf. Related to
  79108. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79109. * @param scene: the Babylon.js scene
  79110. */
  79111. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79112. private static _DefaultMaterial;
  79113. }
  79114. }
  79115. declare module BABYLON.GLTF1 {
  79116. /**
  79117. * Implementation of the base glTF spec
  79118. * @hidden
  79119. */
  79120. export class GLTFLoaderBase {
  79121. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79122. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79123. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79124. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79125. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79126. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79127. }
  79128. /**
  79129. * glTF V1 Loader
  79130. * @hidden
  79131. */
  79132. export class GLTFLoader implements IGLTFLoader {
  79133. static Extensions: {
  79134. [name: string]: GLTFLoaderExtension;
  79135. };
  79136. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79137. state: Nullable<GLTFLoaderState>;
  79138. dispose(): void;
  79139. private _importMeshAsync;
  79140. /**
  79141. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79142. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79143. * @param scene the scene the meshes should be added to
  79144. * @param forAssetContainer defines if the entities must be stored in the scene
  79145. * @param data gltf data containing information of the meshes in a loaded file
  79146. * @param rootUrl root url to load from
  79147. * @param onProgress event that fires when loading progress has occured
  79148. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79149. */
  79150. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79151. private _loadAsync;
  79152. /**
  79153. * Imports all objects from a loaded gltf file and adds them to the scene
  79154. * @param scene the scene the objects should be added to
  79155. * @param data gltf data containing information of the meshes in a loaded file
  79156. * @param rootUrl root url to load from
  79157. * @param onProgress event that fires when loading progress has occured
  79158. * @returns a promise which completes when objects have been loaded to the scene
  79159. */
  79160. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  79161. private _loadShadersAsync;
  79162. private _loadBuffersAsync;
  79163. private _createNodes;
  79164. }
  79165. /** @hidden */
  79166. export abstract class GLTFLoaderExtension {
  79167. private _name;
  79168. constructor(name: string);
  79169. get name(): string;
  79170. /**
  79171. * Defines an override for loading the runtime
  79172. * Return true to stop further extensions from loading the runtime
  79173. */
  79174. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79175. /**
  79176. * Defines an onverride for creating gltf runtime
  79177. * Return true to stop further extensions from creating the runtime
  79178. */
  79179. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79180. /**
  79181. * Defines an override for loading buffers
  79182. * Return true to stop further extensions from loading this buffer
  79183. */
  79184. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79185. /**
  79186. * Defines an override for loading texture buffers
  79187. * Return true to stop further extensions from loading this texture data
  79188. */
  79189. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79190. /**
  79191. * Defines an override for creating textures
  79192. * Return true to stop further extensions from loading this texture
  79193. */
  79194. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79195. /**
  79196. * Defines an override for loading shader strings
  79197. * Return true to stop further extensions from loading this shader data
  79198. */
  79199. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79200. /**
  79201. * Defines an override for loading materials
  79202. * Return true to stop further extensions from loading this material
  79203. */
  79204. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79205. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79206. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79207. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79208. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79209. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79210. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79211. private static LoadTextureBufferAsync;
  79212. private static CreateTextureAsync;
  79213. private static ApplyExtensions;
  79214. }
  79215. }
  79216. declare module BABYLON.GLTF1 {
  79217. /** @hidden */
  79218. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79219. private _bin;
  79220. constructor();
  79221. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79222. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79223. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79224. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79225. }
  79226. }
  79227. declare module BABYLON.GLTF1 {
  79228. /** @hidden */
  79229. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79230. constructor();
  79231. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79232. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79233. private _loadTexture;
  79234. }
  79235. }
  79236. declare module BABYLON.GLTF2.Loader {
  79237. /**
  79238. * Loader interface with an index field.
  79239. */
  79240. export interface IArrayItem {
  79241. /**
  79242. * The index of this item in the array.
  79243. */
  79244. index: number;
  79245. }
  79246. /**
  79247. * Loader interface with additional members.
  79248. */
  79249. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79250. /** @hidden */
  79251. _data?: Promise<ArrayBufferView>;
  79252. /** @hidden */
  79253. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79254. }
  79255. /**
  79256. * Loader interface with additional members.
  79257. */
  79258. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79259. }
  79260. /** @hidden */
  79261. export interface _IAnimationSamplerData {
  79262. input: Float32Array;
  79263. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79264. output: Float32Array;
  79265. }
  79266. /**
  79267. * Loader interface with additional members.
  79268. */
  79269. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79270. /** @hidden */
  79271. _data?: Promise<_IAnimationSamplerData>;
  79272. }
  79273. /**
  79274. * Loader interface with additional members.
  79275. */
  79276. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79277. channels: IAnimationChannel[];
  79278. samplers: IAnimationSampler[];
  79279. /** @hidden */
  79280. _babylonAnimationGroup?: AnimationGroup;
  79281. }
  79282. /**
  79283. * Loader interface with additional members.
  79284. */
  79285. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79286. /** @hidden */
  79287. _data?: Promise<ArrayBufferView>;
  79288. }
  79289. /**
  79290. * Loader interface with additional members.
  79291. */
  79292. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79293. /** @hidden */
  79294. _data?: Promise<ArrayBufferView>;
  79295. /** @hidden */
  79296. _babylonBuffer?: Promise<Buffer>;
  79297. }
  79298. /**
  79299. * Loader interface with additional members.
  79300. */
  79301. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79302. }
  79303. /**
  79304. * Loader interface with additional members.
  79305. */
  79306. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79307. /** @hidden */
  79308. _data?: Promise<ArrayBufferView>;
  79309. }
  79310. /**
  79311. * Loader interface with additional members.
  79312. */
  79313. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79314. }
  79315. /**
  79316. * Loader interface with additional members.
  79317. */
  79318. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79319. }
  79320. /**
  79321. * Loader interface with additional members.
  79322. */
  79323. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79324. baseColorTexture?: ITextureInfo;
  79325. metallicRoughnessTexture?: ITextureInfo;
  79326. }
  79327. /**
  79328. * Loader interface with additional members.
  79329. */
  79330. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79331. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79332. normalTexture?: IMaterialNormalTextureInfo;
  79333. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79334. emissiveTexture?: ITextureInfo;
  79335. /** @hidden */
  79336. _data?: {
  79337. [babylonDrawMode: number]: {
  79338. babylonMaterial: Material;
  79339. babylonMeshes: AbstractMesh[];
  79340. promise: Promise<void>;
  79341. };
  79342. };
  79343. }
  79344. /**
  79345. * Loader interface with additional members.
  79346. */
  79347. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79348. primitives: IMeshPrimitive[];
  79349. }
  79350. /**
  79351. * Loader interface with additional members.
  79352. */
  79353. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79354. /** @hidden */
  79355. _instanceData?: {
  79356. babylonSourceMesh: Mesh;
  79357. promise: Promise<any>;
  79358. };
  79359. }
  79360. /**
  79361. * Loader interface with additional members.
  79362. */
  79363. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79364. /**
  79365. * The parent glTF node.
  79366. */
  79367. parent?: INode;
  79368. /** @hidden */
  79369. _babylonTransformNode?: TransformNode;
  79370. /** @hidden */
  79371. _primitiveBabylonMeshes?: AbstractMesh[];
  79372. /** @hidden */
  79373. _babylonBones?: Bone[];
  79374. /** @hidden */
  79375. _numMorphTargets?: number;
  79376. }
  79377. /** @hidden */
  79378. export interface _ISamplerData {
  79379. noMipMaps: boolean;
  79380. samplingMode: number;
  79381. wrapU: number;
  79382. wrapV: number;
  79383. }
  79384. /**
  79385. * Loader interface with additional members.
  79386. */
  79387. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79388. /** @hidden */
  79389. _data?: _ISamplerData;
  79390. }
  79391. /**
  79392. * Loader interface with additional members.
  79393. */
  79394. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79395. }
  79396. /**
  79397. * Loader interface with additional members.
  79398. */
  79399. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79400. /** @hidden */
  79401. _data?: {
  79402. babylonSkeleton: Skeleton;
  79403. promise: Promise<void>;
  79404. };
  79405. }
  79406. /**
  79407. * Loader interface with additional members.
  79408. */
  79409. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79410. }
  79411. /**
  79412. * Loader interface with additional members.
  79413. */
  79414. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79415. }
  79416. /**
  79417. * Loader interface with additional members.
  79418. */
  79419. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79420. accessors?: IAccessor[];
  79421. animations?: IAnimation[];
  79422. buffers?: IBuffer[];
  79423. bufferViews?: IBufferView[];
  79424. cameras?: ICamera[];
  79425. images?: IImage[];
  79426. materials?: IMaterial[];
  79427. meshes?: IMesh[];
  79428. nodes?: INode[];
  79429. samplers?: ISampler[];
  79430. scenes?: IScene[];
  79431. skins?: ISkin[];
  79432. textures?: ITexture[];
  79433. }
  79434. }
  79435. declare module BABYLON.GLTF2 {
  79436. /**
  79437. * Interface for a glTF loader extension.
  79438. */
  79439. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79440. /**
  79441. * Called after the loader state changes to LOADING.
  79442. */
  79443. onLoading?(): void;
  79444. /**
  79445. * Called after the loader state changes to READY.
  79446. */
  79447. onReady?(): void;
  79448. /**
  79449. * Define this method to modify the default behavior when loading scenes.
  79450. * @param context The context when loading the asset
  79451. * @param scene The glTF scene property
  79452. * @returns A promise that resolves when the load is complete or null if not handled
  79453. */
  79454. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79455. /**
  79456. * Define this method to modify the default behavior when loading nodes.
  79457. * @param context The context when loading the asset
  79458. * @param node The glTF node property
  79459. * @param assign A function called synchronously after parsing the glTF properties
  79460. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79461. */
  79462. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79463. /**
  79464. * Define this method to modify the default behavior when loading cameras.
  79465. * @param context The context when loading the asset
  79466. * @param camera The glTF camera property
  79467. * @param assign A function called synchronously after parsing the glTF properties
  79468. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79469. */
  79470. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79471. /**
  79472. * @hidden
  79473. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79474. * @param context The context when loading the asset
  79475. * @param primitive The glTF mesh primitive property
  79476. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79477. */
  79478. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79479. /**
  79480. * @hidden
  79481. * Define this method to modify the default behavior when loading data for mesh primitives.
  79482. * @param context The context when loading the asset
  79483. * @param name The mesh name when loading the asset
  79484. * @param node The glTF node when loading the asset
  79485. * @param mesh The glTF mesh when loading the asset
  79486. * @param primitive The glTF mesh primitive property
  79487. * @param assign A function called synchronously after parsing the glTF properties
  79488. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79489. */
  79490. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79491. /**
  79492. * @hidden
  79493. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79494. * @param context The context when loading the asset
  79495. * @param material The glTF material property
  79496. * @param assign A function called synchronously after parsing the glTF properties
  79497. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79498. */
  79499. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79500. /**
  79501. * Define this method to modify the default behavior when creating materials.
  79502. * @param context The context when loading the asset
  79503. * @param material The glTF material property
  79504. * @param babylonDrawMode The draw mode for the Babylon material
  79505. * @returns The Babylon material or null if not handled
  79506. */
  79507. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79508. /**
  79509. * Define this method to modify the default behavior when loading material properties.
  79510. * @param context The context when loading the asset
  79511. * @param material The glTF material property
  79512. * @param babylonMaterial The Babylon material
  79513. * @returns A promise that resolves when the load is complete or null if not handled
  79514. */
  79515. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79516. /**
  79517. * Define this method to modify the default behavior when loading texture infos.
  79518. * @param context The context when loading the asset
  79519. * @param textureInfo The glTF texture info property
  79520. * @param assign A function called synchronously after parsing the glTF properties
  79521. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79522. */
  79523. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79524. /**
  79525. * @hidden
  79526. * Define this method to modify the default behavior when loading textures.
  79527. * @param context The context when loading the asset
  79528. * @param texture The glTF texture property
  79529. * @param assign A function called synchronously after parsing the glTF properties
  79530. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79531. */
  79532. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79533. /**
  79534. * Define this method to modify the default behavior when loading animations.
  79535. * @param context The context when loading the asset
  79536. * @param animation The glTF animation property
  79537. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79538. */
  79539. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79540. /**
  79541. * @hidden
  79542. * Define this method to modify the default behavior when loading skins.
  79543. * @param context The context when loading the asset
  79544. * @param node The glTF node property
  79545. * @param skin The glTF skin property
  79546. * @returns A promise that resolves when the load is complete or null if not handled
  79547. */
  79548. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79549. /**
  79550. * @hidden
  79551. * Define this method to modify the default behavior when loading uris.
  79552. * @param context The context when loading the asset
  79553. * @param property The glTF property associated with the uri
  79554. * @param uri The uri to load
  79555. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79556. */
  79557. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79558. /**
  79559. * Define this method to modify the default behavior when loading buffer views.
  79560. * @param context The context when loading the asset
  79561. * @param bufferView The glTF buffer view property
  79562. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79563. */
  79564. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79565. /**
  79566. * Define this method to modify the default behavior when loading buffers.
  79567. * @param context The context when loading the asset
  79568. * @param buffer The glTF buffer property
  79569. * @param byteOffset The byte offset to load
  79570. * @param byteLength The byte length to load
  79571. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79572. */
  79573. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79574. }
  79575. }
  79576. declare module BABYLON.GLTF2 {
  79577. /**
  79578. * Helper class for working with arrays when loading the glTF asset
  79579. */
  79580. export class ArrayItem {
  79581. /**
  79582. * Gets an item from the given array.
  79583. * @param context The context when loading the asset
  79584. * @param array The array to get the item from
  79585. * @param index The index to the array
  79586. * @returns The array item
  79587. */
  79588. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79589. /**
  79590. * Assign an `index` field to each item of the given array.
  79591. * @param array The array of items
  79592. */
  79593. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79594. }
  79595. /**
  79596. * The glTF 2.0 loader
  79597. */
  79598. export class GLTFLoader implements IGLTFLoader {
  79599. /** @hidden */
  79600. _completePromises: Promise<any>[];
  79601. /** @hidden */
  79602. _forAssetContainer: boolean;
  79603. /** Storage */
  79604. _babylonLights: Light[];
  79605. /** @hidden */
  79606. _disableInstancedMesh: number;
  79607. private _disposed;
  79608. private _parent;
  79609. private _state;
  79610. private _extensions;
  79611. private _rootUrl;
  79612. private _fileName;
  79613. private _uniqueRootUrl;
  79614. private _gltf;
  79615. private _bin;
  79616. private _babylonScene;
  79617. private _rootBabylonMesh;
  79618. private _defaultBabylonMaterialData;
  79619. private _progressCallback?;
  79620. private _requests;
  79621. private static _RegisteredExtensions;
  79622. /**
  79623. * The default glTF sampler.
  79624. */
  79625. static readonly DefaultSampler: ISampler;
  79626. /**
  79627. * Registers a loader extension.
  79628. * @param name The name of the loader extension.
  79629. * @param factory The factory function that creates the loader extension.
  79630. */
  79631. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79632. /**
  79633. * Unregisters a loader extension.
  79634. * @param name The name of the loader extension.
  79635. * @returns A boolean indicating whether the extension has been unregistered
  79636. */
  79637. static UnregisterExtension(name: string): boolean;
  79638. /**
  79639. * The loader state.
  79640. */
  79641. get state(): Nullable<GLTFLoaderState>;
  79642. /**
  79643. * The object that represents the glTF JSON.
  79644. */
  79645. get gltf(): IGLTF;
  79646. /**
  79647. * The BIN chunk of a binary glTF.
  79648. */
  79649. get bin(): Nullable<IDataBuffer>;
  79650. /**
  79651. * The parent file loader.
  79652. */
  79653. get parent(): GLTFFileLoader;
  79654. /**
  79655. * The Babylon scene when loading the asset.
  79656. */
  79657. get babylonScene(): Scene;
  79658. /**
  79659. * The root Babylon mesh when loading the asset.
  79660. */
  79661. get rootBabylonMesh(): Mesh;
  79662. /** @hidden */
  79663. constructor(parent: GLTFFileLoader);
  79664. /** @hidden */
  79665. dispose(): void;
  79666. /** @hidden */
  79667. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79668. /** @hidden */
  79669. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79670. private _loadAsync;
  79671. private _loadData;
  79672. private _setupData;
  79673. private _loadExtensions;
  79674. private _checkExtensions;
  79675. private _setState;
  79676. private _createRootNode;
  79677. /**
  79678. * Loads a glTF scene.
  79679. * @param context The context when loading the asset
  79680. * @param scene The glTF scene property
  79681. * @returns A promise that resolves when the load is complete
  79682. */
  79683. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79684. private _forEachPrimitive;
  79685. private _getMeshes;
  79686. private _getTransformNodes;
  79687. private _getSkeletons;
  79688. private _getAnimationGroups;
  79689. private _startAnimations;
  79690. /**
  79691. * Loads a glTF node.
  79692. * @param context The context when loading the asset
  79693. * @param node The glTF node property
  79694. * @param assign A function called synchronously after parsing the glTF properties
  79695. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79696. */
  79697. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79698. private _loadMeshAsync;
  79699. /**
  79700. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79701. * @param context The context when loading the asset
  79702. * @param name The mesh name when loading the asset
  79703. * @param node The glTF node when loading the asset
  79704. * @param mesh The glTF mesh when loading the asset
  79705. * @param primitive The glTF mesh primitive property
  79706. * @param assign A function called synchronously after parsing the glTF properties
  79707. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79708. */
  79709. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79710. private _loadVertexDataAsync;
  79711. private _createMorphTargets;
  79712. private _loadMorphTargetsAsync;
  79713. private _loadMorphTargetVertexDataAsync;
  79714. private static _LoadTransform;
  79715. private _loadSkinAsync;
  79716. private _loadBones;
  79717. private _loadBone;
  79718. private _loadSkinInverseBindMatricesDataAsync;
  79719. private _updateBoneMatrices;
  79720. private _getNodeMatrix;
  79721. /**
  79722. * Loads a glTF camera.
  79723. * @param context The context when loading the asset
  79724. * @param camera The glTF camera property
  79725. * @param assign A function called synchronously after parsing the glTF properties
  79726. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79727. */
  79728. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79729. private _loadAnimationsAsync;
  79730. /**
  79731. * Loads a glTF animation.
  79732. * @param context The context when loading the asset
  79733. * @param animation The glTF animation property
  79734. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79735. */
  79736. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79737. /**
  79738. * @hidden Loads a glTF animation channel.
  79739. * @param context The context when loading the asset
  79740. * @param animationContext The context of the animation when loading the asset
  79741. * @param animation The glTF animation property
  79742. * @param channel The glTF animation channel property
  79743. * @param babylonAnimationGroup The babylon animation group property
  79744. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79745. * @returns A void promise when the channel load is complete
  79746. */
  79747. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79748. private _loadAnimationSamplerAsync;
  79749. private _loadBufferAsync;
  79750. /**
  79751. * Loads a glTF buffer view.
  79752. * @param context The context when loading the asset
  79753. * @param bufferView The glTF buffer view property
  79754. * @returns A promise that resolves with the loaded data when the load is complete
  79755. */
  79756. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79757. private _loadAccessorAsync;
  79758. /** @hidden */
  79759. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79760. private _loadIndicesAccessorAsync;
  79761. private _loadVertexBufferViewAsync;
  79762. private _loadVertexAccessorAsync;
  79763. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79764. /** @hidden */
  79765. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79766. private _createDefaultMaterial;
  79767. /**
  79768. * Creates a Babylon material from a glTF material.
  79769. * @param context The context when loading the asset
  79770. * @param material The glTF material property
  79771. * @param babylonDrawMode The draw mode for the Babylon material
  79772. * @returns The Babylon material
  79773. */
  79774. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79775. /**
  79776. * Loads properties from a glTF material into a Babylon material.
  79777. * @param context The context when loading the asset
  79778. * @param material The glTF material property
  79779. * @param babylonMaterial The Babylon material
  79780. * @returns A promise that resolves when the load is complete
  79781. */
  79782. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79783. /**
  79784. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79785. * @param context The context when loading the asset
  79786. * @param material The glTF material property
  79787. * @param babylonMaterial The Babylon material
  79788. * @returns A promise that resolves when the load is complete
  79789. */
  79790. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79791. /**
  79792. * Loads the alpha properties from a glTF material into a Babylon material.
  79793. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79794. * @param context The context when loading the asset
  79795. * @param material The glTF material property
  79796. * @param babylonMaterial The Babylon material
  79797. */
  79798. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79799. /**
  79800. * Loads a glTF texture info.
  79801. * @param context The context when loading the asset
  79802. * @param textureInfo The glTF texture info property
  79803. * @param assign A function called synchronously after parsing the glTF properties
  79804. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79805. */
  79806. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79807. /** @hidden */
  79808. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79809. /** @hidden */
  79810. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79811. private _loadSampler;
  79812. /**
  79813. * Loads a glTF image.
  79814. * @param context The context when loading the asset
  79815. * @param image The glTF image property
  79816. * @returns A promise that resolves with the loaded data when the load is complete
  79817. */
  79818. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79819. /**
  79820. * Loads a glTF uri.
  79821. * @param context The context when loading the asset
  79822. * @param property The glTF property associated with the uri
  79823. * @param uri The base64 or relative uri
  79824. * @returns A promise that resolves with the loaded data when the load is complete
  79825. */
  79826. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79827. private _onProgress;
  79828. /**
  79829. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79830. * @param babylonObject the Babylon object with metadata
  79831. * @param pointer the JSON pointer
  79832. */
  79833. static AddPointerMetadata(babylonObject: {
  79834. metadata: any;
  79835. }, pointer: string): void;
  79836. private static _GetTextureWrapMode;
  79837. private static _GetTextureSamplingMode;
  79838. private static _GetTypedArrayConstructor;
  79839. private static _GetTypedArray;
  79840. private static _GetNumComponents;
  79841. private static _ValidateUri;
  79842. private static _GetDrawMode;
  79843. private _compileMaterialsAsync;
  79844. private _compileShadowGeneratorsAsync;
  79845. private _forEachExtensions;
  79846. private _applyExtensions;
  79847. private _extensionsOnLoading;
  79848. private _extensionsOnReady;
  79849. private _extensionsLoadSceneAsync;
  79850. private _extensionsLoadNodeAsync;
  79851. private _extensionsLoadCameraAsync;
  79852. private _extensionsLoadVertexDataAsync;
  79853. private _extensionsLoadMeshPrimitiveAsync;
  79854. private _extensionsLoadMaterialAsync;
  79855. private _extensionsCreateMaterial;
  79856. private _extensionsLoadMaterialPropertiesAsync;
  79857. private _extensionsLoadTextureInfoAsync;
  79858. private _extensionsLoadTextureAsync;
  79859. private _extensionsLoadAnimationAsync;
  79860. private _extensionsLoadSkinAsync;
  79861. private _extensionsLoadUriAsync;
  79862. private _extensionsLoadBufferViewAsync;
  79863. private _extensionsLoadBufferAsync;
  79864. /**
  79865. * Helper method called by a loader extension to load an glTF extension.
  79866. * @param context The context when loading the asset
  79867. * @param property The glTF property to load the extension from
  79868. * @param extensionName The name of the extension to load
  79869. * @param actionAsync The action to run
  79870. * @returns The promise returned by actionAsync or null if the extension does not exist
  79871. */
  79872. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79873. /**
  79874. * Helper method called by a loader extension to load a glTF extra.
  79875. * @param context The context when loading the asset
  79876. * @param property The glTF property to load the extra from
  79877. * @param extensionName The name of the extension to load
  79878. * @param actionAsync The action to run
  79879. * @returns The promise returned by actionAsync or null if the extra does not exist
  79880. */
  79881. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79882. /**
  79883. * Checks for presence of an extension.
  79884. * @param name The name of the extension to check
  79885. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79886. */
  79887. isExtensionUsed(name: string): boolean;
  79888. /**
  79889. * Increments the indentation level and logs a message.
  79890. * @param message The message to log
  79891. */
  79892. logOpen(message: string): void;
  79893. /**
  79894. * Decrements the indentation level.
  79895. */
  79896. logClose(): void;
  79897. /**
  79898. * Logs a message
  79899. * @param message The message to log
  79900. */
  79901. log(message: string): void;
  79902. /**
  79903. * Starts a performance counter.
  79904. * @param counterName The name of the performance counter
  79905. */
  79906. startPerformanceCounter(counterName: string): void;
  79907. /**
  79908. * Ends a performance counter.
  79909. * @param counterName The name of the performance counter
  79910. */
  79911. endPerformanceCounter(counterName: string): void;
  79912. }
  79913. }
  79914. declare module BABYLON.GLTF2.Loader.Extensions {
  79915. /**
  79916. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79917. */
  79918. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79919. /**
  79920. * The name of this extension.
  79921. */
  79922. readonly name: string;
  79923. /**
  79924. * Defines whether this extension is enabled.
  79925. */
  79926. enabled: boolean;
  79927. private _loader;
  79928. private _lights?;
  79929. /** @hidden */
  79930. constructor(loader: GLTFLoader);
  79931. /** @hidden */
  79932. dispose(): void;
  79933. /** @hidden */
  79934. onLoading(): void;
  79935. /** @hidden */
  79936. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79937. private _loadLightAsync;
  79938. }
  79939. }
  79940. declare module BABYLON.GLTF2.Loader.Extensions {
  79941. /**
  79942. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79943. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79944. * !!! Experimental Extension Subject to Changes !!!
  79945. */
  79946. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79947. /**
  79948. * The name of this extension.
  79949. */
  79950. readonly name: string;
  79951. /**
  79952. * Defines whether this extension is enabled.
  79953. */
  79954. enabled: boolean;
  79955. private _loader;
  79956. /** @hidden */
  79957. constructor(loader: GLTFLoader);
  79958. /** @hidden */
  79959. dispose(): void;
  79960. /** @hidden */
  79961. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79962. }
  79963. }
  79964. declare module BABYLON.GLTF2.Loader.Extensions {
  79965. /**
  79966. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79967. */
  79968. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79969. /**
  79970. * The name of this extension.
  79971. */
  79972. readonly name: string;
  79973. /**
  79974. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79975. */
  79976. dracoCompression?: DracoCompression;
  79977. /**
  79978. * Defines whether this extension is enabled.
  79979. */
  79980. enabled: boolean;
  79981. private _loader;
  79982. /** @hidden */
  79983. constructor(loader: GLTFLoader);
  79984. /** @hidden */
  79985. dispose(): void;
  79986. /** @hidden */
  79987. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79988. }
  79989. }
  79990. declare module BABYLON.GLTF2.Loader.Extensions {
  79991. /**
  79992. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79993. */
  79994. export class KHR_lights implements IGLTFLoaderExtension {
  79995. /**
  79996. * The name of this extension.
  79997. */
  79998. readonly name: string;
  79999. /**
  80000. * Defines whether this extension is enabled.
  80001. */
  80002. enabled: boolean;
  80003. private _loader;
  80004. private _lights?;
  80005. /** @hidden */
  80006. constructor(loader: GLTFLoader);
  80007. /** @hidden */
  80008. dispose(): void;
  80009. /** @hidden */
  80010. onLoading(): void;
  80011. /** @hidden */
  80012. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80013. }
  80014. }
  80015. declare module BABYLON.GLTF2.Loader.Extensions {
  80016. /**
  80017. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80018. */
  80019. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80020. /**
  80021. * The name of this extension.
  80022. */
  80023. readonly name: string;
  80024. /**
  80025. * Defines whether this extension is enabled.
  80026. */
  80027. enabled: boolean;
  80028. /**
  80029. * Defines a number that determines the order the extensions are applied.
  80030. */
  80031. order: number;
  80032. private _loader;
  80033. /** @hidden */
  80034. constructor(loader: GLTFLoader);
  80035. /** @hidden */
  80036. dispose(): void;
  80037. /** @hidden */
  80038. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80039. private _loadSpecularGlossinessPropertiesAsync;
  80040. }
  80041. }
  80042. declare module BABYLON.GLTF2.Loader.Extensions {
  80043. /**
  80044. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80045. */
  80046. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80047. /**
  80048. * The name of this extension.
  80049. */
  80050. readonly name: string;
  80051. /**
  80052. * Defines whether this extension is enabled.
  80053. */
  80054. enabled: boolean;
  80055. /**
  80056. * Defines a number that determines the order the extensions are applied.
  80057. */
  80058. order: number;
  80059. private _loader;
  80060. /** @hidden */
  80061. constructor(loader: GLTFLoader);
  80062. /** @hidden */
  80063. dispose(): void;
  80064. /** @hidden */
  80065. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80066. private _loadUnlitPropertiesAsync;
  80067. }
  80068. }
  80069. declare module BABYLON.GLTF2.Loader.Extensions {
  80070. /**
  80071. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80072. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80073. * !!! Experimental Extension Subject to Changes !!!
  80074. */
  80075. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80076. /**
  80077. * The name of this extension.
  80078. */
  80079. readonly name: string;
  80080. /**
  80081. * Defines whether this extension is enabled.
  80082. */
  80083. enabled: boolean;
  80084. /**
  80085. * Defines a number that determines the order the extensions are applied.
  80086. */
  80087. order: number;
  80088. private _loader;
  80089. /** @hidden */
  80090. constructor(loader: GLTFLoader);
  80091. /** @hidden */
  80092. dispose(): void;
  80093. /** @hidden */
  80094. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80095. private _loadClearCoatPropertiesAsync;
  80096. }
  80097. }
  80098. declare module BABYLON.GLTF2.Loader.Extensions {
  80099. /**
  80100. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80101. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80102. * !!! Experimental Extension Subject to Changes !!!
  80103. */
  80104. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80105. /**
  80106. * The name of this extension.
  80107. */
  80108. readonly name: string;
  80109. /**
  80110. * Defines whether this extension is enabled.
  80111. */
  80112. enabled: boolean;
  80113. /**
  80114. * Defines a number that determines the order the extensions are applied.
  80115. */
  80116. order: number;
  80117. private _loader;
  80118. /** @hidden */
  80119. constructor(loader: GLTFLoader);
  80120. /** @hidden */
  80121. dispose(): void;
  80122. /** @hidden */
  80123. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80124. private _loadSheenPropertiesAsync;
  80125. }
  80126. }
  80127. declare module BABYLON.GLTF2.Loader.Extensions {
  80128. /**
  80129. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80130. * !!! Experimental Extension Subject to Changes !!!
  80131. */
  80132. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80133. /**
  80134. * The name of this extension.
  80135. */
  80136. readonly name: string;
  80137. /**
  80138. * Defines whether this extension is enabled.
  80139. */
  80140. enabled: boolean;
  80141. /**
  80142. * Defines a number that determines the order the extensions are applied.
  80143. */
  80144. order: number;
  80145. private _loader;
  80146. /** @hidden */
  80147. constructor(loader: GLTFLoader);
  80148. /** @hidden */
  80149. dispose(): void;
  80150. /** @hidden */
  80151. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80152. private _loadSpecularPropertiesAsync;
  80153. }
  80154. }
  80155. declare module BABYLON.GLTF2.Loader.Extensions {
  80156. /**
  80157. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80158. * !!! Experimental Extension Subject to Changes !!!
  80159. */
  80160. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80161. /**
  80162. * Default ior Value from the spec.
  80163. */
  80164. private static readonly _DEFAULT_IOR;
  80165. /**
  80166. * The name of this extension.
  80167. */
  80168. readonly name: string;
  80169. /**
  80170. * Defines whether this extension is enabled.
  80171. */
  80172. enabled: boolean;
  80173. /**
  80174. * Defines a number that determines the order the extensions are applied.
  80175. */
  80176. order: number;
  80177. private _loader;
  80178. /** @hidden */
  80179. constructor(loader: GLTFLoader);
  80180. /** @hidden */
  80181. dispose(): void;
  80182. /** @hidden */
  80183. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80184. private _loadIorPropertiesAsync;
  80185. }
  80186. }
  80187. declare module BABYLON.GLTF2.Loader.Extensions {
  80188. /**
  80189. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80190. * !!! Experimental Extension Subject to Changes !!!
  80191. */
  80192. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80193. /**
  80194. * The name of this extension.
  80195. */
  80196. readonly name: string;
  80197. /**
  80198. * Defines whether this extension is enabled.
  80199. */
  80200. enabled: boolean;
  80201. private _loader;
  80202. /**
  80203. * The default variant name.
  80204. */
  80205. defaultVariant: string | undefined;
  80206. private _tagsToMap;
  80207. /** @hidden */
  80208. constructor(loader: GLTFLoader);
  80209. /** @hidden */
  80210. dispose(): void;
  80211. /**
  80212. * Return a list of available variants for this asset.
  80213. * @returns {string[]}
  80214. */
  80215. getVariants(): string[];
  80216. /**
  80217. * Select a variant by providing a list of variant tag names.
  80218. *
  80219. * @param {(string | string[])} variantName
  80220. */
  80221. selectVariant(variantName: string | string[]): void;
  80222. /**
  80223. * Select a variant by providing a single variant tag.
  80224. *
  80225. * @param {string} variantName
  80226. */
  80227. selectVariantTag(variantName: string): void;
  80228. /** @hidden */
  80229. onLoading(): void;
  80230. /** @hidden */
  80231. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80232. }
  80233. }
  80234. declare module BABYLON.GLTF2.Loader.Extensions {
  80235. /**
  80236. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80237. * !!! Experimental Extension Subject to Changes !!!
  80238. */
  80239. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80240. /**
  80241. * The name of this extension.
  80242. */
  80243. readonly name: string;
  80244. /**
  80245. * Defines whether this extension is enabled.
  80246. */
  80247. enabled: boolean;
  80248. /**
  80249. * Defines a number that determines the order the extensions are applied.
  80250. */
  80251. order: number;
  80252. private _loader;
  80253. /** @hidden */
  80254. constructor(loader: GLTFLoader);
  80255. /** @hidden */
  80256. dispose(): void;
  80257. /** @hidden */
  80258. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80259. private _loadTransparentPropertiesAsync;
  80260. }
  80261. }
  80262. declare module BABYLON.GLTF2.Loader.Extensions {
  80263. /**
  80264. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80265. */
  80266. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80267. /**
  80268. * The name of this extension.
  80269. */
  80270. readonly name: string;
  80271. /**
  80272. * Defines whether this extension is enabled.
  80273. */
  80274. enabled: boolean;
  80275. /** @hidden */
  80276. constructor(loader: GLTFLoader);
  80277. /** @hidden */
  80278. dispose(): void;
  80279. }
  80280. }
  80281. declare module BABYLON.GLTF2.Loader.Extensions {
  80282. /**
  80283. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80284. * !!! Experimental Extension Subject to Changes !!!
  80285. */
  80286. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80287. /** The name of this extension. */
  80288. readonly name: string;
  80289. /** Defines whether this extension is enabled. */
  80290. enabled: boolean;
  80291. private _loader;
  80292. /** @hidden */
  80293. constructor(loader: GLTFLoader);
  80294. /** @hidden */
  80295. dispose(): void;
  80296. /** @hidden */
  80297. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80298. }
  80299. }
  80300. declare module BABYLON.GLTF2.Loader.Extensions {
  80301. /**
  80302. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80303. */
  80304. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80305. /**
  80306. * The name of this extension.
  80307. */
  80308. readonly name: string;
  80309. /**
  80310. * Defines whether this extension is enabled.
  80311. */
  80312. enabled: boolean;
  80313. private _loader;
  80314. /** @hidden */
  80315. constructor(loader: GLTFLoader);
  80316. /** @hidden */
  80317. dispose(): void;
  80318. /** @hidden */
  80319. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80320. }
  80321. }
  80322. declare module BABYLON.GLTF2.Loader.Extensions {
  80323. /**
  80324. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80325. * !!! Experimental Extension Subject to Changes !!!
  80326. */
  80327. export class KHR_xmp implements IGLTFLoaderExtension {
  80328. /**
  80329. * The name of this extension.
  80330. */
  80331. readonly name: string;
  80332. /**
  80333. * Defines whether this extension is enabled.
  80334. */
  80335. enabled: boolean;
  80336. /**
  80337. * Defines a number that determines the order the extensions are applied.
  80338. */
  80339. order: number;
  80340. private _loader;
  80341. /** @hidden */
  80342. constructor(loader: GLTFLoader);
  80343. /** @hidden */
  80344. dispose(): void;
  80345. /**
  80346. * Called after the loader state changes to LOADING.
  80347. */
  80348. onLoading(): void;
  80349. }
  80350. }
  80351. declare module BABYLON.GLTF2.Loader.Extensions {
  80352. /**
  80353. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80354. */
  80355. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80356. /**
  80357. * The name of this extension.
  80358. */
  80359. readonly name: string;
  80360. /**
  80361. * Defines whether this extension is enabled.
  80362. */
  80363. enabled: boolean;
  80364. private _loader;
  80365. private _clips;
  80366. private _emitters;
  80367. /** @hidden */
  80368. constructor(loader: GLTFLoader);
  80369. /** @hidden */
  80370. dispose(): void;
  80371. /** @hidden */
  80372. onLoading(): void;
  80373. /** @hidden */
  80374. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80375. /** @hidden */
  80376. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80377. /** @hidden */
  80378. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80379. private _loadClipAsync;
  80380. private _loadEmitterAsync;
  80381. private _getEventAction;
  80382. private _loadAnimationEventAsync;
  80383. }
  80384. }
  80385. declare module BABYLON.GLTF2.Loader.Extensions {
  80386. /**
  80387. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80388. */
  80389. export class MSFT_lod implements IGLTFLoaderExtension {
  80390. /**
  80391. * The name of this extension.
  80392. */
  80393. readonly name: string;
  80394. /**
  80395. * Defines whether this extension is enabled.
  80396. */
  80397. enabled: boolean;
  80398. /**
  80399. * Defines a number that determines the order the extensions are applied.
  80400. */
  80401. order: number;
  80402. /**
  80403. * Maximum number of LODs to load, starting from the lowest LOD.
  80404. */
  80405. maxLODsToLoad: number;
  80406. /**
  80407. * Observable raised when all node LODs of one level are loaded.
  80408. * The event data is the index of the loaded LOD starting from zero.
  80409. * Dispose the loader to cancel the loading of the next level of LODs.
  80410. */
  80411. onNodeLODsLoadedObservable: Observable<number>;
  80412. /**
  80413. * Observable raised when all material LODs of one level are loaded.
  80414. * The event data is the index of the loaded LOD starting from zero.
  80415. * Dispose the loader to cancel the loading of the next level of LODs.
  80416. */
  80417. onMaterialLODsLoadedObservable: Observable<number>;
  80418. private _loader;
  80419. private _nodeIndexLOD;
  80420. private _nodeSignalLODs;
  80421. private _nodePromiseLODs;
  80422. private _materialIndexLOD;
  80423. private _materialSignalLODs;
  80424. private _materialPromiseLODs;
  80425. private _indexLOD;
  80426. private _bufferLODs;
  80427. /** @hidden */
  80428. constructor(loader: GLTFLoader);
  80429. /** @hidden */
  80430. dispose(): void;
  80431. /** @hidden */
  80432. onReady(): void;
  80433. /** @hidden */
  80434. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80435. /** @hidden */
  80436. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80437. /** @hidden */
  80438. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80439. /** @hidden */
  80440. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80441. /** @hidden */
  80442. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80443. private _loadBufferLOD;
  80444. /**
  80445. * Gets an array of LOD properties from lowest to highest.
  80446. */
  80447. private _getLODs;
  80448. private _disposeTransformNode;
  80449. private _disposeMaterials;
  80450. }
  80451. }
  80452. declare module BABYLON.GLTF2.Loader.Extensions {
  80453. /** @hidden */
  80454. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80455. readonly name: string;
  80456. enabled: boolean;
  80457. private _loader;
  80458. constructor(loader: GLTFLoader);
  80459. dispose(): void;
  80460. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80461. }
  80462. }
  80463. declare module BABYLON.GLTF2.Loader.Extensions {
  80464. /** @hidden */
  80465. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80466. readonly name: string;
  80467. enabled: boolean;
  80468. private _loader;
  80469. constructor(loader: GLTFLoader);
  80470. dispose(): void;
  80471. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80472. }
  80473. }
  80474. declare module BABYLON.GLTF2.Loader.Extensions {
  80475. /**
  80476. * Store glTF extras (if present) in BJS objects' metadata
  80477. */
  80478. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80479. /**
  80480. * The name of this extension.
  80481. */
  80482. readonly name: string;
  80483. /**
  80484. * Defines whether this extension is enabled.
  80485. */
  80486. enabled: boolean;
  80487. private _loader;
  80488. private _assignExtras;
  80489. /** @hidden */
  80490. constructor(loader: GLTFLoader);
  80491. /** @hidden */
  80492. dispose(): void;
  80493. /** @hidden */
  80494. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80495. /** @hidden */
  80496. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80497. /** @hidden */
  80498. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80499. }
  80500. }
  80501. declare module BABYLON {
  80502. /**
  80503. * Class reading and parsing the MTL file bundled with the obj file.
  80504. */
  80505. export class MTLFileLoader {
  80506. /**
  80507. * Invert Y-Axis of referenced textures on load
  80508. */
  80509. static INVERT_TEXTURE_Y: boolean;
  80510. /**
  80511. * All material loaded from the mtl will be set here
  80512. */
  80513. materials: StandardMaterial[];
  80514. /**
  80515. * This function will read the mtl file and create each material described inside
  80516. * This function could be improve by adding :
  80517. * -some component missing (Ni, Tf...)
  80518. * -including the specific options available
  80519. *
  80520. * @param scene defines the scene the material will be created in
  80521. * @param data defines the mtl data to parse
  80522. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80523. * @param forAssetContainer defines if the material should be registered in the scene
  80524. */
  80525. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80526. /**
  80527. * Gets the texture for the material.
  80528. *
  80529. * If the material is imported from input file,
  80530. * We sanitize the url to ensure it takes the textre from aside the material.
  80531. *
  80532. * @param rootUrl The root url to load from
  80533. * @param value The value stored in the mtl
  80534. * @return The Texture
  80535. */
  80536. private static _getTexture;
  80537. }
  80538. }
  80539. declare module BABYLON {
  80540. /**
  80541. * Options for loading OBJ/MTL files
  80542. */
  80543. type MeshLoadOptions = {
  80544. /**
  80545. * Defines if UVs are optimized by default during load.
  80546. */
  80547. OptimizeWithUV: boolean;
  80548. /**
  80549. * Defines custom scaling of UV coordinates of loaded meshes.
  80550. */
  80551. UVScaling: Vector2;
  80552. /**
  80553. * Invert model on y-axis (does a model scaling inversion)
  80554. */
  80555. InvertY: boolean;
  80556. /**
  80557. * Invert Y-Axis of referenced textures on load
  80558. */
  80559. InvertTextureY: boolean;
  80560. /**
  80561. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80562. */
  80563. ImportVertexColors: boolean;
  80564. /**
  80565. * Compute the normals for the model, even if normals are present in the file.
  80566. */
  80567. ComputeNormals: boolean;
  80568. /**
  80569. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80570. */
  80571. SkipMaterials: boolean;
  80572. /**
  80573. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80574. */
  80575. MaterialLoadingFailsSilently: boolean;
  80576. };
  80577. /**
  80578. * OBJ file type loader.
  80579. * This is a babylon scene loader plugin.
  80580. */
  80581. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80582. /**
  80583. * Defines if UVs are optimized by default during load.
  80584. */
  80585. static OPTIMIZE_WITH_UV: boolean;
  80586. /**
  80587. * Invert model on y-axis (does a model scaling inversion)
  80588. */
  80589. static INVERT_Y: boolean;
  80590. /**
  80591. * Invert Y-Axis of referenced textures on load
  80592. */
  80593. static get INVERT_TEXTURE_Y(): boolean;
  80594. static set INVERT_TEXTURE_Y(value: boolean);
  80595. /**
  80596. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80597. */
  80598. static IMPORT_VERTEX_COLORS: boolean;
  80599. /**
  80600. * Compute the normals for the model, even if normals are present in the file.
  80601. */
  80602. static COMPUTE_NORMALS: boolean;
  80603. /**
  80604. * Defines custom scaling of UV coordinates of loaded meshes.
  80605. */
  80606. static UV_SCALING: Vector2;
  80607. /**
  80608. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80609. */
  80610. static SKIP_MATERIALS: boolean;
  80611. /**
  80612. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80613. *
  80614. * Defaults to true for backwards compatibility.
  80615. */
  80616. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80617. /**
  80618. * Defines the name of the plugin.
  80619. */
  80620. name: string;
  80621. /**
  80622. * Defines the extension the plugin is able to load.
  80623. */
  80624. extensions: string;
  80625. /** @hidden */
  80626. obj: RegExp;
  80627. /** @hidden */
  80628. group: RegExp;
  80629. /** @hidden */
  80630. mtllib: RegExp;
  80631. /** @hidden */
  80632. usemtl: RegExp;
  80633. /** @hidden */
  80634. smooth: RegExp;
  80635. /** @hidden */
  80636. vertexPattern: RegExp;
  80637. /** @hidden */
  80638. normalPattern: RegExp;
  80639. /** @hidden */
  80640. uvPattern: RegExp;
  80641. /** @hidden */
  80642. facePattern1: RegExp;
  80643. /** @hidden */
  80644. facePattern2: RegExp;
  80645. /** @hidden */
  80646. facePattern3: RegExp;
  80647. /** @hidden */
  80648. facePattern4: RegExp;
  80649. /** @hidden */
  80650. facePattern5: RegExp;
  80651. private _forAssetContainer;
  80652. private _meshLoadOptions;
  80653. /**
  80654. * Creates loader for .OBJ files
  80655. *
  80656. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80657. */
  80658. constructor(meshLoadOptions?: MeshLoadOptions);
  80659. private static get currentMeshLoadOptions();
  80660. /**
  80661. * Calls synchronously the MTL file attached to this obj.
  80662. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80663. * Without this function materials are not displayed in the first frame (but displayed after).
  80664. * In consequence it is impossible to get material information in your HTML file
  80665. *
  80666. * @param url The URL of the MTL file
  80667. * @param rootUrl
  80668. * @param onSuccess Callback function to be called when the MTL file is loaded
  80669. * @private
  80670. */
  80671. private _loadMTL;
  80672. /**
  80673. * Instantiates a OBJ file loader plugin.
  80674. * @returns the created plugin
  80675. */
  80676. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80677. /**
  80678. * If the data string can be loaded directly.
  80679. *
  80680. * @param data string containing the file data
  80681. * @returns if the data can be loaded directly
  80682. */
  80683. canDirectLoad(data: string): boolean;
  80684. /**
  80685. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80686. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80687. * @param scene the scene the meshes should be added to
  80688. * @param data the OBJ data to load
  80689. * @param rootUrl root url to load from
  80690. * @param onProgress event that fires when loading progress has occured
  80691. * @param fileName Defines the name of the file to load
  80692. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80693. */
  80694. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80695. meshes: AbstractMesh[];
  80696. particleSystems: IParticleSystem[];
  80697. skeletons: Skeleton[];
  80698. animationGroups: AnimationGroup[];
  80699. }>;
  80700. /**
  80701. * Imports all objects from the loaded OBJ data and adds them to the scene
  80702. * @param scene the scene the objects should be added to
  80703. * @param data the OBJ data to load
  80704. * @param rootUrl root url to load from
  80705. * @param onProgress event that fires when loading progress has occured
  80706. * @param fileName Defines the name of the file to load
  80707. * @returns a promise which completes when objects have been loaded to the scene
  80708. */
  80709. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80710. /**
  80711. * Load into an asset container.
  80712. * @param scene The scene to load into
  80713. * @param data The data to import
  80714. * @param rootUrl The root url for scene and resources
  80715. * @param onProgress The callback when the load progresses
  80716. * @param fileName Defines the name of the file to load
  80717. * @returns The loaded asset container
  80718. */
  80719. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80720. /**
  80721. * Read the OBJ file and create an Array of meshes.
  80722. * Each mesh contains all information given by the OBJ and the MTL file.
  80723. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80724. *
  80725. * @param meshesNames
  80726. * @param scene Scene The scene where are displayed the data
  80727. * @param data String The content of the obj file
  80728. * @param rootUrl String The path to the folder
  80729. * @returns Array<AbstractMesh>
  80730. * @private
  80731. */
  80732. private _parseSolid;
  80733. }
  80734. }
  80735. declare module BABYLON {
  80736. /**
  80737. * STL file type loader.
  80738. * This is a babylon scene loader plugin.
  80739. */
  80740. export class STLFileLoader implements ISceneLoaderPlugin {
  80741. /** @hidden */
  80742. solidPattern: RegExp;
  80743. /** @hidden */
  80744. facetsPattern: RegExp;
  80745. /** @hidden */
  80746. normalPattern: RegExp;
  80747. /** @hidden */
  80748. vertexPattern: RegExp;
  80749. /**
  80750. * Defines the name of the plugin.
  80751. */
  80752. name: string;
  80753. /**
  80754. * Defines the extensions the stl loader is able to load.
  80755. * force data to come in as an ArrayBuffer
  80756. * we'll convert to string if it looks like it's an ASCII .stl
  80757. */
  80758. extensions: ISceneLoaderPluginExtensions;
  80759. /**
  80760. * Import meshes into a scene.
  80761. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80762. * @param scene The scene to import into
  80763. * @param data The data to import
  80764. * @param rootUrl The root url for scene and resources
  80765. * @param meshes The meshes array to import into
  80766. * @param particleSystems The particle systems array to import into
  80767. * @param skeletons The skeletons array to import into
  80768. * @param onError The callback when import fails
  80769. * @returns True if successful or false otherwise
  80770. */
  80771. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80772. /**
  80773. * Load into a scene.
  80774. * @param scene The scene to load into
  80775. * @param data The data to import
  80776. * @param rootUrl The root url for scene and resources
  80777. * @param onError The callback when import fails
  80778. * @returns true if successful or false otherwise
  80779. */
  80780. load(scene: Scene, data: any, rootUrl: string): boolean;
  80781. /**
  80782. * Load into an asset container.
  80783. * @param scene The scene to load into
  80784. * @param data The data to import
  80785. * @param rootUrl The root url for scene and resources
  80786. * @param onError The callback when import fails
  80787. * @returns The loaded asset container
  80788. */
  80789. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80790. private _isBinary;
  80791. private _parseBinary;
  80792. private _parseASCII;
  80793. }
  80794. }
  80795. declare module BABYLON {
  80796. /**
  80797. * Class for generating OBJ data from a Babylon scene.
  80798. */
  80799. export class OBJExport {
  80800. /**
  80801. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80802. * @param mesh defines the list of meshes to serialize
  80803. * @param materials defines if materials should be exported
  80804. * @param matlibname defines the name of the associated mtl file
  80805. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80806. * @returns the OBJ content
  80807. */
  80808. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80809. /**
  80810. * Exports the material(s) of a mesh in .MTL file format (text)
  80811. * @param mesh defines the mesh to extract the material from
  80812. * @returns the mtl content
  80813. */
  80814. static MTL(mesh: Mesh): string;
  80815. }
  80816. }
  80817. declare module BABYLON {
  80818. /** @hidden */
  80819. export var __IGLTFExporterExtension: number;
  80820. /**
  80821. * Interface for extending the exporter
  80822. * @hidden
  80823. */
  80824. export interface IGLTFExporterExtension {
  80825. /**
  80826. * The name of this extension
  80827. */
  80828. readonly name: string;
  80829. /**
  80830. * Defines whether this extension is enabled
  80831. */
  80832. enabled: boolean;
  80833. /**
  80834. * Defines whether this extension is required
  80835. */
  80836. required: boolean;
  80837. }
  80838. }
  80839. declare module BABYLON.GLTF2.Exporter {
  80840. /** @hidden */
  80841. export var __IGLTFExporterExtensionV2: number;
  80842. /**
  80843. * Interface for a glTF exporter extension
  80844. * @hidden
  80845. */
  80846. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80847. /**
  80848. * Define this method to modify the default behavior before exporting a texture
  80849. * @param context The context when loading the asset
  80850. * @param babylonTexture The Babylon.js texture
  80851. * @param mimeType The mime-type of the generated image
  80852. * @returns A promise that resolves with the exported texture
  80853. */
  80854. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80855. /**
  80856. * Define this method to get notified when a texture info is created
  80857. * @param context The context when loading the asset
  80858. * @param textureInfo The glTF texture info
  80859. * @param babylonTexture The Babylon.js texture
  80860. */
  80861. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80862. /**
  80863. * Define this method to modify the default behavior when exporting texture info
  80864. * @param context The context when loading the asset
  80865. * @param meshPrimitive glTF mesh primitive
  80866. * @param babylonSubMesh Babylon submesh
  80867. * @param binaryWriter glTF serializer binary writer instance
  80868. * @returns nullable IMeshPrimitive promise
  80869. */
  80870. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80871. /**
  80872. * Define this method to modify the default behavior when exporting a node
  80873. * @param context The context when exporting the node
  80874. * @param node glTF node
  80875. * @param babylonNode BabylonJS node
  80876. * @returns nullable INode promise
  80877. */
  80878. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80879. [key: number]: number;
  80880. }): Promise<Nullable<INode>>;
  80881. /**
  80882. * Define this method to modify the default behavior when exporting a material
  80883. * @param material glTF material
  80884. * @param babylonMaterial BabylonJS material
  80885. * @returns nullable IMaterial promise
  80886. */
  80887. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80888. /**
  80889. * Define this method to return additional textures to export from a material
  80890. * @param material glTF material
  80891. * @param babylonMaterial BabylonJS material
  80892. * @returns List of textures
  80893. */
  80894. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80895. /** Gets a boolean indicating that this extension was used */
  80896. wasUsed: boolean;
  80897. /** Gets a boolean indicating that this extension is required for the file to work */
  80898. required: boolean;
  80899. /**
  80900. * Called after the exporter state changes to EXPORTING
  80901. */
  80902. onExporting?(): void;
  80903. }
  80904. }
  80905. declare module BABYLON.GLTF2.Exporter {
  80906. /**
  80907. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80908. * @hidden
  80909. */
  80910. export class _GLTFMaterialExporter {
  80911. /**
  80912. * Represents the dielectric specular values for R, G and B
  80913. */
  80914. private static readonly _DielectricSpecular;
  80915. /**
  80916. * Allows the maximum specular power to be defined for material calculations
  80917. */
  80918. private static readonly _MaxSpecularPower;
  80919. /**
  80920. * Mapping to store textures
  80921. */
  80922. private _textureMap;
  80923. /**
  80924. * Numeric tolerance value
  80925. */
  80926. private static readonly _Epsilon;
  80927. /**
  80928. * Reference to the glTF Exporter
  80929. */
  80930. private _exporter;
  80931. constructor(exporter: _Exporter);
  80932. /**
  80933. * Specifies if two colors are approximately equal in value
  80934. * @param color1 first color to compare to
  80935. * @param color2 second color to compare to
  80936. * @param epsilon threshold value
  80937. */
  80938. private static FuzzyEquals;
  80939. /**
  80940. * Gets the materials from a Babylon scene and converts them to glTF materials
  80941. * @param scene babylonjs scene
  80942. * @param mimeType texture mime type
  80943. * @param images array of images
  80944. * @param textures array of textures
  80945. * @param materials array of materials
  80946. * @param imageData mapping of texture names to base64 textures
  80947. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80948. */
  80949. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80950. /**
  80951. * Makes a copy of the glTF material without the texture parameters
  80952. * @param originalMaterial original glTF material
  80953. * @returns glTF material without texture parameters
  80954. */
  80955. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80956. /**
  80957. * Specifies if the material has any texture parameters present
  80958. * @param material glTF Material
  80959. * @returns boolean specifying if texture parameters are present
  80960. */
  80961. _hasTexturesPresent(material: IMaterial): boolean;
  80962. /**
  80963. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80964. * @param babylonStandardMaterial
  80965. * @returns glTF Metallic Roughness Material representation
  80966. */
  80967. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80968. /**
  80969. * Computes the metallic factor
  80970. * @param diffuse diffused value
  80971. * @param specular specular value
  80972. * @param oneMinusSpecularStrength one minus the specular strength
  80973. * @returns metallic value
  80974. */
  80975. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80976. /**
  80977. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80978. * @param glTFMaterial glTF material
  80979. * @param babylonMaterial Babylon material
  80980. */
  80981. private static _SetAlphaMode;
  80982. /**
  80983. * Converts a Babylon Standard Material to a glTF Material
  80984. * @param babylonStandardMaterial BJS Standard Material
  80985. * @param mimeType mime type to use for the textures
  80986. * @param images array of glTF image interfaces
  80987. * @param textures array of glTF texture interfaces
  80988. * @param materials array of glTF material interfaces
  80989. * @param imageData map of image file name to data
  80990. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80991. */
  80992. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80993. private _finishMaterial;
  80994. /**
  80995. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80996. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80997. * @param mimeType mime type to use for the textures
  80998. * @param images array of glTF image interfaces
  80999. * @param textures array of glTF texture interfaces
  81000. * @param materials array of glTF material interfaces
  81001. * @param imageData map of image file name to data
  81002. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81003. */
  81004. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81005. /**
  81006. * Converts an image typed array buffer to a base64 image
  81007. * @param buffer typed array buffer
  81008. * @param width width of the image
  81009. * @param height height of the image
  81010. * @param mimeType mimetype of the image
  81011. * @returns base64 image string
  81012. */
  81013. private _createBase64FromCanvasAsync;
  81014. /**
  81015. * Generates a white texture based on the specified width and height
  81016. * @param width width of the texture in pixels
  81017. * @param height height of the texture in pixels
  81018. * @param scene babylonjs scene
  81019. * @returns white texture
  81020. */
  81021. private _createWhiteTexture;
  81022. /**
  81023. * 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
  81024. * @param texture1 first texture to resize
  81025. * @param texture2 second texture to resize
  81026. * @param scene babylonjs scene
  81027. * @returns resized textures or null
  81028. */
  81029. private _resizeTexturesToSameDimensions;
  81030. /**
  81031. * Converts an array of pixels to a Float32Array
  81032. * Throws an error if the pixel format is not supported
  81033. * @param pixels - array buffer containing pixel values
  81034. * @returns Float32 of pixels
  81035. */
  81036. private _convertPixelArrayToFloat32;
  81037. /**
  81038. * Convert Specular Glossiness Textures to Metallic Roughness
  81039. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81040. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81041. * @param diffuseTexture texture used to store diffuse information
  81042. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81043. * @param factors specular glossiness material factors
  81044. * @param mimeType the mime type to use for the texture
  81045. * @returns pbr metallic roughness interface or null
  81046. */
  81047. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81048. /**
  81049. * Converts specular glossiness material properties to metallic roughness
  81050. * @param specularGlossiness interface with specular glossiness material properties
  81051. * @returns interface with metallic roughness material properties
  81052. */
  81053. private _convertSpecularGlossinessToMetallicRoughness;
  81054. /**
  81055. * Calculates the surface reflectance, independent of lighting conditions
  81056. * @param color Color source to calculate brightness from
  81057. * @returns number representing the perceived brightness, or zero if color is undefined
  81058. */
  81059. private _getPerceivedBrightness;
  81060. /**
  81061. * Returns the maximum color component value
  81062. * @param color
  81063. * @returns maximum color component value, or zero if color is null or undefined
  81064. */
  81065. private _getMaxComponent;
  81066. /**
  81067. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81068. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81069. * @param mimeType mime type to use for the textures
  81070. * @param images array of glTF image interfaces
  81071. * @param textures array of glTF texture interfaces
  81072. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81073. * @param imageData map of image file name to data
  81074. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81075. * @returns glTF PBR Metallic Roughness factors
  81076. */
  81077. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81078. private _getGLTFTextureSampler;
  81079. private _getGLTFTextureWrapMode;
  81080. private _getGLTFTextureWrapModesSampler;
  81081. /**
  81082. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81083. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81084. * @param mimeType mime type to use for the textures
  81085. * @param images array of glTF image interfaces
  81086. * @param textures array of glTF texture interfaces
  81087. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81088. * @param imageData map of image file name to data
  81089. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81090. * @returns glTF PBR Metallic Roughness factors
  81091. */
  81092. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81093. /**
  81094. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81095. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81096. * @param mimeType mime type to use for the textures
  81097. * @param images array of glTF image interfaces
  81098. * @param textures array of glTF texture interfaces
  81099. * @param materials array of glTF material interfaces
  81100. * @param imageData map of image file name to data
  81101. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81102. */
  81103. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81104. private setMetallicRoughnessPbrMaterial;
  81105. private getPixelsFromTexture;
  81106. /**
  81107. * Extracts a texture from a Babylon texture into file data and glTF data
  81108. * @param babylonTexture Babylon texture to extract
  81109. * @param mimeType Mime Type of the babylonTexture
  81110. * @return glTF texture info, or null if the texture format is not supported
  81111. */
  81112. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81113. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81114. /**
  81115. * Builds a texture from base64 string
  81116. * @param base64Texture base64 texture string
  81117. * @param baseTextureName Name to use for the texture
  81118. * @param mimeType image mime type for the texture
  81119. * @param images array of images
  81120. * @param textures array of textures
  81121. * @param imageData map of image data
  81122. * @returns glTF texture info, or null if the texture format is not supported
  81123. */
  81124. private _getTextureInfoFromBase64;
  81125. }
  81126. }
  81127. declare module BABYLON {
  81128. /**
  81129. * Class for holding and downloading glTF file data
  81130. */
  81131. export class GLTFData {
  81132. /**
  81133. * Object which contains the file name as the key and its data as the value
  81134. */
  81135. glTFFiles: {
  81136. [fileName: string]: string | Blob;
  81137. };
  81138. /**
  81139. * Initializes the glTF file object
  81140. */
  81141. constructor();
  81142. /**
  81143. * Downloads the glTF data as files based on their names and data
  81144. */
  81145. downloadFiles(): void;
  81146. }
  81147. }
  81148. declare module BABYLON {
  81149. /**
  81150. * Holds a collection of exporter options and parameters
  81151. */
  81152. export interface IExportOptions {
  81153. /**
  81154. * Function which indicates whether a babylon node should be exported or not
  81155. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81156. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81157. */
  81158. shouldExportNode?(node: Node): boolean;
  81159. /**
  81160. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81161. * @param metadata source metadata to read from
  81162. * @returns the data to store to glTF node extras
  81163. */
  81164. metadataSelector?(metadata: any): any;
  81165. /**
  81166. * The sample rate to bake animation curves
  81167. */
  81168. animationSampleRate?: number;
  81169. /**
  81170. * Begin serialization without waiting for the scene to be ready
  81171. */
  81172. exportWithoutWaitingForScene?: boolean;
  81173. /**
  81174. * Indicates if coordinate system swapping root nodes should be included in export
  81175. */
  81176. includeCoordinateSystemConversionNodes?: boolean;
  81177. }
  81178. /**
  81179. * Class for generating glTF data from a Babylon scene.
  81180. */
  81181. export class GLTF2Export {
  81182. /**
  81183. * Exports the geometry of the scene to .gltf file format asynchronously
  81184. * @param scene Babylon scene with scene hierarchy information
  81185. * @param filePrefix File prefix to use when generating the glTF file
  81186. * @param options Exporter options
  81187. * @returns Returns an object with a .gltf file and associates texture names
  81188. * as keys and their data and paths as values
  81189. */
  81190. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81191. private static _PreExportAsync;
  81192. private static _PostExportAsync;
  81193. /**
  81194. * Exports the geometry of the scene to .glb file format asychronously
  81195. * @param scene Babylon scene with scene hierarchy information
  81196. * @param filePrefix File prefix to use when generating glb file
  81197. * @param options Exporter options
  81198. * @returns Returns an object with a .glb filename as key and data as value
  81199. */
  81200. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81201. }
  81202. }
  81203. declare module BABYLON.GLTF2.Exporter {
  81204. /**
  81205. * @hidden
  81206. */
  81207. export class _GLTFUtilities {
  81208. /**
  81209. * Creates a buffer view based on the supplied arguments
  81210. * @param bufferIndex index value of the specified buffer
  81211. * @param byteOffset byte offset value
  81212. * @param byteLength byte length of the bufferView
  81213. * @param byteStride byte distance between conequential elements
  81214. * @param name name of the buffer view
  81215. * @returns bufferView for glTF
  81216. */
  81217. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81218. /**
  81219. * Creates an accessor based on the supplied arguments
  81220. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81221. * @param name The name of the accessor
  81222. * @param type The type of the accessor
  81223. * @param componentType The datatype of components in the attribute
  81224. * @param count The number of attributes referenced by this accessor
  81225. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81226. * @param min Minimum value of each component in this attribute
  81227. * @param max Maximum value of each component in this attribute
  81228. * @returns accessor for glTF
  81229. */
  81230. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81231. /**
  81232. * Calculates the minimum and maximum values of an array of position floats
  81233. * @param positions Positions array of a mesh
  81234. * @param vertexStart Starting vertex offset to calculate min and max values
  81235. * @param vertexCount Number of vertices to check for min and max values
  81236. * @returns min number array and max number array
  81237. */
  81238. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81239. min: number[];
  81240. max: number[];
  81241. };
  81242. /**
  81243. * Converts a new right-handed Vector3
  81244. * @param vector vector3 array
  81245. * @returns right-handed Vector3
  81246. */
  81247. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81248. /**
  81249. * Converts a Vector3 to right-handed
  81250. * @param vector Vector3 to convert to right-handed
  81251. */
  81252. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81253. /**
  81254. * Converts a three element number array to right-handed
  81255. * @param vector number array to convert to right-handed
  81256. */
  81257. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81258. /**
  81259. * Converts a new right-handed Vector3
  81260. * @param vector vector3 array
  81261. * @returns right-handed Vector3
  81262. */
  81263. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81264. /**
  81265. * Converts a Vector3 to right-handed
  81266. * @param vector Vector3 to convert to right-handed
  81267. */
  81268. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81269. /**
  81270. * Converts a three element number array to right-handed
  81271. * @param vector number array to convert to right-handed
  81272. */
  81273. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81274. /**
  81275. * Converts a Vector4 to right-handed
  81276. * @param vector Vector4 to convert to right-handed
  81277. */
  81278. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81279. /**
  81280. * Converts a Vector4 to right-handed
  81281. * @param vector Vector4 to convert to right-handed
  81282. */
  81283. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81284. /**
  81285. * Converts a Quaternion to right-handed
  81286. * @param quaternion Source quaternion to convert to right-handed
  81287. */
  81288. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81289. /**
  81290. * Converts a Quaternion to right-handed
  81291. * @param quaternion Source quaternion to convert to right-handed
  81292. */
  81293. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81294. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81295. }
  81296. }
  81297. declare module BABYLON.GLTF2.Exporter {
  81298. /**
  81299. * Converts Babylon Scene into glTF 2.0.
  81300. * @hidden
  81301. */
  81302. export class _Exporter {
  81303. /**
  81304. * Stores the glTF to export
  81305. */
  81306. _glTF: IGLTF;
  81307. /**
  81308. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81309. */
  81310. _bufferViews: IBufferView[];
  81311. /**
  81312. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81313. */
  81314. _accessors: IAccessor[];
  81315. /**
  81316. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81317. */
  81318. _nodes: INode[];
  81319. /**
  81320. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81321. */
  81322. private _scenes;
  81323. /**
  81324. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81325. */
  81326. private _meshes;
  81327. /**
  81328. * Stores all the generated material information, which represents the appearance of each primitive
  81329. */
  81330. _materials: IMaterial[];
  81331. _materialMap: {
  81332. [materialID: number]: number;
  81333. };
  81334. /**
  81335. * Stores all the generated texture information, which is referenced by glTF materials
  81336. */
  81337. _textures: ITexture[];
  81338. /**
  81339. * Stores all the generated image information, which is referenced by glTF textures
  81340. */
  81341. _images: IImage[];
  81342. /**
  81343. * Stores all the texture samplers
  81344. */
  81345. _samplers: ISampler[];
  81346. /**
  81347. * Stores all the generated animation samplers, which is referenced by glTF animations
  81348. */
  81349. /**
  81350. * Stores the animations for glTF models
  81351. */
  81352. private _animations;
  81353. /**
  81354. * Stores the total amount of bytes stored in the glTF buffer
  81355. */
  81356. private _totalByteLength;
  81357. /**
  81358. * Stores a reference to the Babylon scene containing the source geometry and material information
  81359. */
  81360. _babylonScene: Scene;
  81361. /**
  81362. * Stores a map of the image data, where the key is the file name and the value
  81363. * is the image data
  81364. */
  81365. _imageData: {
  81366. [fileName: string]: {
  81367. data: Uint8Array;
  81368. mimeType: ImageMimeType;
  81369. };
  81370. };
  81371. /**
  81372. * Stores a map of the unique id of a node to its index in the node array
  81373. */
  81374. _nodeMap: {
  81375. [key: number]: number;
  81376. };
  81377. /**
  81378. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81379. */
  81380. _convertToRightHandedSystem: boolean;
  81381. /**
  81382. * Specifies if a Babylon node should be converted to right-handed on export
  81383. */
  81384. _convertToRightHandedSystemMap: {
  81385. [nodeId: number]: boolean;
  81386. };
  81387. _includeCoordinateSystemConversionNodes: boolean;
  81388. /**
  81389. * Baked animation sample rate
  81390. */
  81391. private _animationSampleRate;
  81392. private _options;
  81393. private _localEngine;
  81394. _glTFMaterialExporter: _GLTFMaterialExporter;
  81395. private _extensions;
  81396. private static _ExtensionNames;
  81397. private static _ExtensionFactories;
  81398. private _applyExtension;
  81399. private _applyExtensions;
  81400. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81401. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81402. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81403. [key: number]: number;
  81404. }): Promise<Nullable<INode>>;
  81405. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81406. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81407. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81408. private _forEachExtensions;
  81409. private _extensionsOnExporting;
  81410. /**
  81411. * Load glTF serializer extensions
  81412. */
  81413. private _loadExtensions;
  81414. /**
  81415. * Creates a glTF Exporter instance, which can accept optional exporter options
  81416. * @param babylonScene Babylon scene object
  81417. * @param options Options to modify the behavior of the exporter
  81418. */
  81419. constructor(babylonScene: Scene, options?: IExportOptions);
  81420. dispose(): void;
  81421. /**
  81422. * Registers a glTF exporter extension
  81423. * @param name Name of the extension to export
  81424. * @param factory The factory function that creates the exporter extension
  81425. */
  81426. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81427. /**
  81428. * Un-registers an exporter extension
  81429. * @param name The name fo the exporter extension
  81430. * @returns A boolean indicating whether the extension has been un-registered
  81431. */
  81432. static UnregisterExtension(name: string): boolean;
  81433. /**
  81434. * Lazy load a local engine
  81435. */
  81436. _getLocalEngine(): Engine;
  81437. private reorderIndicesBasedOnPrimitiveMode;
  81438. /**
  81439. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81440. * clock-wise during export to glTF
  81441. * @param submesh BabylonJS submesh
  81442. * @param primitiveMode Primitive mode of the mesh
  81443. * @param sideOrientation the winding order of the submesh
  81444. * @param vertexBufferKind The type of vertex attribute
  81445. * @param meshAttributeArray The vertex attribute data
  81446. * @param byteOffset The offset to the binary data
  81447. * @param binaryWriter The binary data for the glTF file
  81448. * @param convertToRightHandedSystem Converts the values to right-handed
  81449. */
  81450. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81451. /**
  81452. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81453. * clock-wise during export to glTF
  81454. * @param submesh BabylonJS submesh
  81455. * @param primitiveMode Primitive mode of the mesh
  81456. * @param sideOrientation the winding order of the submesh
  81457. * @param vertexBufferKind The type of vertex attribute
  81458. * @param meshAttributeArray The vertex attribute data
  81459. * @param byteOffset The offset to the binary data
  81460. * @param binaryWriter The binary data for the glTF file
  81461. * @param convertToRightHandedSystem Converts the values to right-handed
  81462. */
  81463. private reorderTriangleFillMode;
  81464. /**
  81465. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81466. * clock-wise during export to glTF
  81467. * @param submesh BabylonJS submesh
  81468. * @param primitiveMode Primitive mode of the mesh
  81469. * @param sideOrientation the winding order of the submesh
  81470. * @param vertexBufferKind The type of vertex attribute
  81471. * @param meshAttributeArray The vertex attribute data
  81472. * @param byteOffset The offset to the binary data
  81473. * @param binaryWriter The binary data for the glTF file
  81474. * @param convertToRightHandedSystem Converts the values to right-handed
  81475. */
  81476. private reorderTriangleStripDrawMode;
  81477. /**
  81478. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81479. * clock-wise during export to glTF
  81480. * @param submesh BabylonJS submesh
  81481. * @param primitiveMode Primitive mode of the mesh
  81482. * @param sideOrientation the winding order of the submesh
  81483. * @param vertexBufferKind The type of vertex attribute
  81484. * @param meshAttributeArray The vertex attribute data
  81485. * @param byteOffset The offset to the binary data
  81486. * @param binaryWriter The binary data for the glTF file
  81487. * @param convertToRightHandedSystem Converts the values to right-handed
  81488. */
  81489. private reorderTriangleFanMode;
  81490. /**
  81491. * Writes the vertex attribute data to binary
  81492. * @param vertices The vertices to write to the binary writer
  81493. * @param byteOffset The offset into the binary writer to overwrite binary data
  81494. * @param vertexAttributeKind The vertex attribute type
  81495. * @param meshAttributeArray The vertex attribute data
  81496. * @param binaryWriter The writer containing the binary data
  81497. * @param convertToRightHandedSystem Converts the values to right-handed
  81498. */
  81499. private writeVertexAttributeData;
  81500. /**
  81501. * Writes mesh attribute data to a data buffer
  81502. * Returns the bytelength of the data
  81503. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81504. * @param meshAttributeArray Array containing the attribute data
  81505. * @param binaryWriter The buffer to write the binary data to
  81506. * @param indices Used to specify the order of the vertex data
  81507. * @param convertToRightHandedSystem Converts the values to right-handed
  81508. */
  81509. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81510. /**
  81511. * Generates glTF json data
  81512. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81513. * @param glTFPrefix Text to use when prefixing a glTF file
  81514. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81515. * @returns json data as string
  81516. */
  81517. private generateJSON;
  81518. /**
  81519. * Generates data for .gltf and .bin files based on the glTF prefix string
  81520. * @param glTFPrefix Text to use when prefixing a glTF file
  81521. * @param dispose Dispose the exporter
  81522. * @returns GLTFData with glTF file data
  81523. */
  81524. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81525. /**
  81526. * Creates a binary buffer for glTF
  81527. * @returns array buffer for binary data
  81528. */
  81529. private _generateBinaryAsync;
  81530. /**
  81531. * Pads the number to a multiple of 4
  81532. * @param num number to pad
  81533. * @returns padded number
  81534. */
  81535. private _getPadding;
  81536. /**
  81537. * @hidden
  81538. */
  81539. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81540. /**
  81541. * Sets the TRS for each node
  81542. * @param node glTF Node for storing the transformation data
  81543. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81544. * @param convertToRightHandedSystem Converts the values to right-handed
  81545. */
  81546. private setNodeTransformation;
  81547. private getVertexBufferFromMesh;
  81548. /**
  81549. * Creates a bufferview based on the vertices type for the Babylon mesh
  81550. * @param kind Indicates the type of vertices data
  81551. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81552. * @param binaryWriter The buffer to write the bufferview data to
  81553. * @param convertToRightHandedSystem Converts the values to right-handed
  81554. */
  81555. private createBufferViewKind;
  81556. /**
  81557. * The primitive mode of the Babylon mesh
  81558. * @param babylonMesh The BabylonJS mesh
  81559. */
  81560. private getMeshPrimitiveMode;
  81561. /**
  81562. * Sets the primitive mode of the glTF mesh primitive
  81563. * @param meshPrimitive glTF mesh primitive
  81564. * @param primitiveMode The primitive mode
  81565. */
  81566. private setPrimitiveMode;
  81567. /**
  81568. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81569. * @param meshPrimitive glTF mesh primitive
  81570. * @param attributeKind vertex attribute
  81571. * @returns boolean specifying if uv coordinates are present
  81572. */
  81573. private setAttributeKind;
  81574. /**
  81575. * Sets data for the primitive attributes of each submesh
  81576. * @param mesh glTF Mesh object to store the primitive attribute information
  81577. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81578. * @param binaryWriter Buffer to write the attribute data to
  81579. * @param convertToRightHandedSystem Converts the values to right-handed
  81580. */
  81581. private setPrimitiveAttributesAsync;
  81582. /**
  81583. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81584. * @param node The node to check
  81585. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81586. */
  81587. private isBabylonCoordinateSystemConvertingNode;
  81588. /**
  81589. * Creates a glTF scene based on the array of meshes
  81590. * Returns the the total byte offset
  81591. * @param babylonScene Babylon scene to get the mesh data from
  81592. * @param binaryWriter Buffer to write binary data to
  81593. */
  81594. private createSceneAsync;
  81595. /**
  81596. * Creates a mapping of Node unique id to node index and handles animations
  81597. * @param babylonScene Babylon Scene
  81598. * @param nodes Babylon transform nodes
  81599. * @param binaryWriter Buffer to write binary data to
  81600. * @returns Node mapping of unique id to index
  81601. */
  81602. private createNodeMapAndAnimationsAsync;
  81603. /**
  81604. * Creates a glTF node from a Babylon mesh
  81605. * @param babylonMesh Source Babylon mesh
  81606. * @param binaryWriter Buffer for storing geometry data
  81607. * @param convertToRightHandedSystem Converts the values to right-handed
  81608. * @param nodeMap Node mapping of unique id to glTF node index
  81609. * @returns glTF node
  81610. */
  81611. private createNodeAsync;
  81612. }
  81613. /**
  81614. * @hidden
  81615. *
  81616. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81617. */
  81618. export class _BinaryWriter {
  81619. /**
  81620. * Array buffer which stores all binary data
  81621. */
  81622. private _arrayBuffer;
  81623. /**
  81624. * View of the array buffer
  81625. */
  81626. private _dataView;
  81627. /**
  81628. * byte offset of data in array buffer
  81629. */
  81630. private _byteOffset;
  81631. /**
  81632. * Initialize binary writer with an initial byte length
  81633. * @param byteLength Initial byte length of the array buffer
  81634. */
  81635. constructor(byteLength: number);
  81636. /**
  81637. * Resize the array buffer to the specified byte length
  81638. * @param byteLength
  81639. */
  81640. private resizeBuffer;
  81641. /**
  81642. * Get an array buffer with the length of the byte offset
  81643. * @returns ArrayBuffer resized to the byte offset
  81644. */
  81645. getArrayBuffer(): ArrayBuffer;
  81646. /**
  81647. * Get the byte offset of the array buffer
  81648. * @returns byte offset
  81649. */
  81650. getByteOffset(): number;
  81651. /**
  81652. * Stores an UInt8 in the array buffer
  81653. * @param entry
  81654. * @param byteOffset If defined, specifies where to set the value as an offset.
  81655. */
  81656. setUInt8(entry: number, byteOffset?: number): void;
  81657. /**
  81658. * Gets an UInt32 in the array buffer
  81659. * @param entry
  81660. * @param byteOffset If defined, specifies where to set the value as an offset.
  81661. */
  81662. getUInt32(byteOffset: number): number;
  81663. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81664. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81665. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81666. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81667. /**
  81668. * Stores a Float32 in the array buffer
  81669. * @param entry
  81670. */
  81671. setFloat32(entry: number, byteOffset?: number): void;
  81672. /**
  81673. * Stores an UInt32 in the array buffer
  81674. * @param entry
  81675. * @param byteOffset If defined, specifies where to set the value as an offset.
  81676. */
  81677. setUInt32(entry: number, byteOffset?: number): void;
  81678. }
  81679. }
  81680. declare module BABYLON.GLTF2.Exporter {
  81681. /**
  81682. * @hidden
  81683. * Interface to store animation data.
  81684. */
  81685. export interface _IAnimationData {
  81686. /**
  81687. * Keyframe data.
  81688. */
  81689. inputs: number[];
  81690. /**
  81691. * Value data.
  81692. */
  81693. outputs: number[][];
  81694. /**
  81695. * Animation interpolation data.
  81696. */
  81697. samplerInterpolation: AnimationSamplerInterpolation;
  81698. /**
  81699. * Minimum keyframe value.
  81700. */
  81701. inputsMin: number;
  81702. /**
  81703. * Maximum keyframe value.
  81704. */
  81705. inputsMax: number;
  81706. }
  81707. /**
  81708. * @hidden
  81709. */
  81710. export interface _IAnimationInfo {
  81711. /**
  81712. * The target channel for the animation
  81713. */
  81714. animationChannelTargetPath: AnimationChannelTargetPath;
  81715. /**
  81716. * The glTF accessor type for the data.
  81717. */
  81718. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81719. /**
  81720. * Specifies if quaternions should be used.
  81721. */
  81722. useQuaternion: boolean;
  81723. }
  81724. /**
  81725. * @hidden
  81726. * Utility class for generating glTF animation data from BabylonJS.
  81727. */
  81728. export class _GLTFAnimation {
  81729. /**
  81730. * @ignore
  81731. *
  81732. * Creates glTF channel animation from BabylonJS animation.
  81733. * @param babylonTransformNode - BabylonJS mesh.
  81734. * @param animation - animation.
  81735. * @param animationChannelTargetPath - The target animation channel.
  81736. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81737. * @param useQuaternion - Specifies if quaternions are used.
  81738. * @returns nullable IAnimationData
  81739. */
  81740. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81741. private static _DeduceAnimationInfo;
  81742. /**
  81743. * @ignore
  81744. * Create node animations from the transform node animations
  81745. * @param babylonNode
  81746. * @param runtimeGLTFAnimation
  81747. * @param idleGLTFAnimations
  81748. * @param nodeMap
  81749. * @param nodes
  81750. * @param binaryWriter
  81751. * @param bufferViews
  81752. * @param accessors
  81753. * @param convertToRightHandedSystem
  81754. * @param animationSampleRate
  81755. */
  81756. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81757. [key: number]: number;
  81758. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81759. /**
  81760. * @ignore
  81761. * Create node animations from the animation groups
  81762. * @param babylonScene
  81763. * @param glTFAnimations
  81764. * @param nodeMap
  81765. * @param nodes
  81766. * @param binaryWriter
  81767. * @param bufferViews
  81768. * @param accessors
  81769. * @param convertToRightHandedSystemMap
  81770. * @param animationSampleRate
  81771. */
  81772. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81773. [key: number]: number;
  81774. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81775. [nodeId: number]: boolean;
  81776. }, animationSampleRate: number): void;
  81777. private static AddAnimation;
  81778. /**
  81779. * Create a baked animation
  81780. * @param babylonTransformNode BabylonJS mesh
  81781. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81782. * @param animationChannelTargetPath animation target channel
  81783. * @param minFrame minimum animation frame
  81784. * @param maxFrame maximum animation frame
  81785. * @param fps frames per second of the animation
  81786. * @param inputs input key frames of the animation
  81787. * @param outputs output key frame data of the animation
  81788. * @param convertToRightHandedSystem converts the values to right-handed
  81789. * @param useQuaternion specifies if quaternions should be used
  81790. */
  81791. private static _CreateBakedAnimation;
  81792. private static _ConvertFactorToVector3OrQuaternion;
  81793. private static _SetInterpolatedValue;
  81794. /**
  81795. * Creates linear animation from the animation key frames
  81796. * @param babylonTransformNode BabylonJS mesh
  81797. * @param animation BabylonJS animation
  81798. * @param animationChannelTargetPath The target animation channel
  81799. * @param frameDelta The difference between the last and first frame of the animation
  81800. * @param inputs Array to store the key frame times
  81801. * @param outputs Array to store the key frame data
  81802. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81803. * @param useQuaternion Specifies if quaternions are used in the animation
  81804. */
  81805. private static _CreateLinearOrStepAnimation;
  81806. /**
  81807. * Creates cubic spline animation from the animation key frames
  81808. * @param babylonTransformNode BabylonJS mesh
  81809. * @param animation BabylonJS animation
  81810. * @param animationChannelTargetPath The target animation channel
  81811. * @param frameDelta The difference between the last and first frame of the animation
  81812. * @param inputs Array to store the key frame times
  81813. * @param outputs Array to store the key frame data
  81814. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81815. * @param useQuaternion Specifies if quaternions are used in the animation
  81816. */
  81817. private static _CreateCubicSplineAnimation;
  81818. private static _GetBasePositionRotationOrScale;
  81819. /**
  81820. * Adds a key frame value
  81821. * @param keyFrame
  81822. * @param animation
  81823. * @param outputs
  81824. * @param animationChannelTargetPath
  81825. * @param basePositionRotationOrScale
  81826. * @param convertToRightHandedSystem
  81827. * @param useQuaternion
  81828. */
  81829. private static _AddKeyframeValue;
  81830. /**
  81831. * Determine the interpolation based on the key frames
  81832. * @param keyFrames
  81833. * @param animationChannelTargetPath
  81834. * @param useQuaternion
  81835. */
  81836. private static _DeduceInterpolation;
  81837. /**
  81838. * Adds an input tangent or output tangent to the output data
  81839. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81840. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81841. * @param outputs The animation data by keyframe
  81842. * @param animationChannelTargetPath The target animation channel
  81843. * @param interpolation The interpolation type
  81844. * @param keyFrame The key frame with the animation data
  81845. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81846. * @param useQuaternion Specifies if quaternions are used
  81847. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81848. */
  81849. private static AddSplineTangent;
  81850. /**
  81851. * Get the minimum and maximum key frames' frame values
  81852. * @param keyFrames animation key frames
  81853. * @returns the minimum and maximum key frame value
  81854. */
  81855. private static calculateMinMaxKeyFrames;
  81856. }
  81857. }
  81858. declare module BABYLON.GLTF2.Exporter {
  81859. /** @hidden */
  81860. export var textureTransformPixelShader: {
  81861. name: string;
  81862. shader: string;
  81863. };
  81864. }
  81865. declare module BABYLON.GLTF2.Exporter.Extensions {
  81866. /**
  81867. * @hidden
  81868. */
  81869. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81870. private _recordedTextures;
  81871. /** Name of this extension */
  81872. readonly name: string;
  81873. /** Defines whether this extension is enabled */
  81874. enabled: boolean;
  81875. /** Defines whether this extension is required */
  81876. required: boolean;
  81877. /** Reference to the glTF exporter */
  81878. private _wasUsed;
  81879. constructor(exporter: _Exporter);
  81880. dispose(): void;
  81881. /** @hidden */
  81882. get wasUsed(): boolean;
  81883. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81884. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81885. /**
  81886. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81887. * @param babylonTexture
  81888. * @param offset
  81889. * @param rotation
  81890. * @param scale
  81891. * @param scene
  81892. */
  81893. private _textureTransformTextureAsync;
  81894. }
  81895. }
  81896. declare module BABYLON.GLTF2.Exporter.Extensions {
  81897. /**
  81898. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81899. */
  81900. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81901. /** The name of this extension. */
  81902. readonly name: string;
  81903. /** Defines whether this extension is enabled. */
  81904. enabled: boolean;
  81905. /** Defines whether this extension is required */
  81906. required: boolean;
  81907. /** Reference to the glTF exporter */
  81908. private _exporter;
  81909. private _lights;
  81910. /** @hidden */
  81911. constructor(exporter: _Exporter);
  81912. /** @hidden */
  81913. dispose(): void;
  81914. /** @hidden */
  81915. get wasUsed(): boolean;
  81916. /** @hidden */
  81917. onExporting(): void;
  81918. /**
  81919. * Define this method to modify the default behavior when exporting a node
  81920. * @param context The context when exporting the node
  81921. * @param node glTF node
  81922. * @param babylonNode BabylonJS node
  81923. * @param nodeMap Node mapping of unique id to glTF node index
  81924. * @returns nullable INode promise
  81925. */
  81926. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81927. [key: number]: number;
  81928. }): Promise<Nullable<INode>>;
  81929. }
  81930. }
  81931. declare module BABYLON.GLTF2.Exporter.Extensions {
  81932. /**
  81933. * @hidden
  81934. */
  81935. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81936. /** Name of this extension */
  81937. readonly name: string;
  81938. /** Defines whether this extension is enabled */
  81939. enabled: boolean;
  81940. /** Defines whether this extension is required */
  81941. required: boolean;
  81942. /** Reference to the glTF exporter */
  81943. private _textureInfos;
  81944. private _exportedTextures;
  81945. private _wasUsed;
  81946. constructor(exporter: _Exporter);
  81947. dispose(): void;
  81948. /** @hidden */
  81949. get wasUsed(): boolean;
  81950. private _getTextureIndex;
  81951. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81952. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81953. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81954. }
  81955. }
  81956. declare module BABYLON {
  81957. /**
  81958. * Class for generating STL data from a Babylon scene.
  81959. */
  81960. export class STLExport {
  81961. /**
  81962. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81963. * @param meshes list defines the mesh to serialize
  81964. * @param download triggers the automatic download of the file.
  81965. * @param fileName changes the downloads fileName.
  81966. * @param binary changes the STL to a binary type.
  81967. * @param isLittleEndian toggle for binary type exporter.
  81968. * @returns the STL as UTF8 string
  81969. */
  81970. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81971. }
  81972. }
  81973. declare module "babylonjs-gltf2interface" {
  81974. export = BABYLON.GLTF2;
  81975. }
  81976. /**
  81977. * Module for glTF 2.0 Interface
  81978. */
  81979. declare module BABYLON.GLTF2 {
  81980. /**
  81981. * The datatype of the components in the attribute
  81982. */
  81983. const enum AccessorComponentType {
  81984. /**
  81985. * Byte
  81986. */
  81987. BYTE = 5120,
  81988. /**
  81989. * Unsigned Byte
  81990. */
  81991. UNSIGNED_BYTE = 5121,
  81992. /**
  81993. * Short
  81994. */
  81995. SHORT = 5122,
  81996. /**
  81997. * Unsigned Short
  81998. */
  81999. UNSIGNED_SHORT = 5123,
  82000. /**
  82001. * Unsigned Int
  82002. */
  82003. UNSIGNED_INT = 5125,
  82004. /**
  82005. * Float
  82006. */
  82007. FLOAT = 5126,
  82008. }
  82009. /**
  82010. * Specifies if the attirbute is a scalar, vector, or matrix
  82011. */
  82012. const enum AccessorType {
  82013. /**
  82014. * Scalar
  82015. */
  82016. SCALAR = "SCALAR",
  82017. /**
  82018. * Vector2
  82019. */
  82020. VEC2 = "VEC2",
  82021. /**
  82022. * Vector3
  82023. */
  82024. VEC3 = "VEC3",
  82025. /**
  82026. * Vector4
  82027. */
  82028. VEC4 = "VEC4",
  82029. /**
  82030. * Matrix2x2
  82031. */
  82032. MAT2 = "MAT2",
  82033. /**
  82034. * Matrix3x3
  82035. */
  82036. MAT3 = "MAT3",
  82037. /**
  82038. * Matrix4x4
  82039. */
  82040. MAT4 = "MAT4",
  82041. }
  82042. /**
  82043. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82044. */
  82045. const enum AnimationChannelTargetPath {
  82046. /**
  82047. * Translation
  82048. */
  82049. TRANSLATION = "translation",
  82050. /**
  82051. * Rotation
  82052. */
  82053. ROTATION = "rotation",
  82054. /**
  82055. * Scale
  82056. */
  82057. SCALE = "scale",
  82058. /**
  82059. * Weights
  82060. */
  82061. WEIGHTS = "weights",
  82062. }
  82063. /**
  82064. * Interpolation algorithm
  82065. */
  82066. const enum AnimationSamplerInterpolation {
  82067. /**
  82068. * The animated values are linearly interpolated between keyframes
  82069. */
  82070. LINEAR = "LINEAR",
  82071. /**
  82072. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82073. */
  82074. STEP = "STEP",
  82075. /**
  82076. * The animation's interpolation is computed using a cubic spline with specified tangents
  82077. */
  82078. CUBICSPLINE = "CUBICSPLINE",
  82079. }
  82080. /**
  82081. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82082. */
  82083. const enum CameraType {
  82084. /**
  82085. * A perspective camera containing properties to create a perspective projection matrix
  82086. */
  82087. PERSPECTIVE = "perspective",
  82088. /**
  82089. * An orthographic camera containing properties to create an orthographic projection matrix
  82090. */
  82091. ORTHOGRAPHIC = "orthographic",
  82092. }
  82093. /**
  82094. * The mime-type of the image
  82095. */
  82096. const enum ImageMimeType {
  82097. /**
  82098. * JPEG Mime-type
  82099. */
  82100. JPEG = "image/jpeg",
  82101. /**
  82102. * PNG Mime-type
  82103. */
  82104. PNG = "image/png",
  82105. }
  82106. /**
  82107. * The alpha rendering mode of the material
  82108. */
  82109. const enum MaterialAlphaMode {
  82110. /**
  82111. * The alpha value is ignored and the rendered output is fully opaque
  82112. */
  82113. OPAQUE = "OPAQUE",
  82114. /**
  82115. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82116. */
  82117. MASK = "MASK",
  82118. /**
  82119. * 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)
  82120. */
  82121. BLEND = "BLEND",
  82122. }
  82123. /**
  82124. * The type of the primitives to render
  82125. */
  82126. const enum MeshPrimitiveMode {
  82127. /**
  82128. * Points
  82129. */
  82130. POINTS = 0,
  82131. /**
  82132. * Lines
  82133. */
  82134. LINES = 1,
  82135. /**
  82136. * Line Loop
  82137. */
  82138. LINE_LOOP = 2,
  82139. /**
  82140. * Line Strip
  82141. */
  82142. LINE_STRIP = 3,
  82143. /**
  82144. * Triangles
  82145. */
  82146. TRIANGLES = 4,
  82147. /**
  82148. * Triangle Strip
  82149. */
  82150. TRIANGLE_STRIP = 5,
  82151. /**
  82152. * Triangle Fan
  82153. */
  82154. TRIANGLE_FAN = 6,
  82155. }
  82156. /**
  82157. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82158. */
  82159. const enum TextureMagFilter {
  82160. /**
  82161. * Nearest
  82162. */
  82163. NEAREST = 9728,
  82164. /**
  82165. * Linear
  82166. */
  82167. LINEAR = 9729,
  82168. }
  82169. /**
  82170. * Minification filter. All valid values correspond to WebGL enums
  82171. */
  82172. const enum TextureMinFilter {
  82173. /**
  82174. * Nearest
  82175. */
  82176. NEAREST = 9728,
  82177. /**
  82178. * Linear
  82179. */
  82180. LINEAR = 9729,
  82181. /**
  82182. * Nearest Mip-Map Nearest
  82183. */
  82184. NEAREST_MIPMAP_NEAREST = 9984,
  82185. /**
  82186. * Linear Mipmap Nearest
  82187. */
  82188. LINEAR_MIPMAP_NEAREST = 9985,
  82189. /**
  82190. * Nearest Mipmap Linear
  82191. */
  82192. NEAREST_MIPMAP_LINEAR = 9986,
  82193. /**
  82194. * Linear Mipmap Linear
  82195. */
  82196. LINEAR_MIPMAP_LINEAR = 9987,
  82197. }
  82198. /**
  82199. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82200. */
  82201. const enum TextureWrapMode {
  82202. /**
  82203. * Clamp to Edge
  82204. */
  82205. CLAMP_TO_EDGE = 33071,
  82206. /**
  82207. * Mirrored Repeat
  82208. */
  82209. MIRRORED_REPEAT = 33648,
  82210. /**
  82211. * Repeat
  82212. */
  82213. REPEAT = 10497,
  82214. }
  82215. /**
  82216. * glTF Property
  82217. */
  82218. interface IProperty {
  82219. /**
  82220. * Dictionary object with extension-specific objects
  82221. */
  82222. extensions?: {
  82223. [key: string]: any;
  82224. };
  82225. /**
  82226. * Application-Specific data
  82227. */
  82228. extras?: any;
  82229. }
  82230. /**
  82231. * glTF Child of Root Property
  82232. */
  82233. interface IChildRootProperty extends IProperty {
  82234. /**
  82235. * The user-defined name of this object
  82236. */
  82237. name?: string;
  82238. }
  82239. /**
  82240. * Indices of those attributes that deviate from their initialization value
  82241. */
  82242. interface IAccessorSparseIndices extends IProperty {
  82243. /**
  82244. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82245. */
  82246. bufferView: number;
  82247. /**
  82248. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82249. */
  82250. byteOffset?: number;
  82251. /**
  82252. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82253. */
  82254. componentType: AccessorComponentType;
  82255. }
  82256. /**
  82257. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82258. */
  82259. interface IAccessorSparseValues extends IProperty {
  82260. /**
  82261. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82262. */
  82263. bufferView: number;
  82264. /**
  82265. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82266. */
  82267. byteOffset?: number;
  82268. }
  82269. /**
  82270. * Sparse storage of attributes that deviate from their initialization value
  82271. */
  82272. interface IAccessorSparse extends IProperty {
  82273. /**
  82274. * The number of attributes encoded in this sparse accessor
  82275. */
  82276. count: number;
  82277. /**
  82278. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82279. */
  82280. indices: IAccessorSparseIndices;
  82281. /**
  82282. * 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
  82283. */
  82284. values: IAccessorSparseValues;
  82285. }
  82286. /**
  82287. * 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
  82288. */
  82289. interface IAccessor extends IChildRootProperty {
  82290. /**
  82291. * The index of the bufferview
  82292. */
  82293. bufferView?: number;
  82294. /**
  82295. * The offset relative to the start of the bufferView in bytes
  82296. */
  82297. byteOffset?: number;
  82298. /**
  82299. * The datatype of components in the attribute
  82300. */
  82301. componentType: AccessorComponentType;
  82302. /**
  82303. * Specifies whether integer data values should be normalized
  82304. */
  82305. normalized?: boolean;
  82306. /**
  82307. * The number of attributes referenced by this accessor
  82308. */
  82309. count: number;
  82310. /**
  82311. * Specifies if the attribute is a scalar, vector, or matrix
  82312. */
  82313. type: AccessorType;
  82314. /**
  82315. * Maximum value of each component in this attribute
  82316. */
  82317. max?: number[];
  82318. /**
  82319. * Minimum value of each component in this attribute
  82320. */
  82321. min?: number[];
  82322. /**
  82323. * Sparse storage of attributes that deviate from their initialization value
  82324. */
  82325. sparse?: IAccessorSparse;
  82326. }
  82327. /**
  82328. * Targets an animation's sampler at a node's property
  82329. */
  82330. interface IAnimationChannel extends IProperty {
  82331. /**
  82332. * The index of a sampler in this animation used to compute the value for the target
  82333. */
  82334. sampler: number;
  82335. /**
  82336. * The index of the node and TRS property to target
  82337. */
  82338. target: IAnimationChannelTarget;
  82339. }
  82340. /**
  82341. * The index of the node and TRS property that an animation channel targets
  82342. */
  82343. interface IAnimationChannelTarget extends IProperty {
  82344. /**
  82345. * The index of the node to target
  82346. */
  82347. node: number;
  82348. /**
  82349. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82350. */
  82351. path: AnimationChannelTargetPath;
  82352. }
  82353. /**
  82354. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82355. */
  82356. interface IAnimationSampler extends IProperty {
  82357. /**
  82358. * The index of an accessor containing keyframe input values, e.g., time
  82359. */
  82360. input: number;
  82361. /**
  82362. * Interpolation algorithm
  82363. */
  82364. interpolation?: AnimationSamplerInterpolation;
  82365. /**
  82366. * The index of an accessor, containing keyframe output values
  82367. */
  82368. output: number;
  82369. }
  82370. /**
  82371. * A keyframe animation
  82372. */
  82373. interface IAnimation extends IChildRootProperty {
  82374. /**
  82375. * An array of channels, each of which targets an animation's sampler at a node's property
  82376. */
  82377. channels: IAnimationChannel[];
  82378. /**
  82379. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82380. */
  82381. samplers: IAnimationSampler[];
  82382. }
  82383. /**
  82384. * Metadata about the glTF asset
  82385. */
  82386. interface IAsset extends IChildRootProperty {
  82387. /**
  82388. * A copyright message suitable for display to credit the content creator
  82389. */
  82390. copyright?: string;
  82391. /**
  82392. * Tool that generated this glTF model. Useful for debugging
  82393. */
  82394. generator?: string;
  82395. /**
  82396. * The glTF version that this asset targets
  82397. */
  82398. version: string;
  82399. /**
  82400. * The minimum glTF version that this asset targets
  82401. */
  82402. minVersion?: string;
  82403. }
  82404. /**
  82405. * A buffer points to binary geometry, animation, or skins
  82406. */
  82407. interface IBuffer extends IChildRootProperty {
  82408. /**
  82409. * 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
  82410. */
  82411. uri?: string;
  82412. /**
  82413. * The length of the buffer in bytes
  82414. */
  82415. byteLength: number;
  82416. }
  82417. /**
  82418. * A view into a buffer generally representing a subset of the buffer
  82419. */
  82420. interface IBufferView extends IChildRootProperty {
  82421. /**
  82422. * The index of the buffer
  82423. */
  82424. buffer: number;
  82425. /**
  82426. * The offset into the buffer in bytes
  82427. */
  82428. byteOffset?: number;
  82429. /**
  82430. * The lenth of the bufferView in bytes
  82431. */
  82432. byteLength: number;
  82433. /**
  82434. * The stride, in bytes
  82435. */
  82436. byteStride?: number;
  82437. }
  82438. /**
  82439. * An orthographic camera containing properties to create an orthographic projection matrix
  82440. */
  82441. interface ICameraOrthographic extends IProperty {
  82442. /**
  82443. * The floating-point horizontal magnification of the view. Must not be zero
  82444. */
  82445. xmag: number;
  82446. /**
  82447. * The floating-point vertical magnification of the view. Must not be zero
  82448. */
  82449. ymag: number;
  82450. /**
  82451. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82452. */
  82453. zfar: number;
  82454. /**
  82455. * The floating-point distance to the near clipping plane
  82456. */
  82457. znear: number;
  82458. }
  82459. /**
  82460. * A perspective camera containing properties to create a perspective projection matrix
  82461. */
  82462. interface ICameraPerspective extends IProperty {
  82463. /**
  82464. * The floating-point aspect ratio of the field of view
  82465. */
  82466. aspectRatio?: number;
  82467. /**
  82468. * The floating-point vertical field of view in radians
  82469. */
  82470. yfov: number;
  82471. /**
  82472. * The floating-point distance to the far clipping plane
  82473. */
  82474. zfar?: number;
  82475. /**
  82476. * The floating-point distance to the near clipping plane
  82477. */
  82478. znear: number;
  82479. }
  82480. /**
  82481. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82482. */
  82483. interface ICamera extends IChildRootProperty {
  82484. /**
  82485. * An orthographic camera containing properties to create an orthographic projection matrix
  82486. */
  82487. orthographic?: ICameraOrthographic;
  82488. /**
  82489. * A perspective camera containing properties to create a perspective projection matrix
  82490. */
  82491. perspective?: ICameraPerspective;
  82492. /**
  82493. * Specifies if the camera uses a perspective or orthographic projection
  82494. */
  82495. type: CameraType;
  82496. }
  82497. /**
  82498. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82499. */
  82500. interface IImage extends IChildRootProperty {
  82501. /**
  82502. * 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
  82503. */
  82504. uri?: string;
  82505. /**
  82506. * The image's MIME type
  82507. */
  82508. mimeType?: ImageMimeType;
  82509. /**
  82510. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82511. */
  82512. bufferView?: number;
  82513. }
  82514. /**
  82515. * Material Normal Texture Info
  82516. */
  82517. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82518. /**
  82519. * The scalar multiplier applied to each normal vector of the normal texture
  82520. */
  82521. scale?: number;
  82522. }
  82523. /**
  82524. * Material Occlusion Texture Info
  82525. */
  82526. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82527. /**
  82528. * A scalar multiplier controlling the amount of occlusion applied
  82529. */
  82530. strength?: number;
  82531. }
  82532. /**
  82533. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82534. */
  82535. interface IMaterialPbrMetallicRoughness {
  82536. /**
  82537. * The material's base color factor
  82538. */
  82539. baseColorFactor?: number[];
  82540. /**
  82541. * The base color texture
  82542. */
  82543. baseColorTexture?: ITextureInfo;
  82544. /**
  82545. * The metalness of the material
  82546. */
  82547. metallicFactor?: number;
  82548. /**
  82549. * The roughness of the material
  82550. */
  82551. roughnessFactor?: number;
  82552. /**
  82553. * The metallic-roughness texture
  82554. */
  82555. metallicRoughnessTexture?: ITextureInfo;
  82556. }
  82557. /**
  82558. * The material appearance of a primitive
  82559. */
  82560. interface IMaterial extends IChildRootProperty {
  82561. /**
  82562. * 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
  82563. */
  82564. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82565. /**
  82566. * The normal map texture
  82567. */
  82568. normalTexture?: IMaterialNormalTextureInfo;
  82569. /**
  82570. * The occlusion map texture
  82571. */
  82572. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82573. /**
  82574. * The emissive map texture
  82575. */
  82576. emissiveTexture?: ITextureInfo;
  82577. /**
  82578. * 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
  82579. */
  82580. emissiveFactor?: number[];
  82581. /**
  82582. * The alpha rendering mode of the material
  82583. */
  82584. alphaMode?: MaterialAlphaMode;
  82585. /**
  82586. * The alpha cutoff value of the material
  82587. */
  82588. alphaCutoff?: number;
  82589. /**
  82590. * Specifies whether the material is double sided
  82591. */
  82592. doubleSided?: boolean;
  82593. }
  82594. /**
  82595. * Geometry to be rendered with the given material
  82596. */
  82597. interface IMeshPrimitive extends IProperty {
  82598. /**
  82599. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82600. */
  82601. attributes: {
  82602. [name: string]: number;
  82603. };
  82604. /**
  82605. * The index of the accessor that contains the indices
  82606. */
  82607. indices?: number;
  82608. /**
  82609. * The index of the material to apply to this primitive when rendering
  82610. */
  82611. material?: number;
  82612. /**
  82613. * The type of primitives to render. All valid values correspond to WebGL enums
  82614. */
  82615. mode?: MeshPrimitiveMode;
  82616. /**
  82617. * 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
  82618. */
  82619. targets?: {
  82620. [name: string]: number;
  82621. }[];
  82622. }
  82623. /**
  82624. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82625. */
  82626. interface IMesh extends IChildRootProperty {
  82627. /**
  82628. * An array of primitives, each defining geometry to be rendered with a material
  82629. */
  82630. primitives: IMeshPrimitive[];
  82631. /**
  82632. * Array of weights to be applied to the Morph Targets
  82633. */
  82634. weights?: number[];
  82635. }
  82636. /**
  82637. * A node in the node hierarchy
  82638. */
  82639. interface INode extends IChildRootProperty {
  82640. /**
  82641. * The index of the camera referenced by this node
  82642. */
  82643. camera?: number;
  82644. /**
  82645. * The indices of this node's children
  82646. */
  82647. children?: number[];
  82648. /**
  82649. * The index of the skin referenced by this node
  82650. */
  82651. skin?: number;
  82652. /**
  82653. * A floating-point 4x4 transformation matrix stored in column-major order
  82654. */
  82655. matrix?: number[];
  82656. /**
  82657. * The index of the mesh in this node
  82658. */
  82659. mesh?: number;
  82660. /**
  82661. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82662. */
  82663. rotation?: number[];
  82664. /**
  82665. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82666. */
  82667. scale?: number[];
  82668. /**
  82669. * The node's translation along the x, y, and z axes
  82670. */
  82671. translation?: number[];
  82672. /**
  82673. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82674. */
  82675. weights?: number[];
  82676. }
  82677. /**
  82678. * Texture sampler properties for filtering and wrapping modes
  82679. */
  82680. interface ISampler extends IChildRootProperty {
  82681. /**
  82682. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82683. */
  82684. magFilter?: TextureMagFilter;
  82685. /**
  82686. * Minification filter. All valid values correspond to WebGL enums
  82687. */
  82688. minFilter?: TextureMinFilter;
  82689. /**
  82690. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82691. */
  82692. wrapS?: TextureWrapMode;
  82693. /**
  82694. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82695. */
  82696. wrapT?: TextureWrapMode;
  82697. }
  82698. /**
  82699. * The root nodes of a scene
  82700. */
  82701. interface IScene extends IChildRootProperty {
  82702. /**
  82703. * The indices of each root node
  82704. */
  82705. nodes: number[];
  82706. }
  82707. /**
  82708. * Joints and matrices defining a skin
  82709. */
  82710. interface ISkin extends IChildRootProperty {
  82711. /**
  82712. * 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
  82713. */
  82714. inverseBindMatrices?: number;
  82715. /**
  82716. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82717. */
  82718. skeleton?: number;
  82719. /**
  82720. * 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)
  82721. */
  82722. joints: number[];
  82723. }
  82724. /**
  82725. * A texture and its sampler
  82726. */
  82727. interface ITexture extends IChildRootProperty {
  82728. /**
  82729. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82730. */
  82731. sampler?: number;
  82732. /**
  82733. * The index of the image used by this texture
  82734. */
  82735. source: number;
  82736. }
  82737. /**
  82738. * Reference to a texture
  82739. */
  82740. interface ITextureInfo extends IProperty {
  82741. /**
  82742. * The index of the texture
  82743. */
  82744. index: number;
  82745. /**
  82746. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82747. */
  82748. texCoord?: number;
  82749. }
  82750. /**
  82751. * The root object for a glTF asset
  82752. */
  82753. interface IGLTF extends IProperty {
  82754. /**
  82755. * An array of accessors. An accessor is a typed view into a bufferView
  82756. */
  82757. accessors?: IAccessor[];
  82758. /**
  82759. * An array of keyframe animations
  82760. */
  82761. animations?: IAnimation[];
  82762. /**
  82763. * Metadata about the glTF asset
  82764. */
  82765. asset: IAsset;
  82766. /**
  82767. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82768. */
  82769. buffers?: IBuffer[];
  82770. /**
  82771. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82772. */
  82773. bufferViews?: IBufferView[];
  82774. /**
  82775. * An array of cameras
  82776. */
  82777. cameras?: ICamera[];
  82778. /**
  82779. * Names of glTF extensions used somewhere in this asset
  82780. */
  82781. extensionsUsed?: string[];
  82782. /**
  82783. * Names of glTF extensions required to properly load this asset
  82784. */
  82785. extensionsRequired?: string[];
  82786. /**
  82787. * An array of images. An image defines data used to create a texture
  82788. */
  82789. images?: IImage[];
  82790. /**
  82791. * An array of materials. A material defines the appearance of a primitive
  82792. */
  82793. materials?: IMaterial[];
  82794. /**
  82795. * An array of meshes. A mesh is a set of primitives to be rendered
  82796. */
  82797. meshes?: IMesh[];
  82798. /**
  82799. * An array of nodes
  82800. */
  82801. nodes?: INode[];
  82802. /**
  82803. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82804. */
  82805. samplers?: ISampler[];
  82806. /**
  82807. * The index of the default scene
  82808. */
  82809. scene?: number;
  82810. /**
  82811. * An array of scenes
  82812. */
  82813. scenes?: IScene[];
  82814. /**
  82815. * An array of skins. A skin is defined by joints and matrices
  82816. */
  82817. skins?: ISkin[];
  82818. /**
  82819. * An array of textures
  82820. */
  82821. textures?: ITexture[];
  82822. }
  82823. /**
  82824. * The glTF validation results
  82825. * @ignore
  82826. */
  82827. interface IGLTFValidationResults {
  82828. info: {
  82829. generator: string;
  82830. hasAnimations: boolean;
  82831. hasDefaultScene: boolean;
  82832. hasMaterials: boolean;
  82833. hasMorphTargets: boolean;
  82834. hasSkins: boolean;
  82835. hasTextures: boolean;
  82836. maxAttributesUsed: number;
  82837. primitivesCount: number
  82838. };
  82839. issues: {
  82840. messages: Array<string>;
  82841. numErrors: number;
  82842. numHints: number;
  82843. numInfos: number;
  82844. numWarnings: number;
  82845. truncated: boolean
  82846. };
  82847. mimeType: string;
  82848. uri: string;
  82849. validatedAt: string;
  82850. validatorVersion: string;
  82851. }
  82852. /**
  82853. * The glTF validation options
  82854. */
  82855. interface IGLTFValidationOptions {
  82856. /** Uri to use */
  82857. uri?: string;
  82858. /** Function used to load external resources */
  82859. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82860. /** Boolean indicating that we need to validate accessor data */
  82861. validateAccessorData?: boolean;
  82862. /** max number of issues allowed */
  82863. maxIssues?: number;
  82864. /** Ignored issues */
  82865. ignoredIssues?: Array<string>;
  82866. /** Value to override severy settings */
  82867. severityOverrides?: Object;
  82868. }
  82869. /**
  82870. * The glTF validator object
  82871. * @ignore
  82872. */
  82873. interface IGLTFValidator {
  82874. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82875. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82876. }
  82877. }
  82878. declare module BABYLON {
  82879. /** @hidden */
  82880. export var cellPixelShader: {
  82881. name: string;
  82882. shader: string;
  82883. };
  82884. }
  82885. declare module BABYLON {
  82886. /** @hidden */
  82887. export var cellVertexShader: {
  82888. name: string;
  82889. shader: string;
  82890. };
  82891. }
  82892. declare module BABYLON {
  82893. export class CellMaterial extends BABYLON.PushMaterial {
  82894. private _diffuseTexture;
  82895. diffuseTexture: BABYLON.BaseTexture;
  82896. diffuseColor: BABYLON.Color3;
  82897. _computeHighLevel: boolean;
  82898. computeHighLevel: boolean;
  82899. private _disableLighting;
  82900. disableLighting: boolean;
  82901. private _maxSimultaneousLights;
  82902. maxSimultaneousLights: number;
  82903. constructor(name: string, scene: BABYLON.Scene);
  82904. needAlphaBlending(): boolean;
  82905. needAlphaTesting(): boolean;
  82906. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82907. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82908. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82909. getAnimatables(): BABYLON.IAnimatable[];
  82910. getActiveTextures(): BABYLON.BaseTexture[];
  82911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82912. dispose(forceDisposeEffect?: boolean): void;
  82913. getClassName(): string;
  82914. clone(name: string): CellMaterial;
  82915. serialize(): any;
  82916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82917. }
  82918. }
  82919. declare module BABYLON {
  82920. export class CustomShaderStructure {
  82921. FragmentStore: string;
  82922. VertexStore: string;
  82923. constructor();
  82924. }
  82925. export class ShaderSpecialParts {
  82926. constructor();
  82927. Fragment_Begin: string;
  82928. Fragment_Definitions: string;
  82929. Fragment_MainBegin: string;
  82930. Fragment_Custom_Diffuse: string;
  82931. Fragment_Before_Lights: string;
  82932. Fragment_Before_Fog: string;
  82933. Fragment_Custom_Alpha: string;
  82934. Fragment_Before_FragColor: string;
  82935. Vertex_Begin: string;
  82936. Vertex_Definitions: string;
  82937. Vertex_MainBegin: string;
  82938. Vertex_Before_PositionUpdated: string;
  82939. Vertex_Before_NormalUpdated: string;
  82940. Vertex_After_WorldPosComputed: string;
  82941. Vertex_MainEnd: string;
  82942. }
  82943. export class CustomMaterial extends BABYLON.StandardMaterial {
  82944. static ShaderIndexer: number;
  82945. CustomParts: ShaderSpecialParts;
  82946. _isCreatedShader: boolean;
  82947. _createdShaderName: string;
  82948. _customUniform: string[];
  82949. _newUniforms: string[];
  82950. _newUniformInstances: {
  82951. [name: string]: any;
  82952. };
  82953. _newSamplerInstances: {
  82954. [name: string]: BABYLON.Texture;
  82955. };
  82956. _customAttributes: string[];
  82957. FragmentShader: string;
  82958. VertexShader: string;
  82959. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82960. ReviewUniform(name: string, arr: string[]): string[];
  82961. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82962. constructor(name: string, scene: BABYLON.Scene);
  82963. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82964. AddAttribute(name: string): CustomMaterial;
  82965. Fragment_Begin(shaderPart: string): CustomMaterial;
  82966. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82967. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82968. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82969. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82970. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82971. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82972. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82973. Vertex_Begin(shaderPart: string): CustomMaterial;
  82974. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82975. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82976. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82977. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82978. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82979. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82980. }
  82981. }
  82982. declare module BABYLON {
  82983. export class ShaderAlebdoParts {
  82984. constructor();
  82985. Fragment_Begin: string;
  82986. Fragment_Definitions: string;
  82987. Fragment_MainBegin: string;
  82988. Fragment_Custom_Albedo: string;
  82989. Fragment_Before_Lights: string;
  82990. Fragment_Custom_MetallicRoughness: string;
  82991. Fragment_Custom_MicroSurface: string;
  82992. Fragment_Before_Fog: string;
  82993. Fragment_Custom_Alpha: string;
  82994. Fragment_Before_FragColor: string;
  82995. Vertex_Begin: string;
  82996. Vertex_Definitions: string;
  82997. Vertex_MainBegin: string;
  82998. Vertex_Before_PositionUpdated: string;
  82999. Vertex_Before_NormalUpdated: string;
  83000. Vertex_After_WorldPosComputed: string;
  83001. Vertex_MainEnd: string;
  83002. }
  83003. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83004. static ShaderIndexer: number;
  83005. CustomParts: ShaderAlebdoParts;
  83006. _isCreatedShader: boolean;
  83007. _createdShaderName: string;
  83008. _customUniform: string[];
  83009. _newUniforms: string[];
  83010. _newUniformInstances: {
  83011. [name: string]: any;
  83012. };
  83013. _newSamplerInstances: {
  83014. [name: string]: BABYLON.Texture;
  83015. };
  83016. _customAttributes: string[];
  83017. FragmentShader: string;
  83018. VertexShader: string;
  83019. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83020. ReviewUniform(name: string, arr: string[]): string[];
  83021. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83022. constructor(name: string, scene: BABYLON.Scene);
  83023. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83024. AddAttribute(name: string): PBRCustomMaterial;
  83025. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83026. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83027. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83028. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83029. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83030. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83031. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83032. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83033. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83034. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83035. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83036. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83037. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83038. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83039. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83040. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83041. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83042. }
  83043. }
  83044. declare module BABYLON {
  83045. /** @hidden */
  83046. export var firePixelShader: {
  83047. name: string;
  83048. shader: string;
  83049. };
  83050. }
  83051. declare module BABYLON {
  83052. /** @hidden */
  83053. export var fireVertexShader: {
  83054. name: string;
  83055. shader: string;
  83056. };
  83057. }
  83058. declare module BABYLON {
  83059. export class FireMaterial extends BABYLON.PushMaterial {
  83060. private _diffuseTexture;
  83061. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83062. private _distortionTexture;
  83063. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83064. private _opacityTexture;
  83065. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83066. diffuseColor: BABYLON.Color3;
  83067. speed: number;
  83068. private _scaledDiffuse;
  83069. private _lastTime;
  83070. constructor(name: string, scene: BABYLON.Scene);
  83071. needAlphaBlending(): boolean;
  83072. needAlphaTesting(): boolean;
  83073. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83074. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83075. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83076. getAnimatables(): BABYLON.IAnimatable[];
  83077. getActiveTextures(): BABYLON.BaseTexture[];
  83078. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83079. getClassName(): string;
  83080. dispose(forceDisposeEffect?: boolean): void;
  83081. clone(name: string): FireMaterial;
  83082. serialize(): any;
  83083. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83084. }
  83085. }
  83086. declare module BABYLON {
  83087. /** @hidden */
  83088. export var furPixelShader: {
  83089. name: string;
  83090. shader: string;
  83091. };
  83092. }
  83093. declare module BABYLON {
  83094. /** @hidden */
  83095. export var furVertexShader: {
  83096. name: string;
  83097. shader: string;
  83098. };
  83099. }
  83100. declare module BABYLON {
  83101. export class FurMaterial extends BABYLON.PushMaterial {
  83102. private _diffuseTexture;
  83103. diffuseTexture: BABYLON.BaseTexture;
  83104. private _heightTexture;
  83105. heightTexture: BABYLON.BaseTexture;
  83106. diffuseColor: BABYLON.Color3;
  83107. furLength: number;
  83108. furAngle: number;
  83109. furColor: BABYLON.Color3;
  83110. furOffset: number;
  83111. furSpacing: number;
  83112. furGravity: BABYLON.Vector3;
  83113. furSpeed: number;
  83114. furDensity: number;
  83115. furOcclusion: number;
  83116. furTexture: BABYLON.DynamicTexture;
  83117. private _disableLighting;
  83118. disableLighting: boolean;
  83119. private _maxSimultaneousLights;
  83120. maxSimultaneousLights: number;
  83121. highLevelFur: boolean;
  83122. _meshes: BABYLON.AbstractMesh[];
  83123. private _furTime;
  83124. constructor(name: string, scene: BABYLON.Scene);
  83125. get furTime(): number;
  83126. set furTime(furTime: number);
  83127. needAlphaBlending(): boolean;
  83128. needAlphaTesting(): boolean;
  83129. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83130. updateFur(): void;
  83131. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83132. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83133. getAnimatables(): BABYLON.IAnimatable[];
  83134. getActiveTextures(): BABYLON.BaseTexture[];
  83135. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83136. dispose(forceDisposeEffect?: boolean): void;
  83137. clone(name: string): FurMaterial;
  83138. serialize(): any;
  83139. getClassName(): string;
  83140. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83141. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83142. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83143. }
  83144. }
  83145. declare module BABYLON {
  83146. /** @hidden */
  83147. export var gradientPixelShader: {
  83148. name: string;
  83149. shader: string;
  83150. };
  83151. }
  83152. declare module BABYLON {
  83153. /** @hidden */
  83154. export var gradientVertexShader: {
  83155. name: string;
  83156. shader: string;
  83157. };
  83158. }
  83159. declare module BABYLON {
  83160. export class GradientMaterial extends BABYLON.PushMaterial {
  83161. private _maxSimultaneousLights;
  83162. maxSimultaneousLights: number;
  83163. topColor: BABYLON.Color3;
  83164. topColorAlpha: number;
  83165. bottomColor: BABYLON.Color3;
  83166. bottomColorAlpha: number;
  83167. offset: number;
  83168. scale: number;
  83169. smoothness: number;
  83170. private _disableLighting;
  83171. disableLighting: boolean;
  83172. constructor(name: string, scene: BABYLON.Scene);
  83173. needAlphaBlending(): boolean;
  83174. needAlphaTesting(): boolean;
  83175. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83176. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83177. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83178. getAnimatables(): BABYLON.IAnimatable[];
  83179. dispose(forceDisposeEffect?: boolean): void;
  83180. clone(name: string): GradientMaterial;
  83181. serialize(): any;
  83182. getClassName(): string;
  83183. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83184. }
  83185. }
  83186. declare module BABYLON {
  83187. /** @hidden */
  83188. export var gridPixelShader: {
  83189. name: string;
  83190. shader: string;
  83191. };
  83192. }
  83193. declare module BABYLON {
  83194. /** @hidden */
  83195. export var gridVertexShader: {
  83196. name: string;
  83197. shader: string;
  83198. };
  83199. }
  83200. declare module BABYLON {
  83201. /**
  83202. * The grid materials allows you to wrap any shape with a grid.
  83203. * Colors are customizable.
  83204. */
  83205. export class GridMaterial extends BABYLON.PushMaterial {
  83206. /**
  83207. * Main color of the grid (e.g. between lines)
  83208. */
  83209. mainColor: BABYLON.Color3;
  83210. /**
  83211. * Color of the grid lines.
  83212. */
  83213. lineColor: BABYLON.Color3;
  83214. /**
  83215. * The scale of the grid compared to unit.
  83216. */
  83217. gridRatio: number;
  83218. /**
  83219. * Allows setting an offset for the grid lines.
  83220. */
  83221. gridOffset: BABYLON.Vector3;
  83222. /**
  83223. * The frequency of thicker lines.
  83224. */
  83225. majorUnitFrequency: number;
  83226. /**
  83227. * The visibility of minor units in the grid.
  83228. */
  83229. minorUnitVisibility: number;
  83230. /**
  83231. * The grid opacity outside of the lines.
  83232. */
  83233. opacity: number;
  83234. /**
  83235. * Determine RBG output is premultiplied by alpha value.
  83236. */
  83237. preMultiplyAlpha: boolean;
  83238. private _opacityTexture;
  83239. opacityTexture: BABYLON.BaseTexture;
  83240. private _gridControl;
  83241. /**
  83242. * constructor
  83243. * @param name The name given to the material in order to identify it afterwards.
  83244. * @param scene The scene the material is used in.
  83245. */
  83246. constructor(name: string, scene: BABYLON.Scene);
  83247. /**
  83248. * Returns wehter or not the grid requires alpha blending.
  83249. */
  83250. needAlphaBlending(): boolean;
  83251. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83252. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83253. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83254. /**
  83255. * Dispose the material and its associated resources.
  83256. * @param forceDisposeEffect will also dispose the used effect when true
  83257. */
  83258. dispose(forceDisposeEffect?: boolean): void;
  83259. clone(name: string): GridMaterial;
  83260. serialize(): any;
  83261. getClassName(): string;
  83262. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83263. }
  83264. }
  83265. declare module BABYLON {
  83266. /** @hidden */
  83267. export var lavaPixelShader: {
  83268. name: string;
  83269. shader: string;
  83270. };
  83271. }
  83272. declare module BABYLON {
  83273. /** @hidden */
  83274. export var lavaVertexShader: {
  83275. name: string;
  83276. shader: string;
  83277. };
  83278. }
  83279. declare module BABYLON {
  83280. export class LavaMaterial extends BABYLON.PushMaterial {
  83281. private _diffuseTexture;
  83282. diffuseTexture: BABYLON.BaseTexture;
  83283. noiseTexture: BABYLON.BaseTexture;
  83284. fogColor: BABYLON.Color3;
  83285. speed: number;
  83286. movingSpeed: number;
  83287. lowFrequencySpeed: number;
  83288. fogDensity: number;
  83289. private _lastTime;
  83290. diffuseColor: BABYLON.Color3;
  83291. private _disableLighting;
  83292. disableLighting: boolean;
  83293. private _unlit;
  83294. unlit: boolean;
  83295. private _maxSimultaneousLights;
  83296. maxSimultaneousLights: number;
  83297. private _scaledDiffuse;
  83298. constructor(name: string, scene: BABYLON.Scene);
  83299. needAlphaBlending(): boolean;
  83300. needAlphaTesting(): boolean;
  83301. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83302. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83303. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83304. getAnimatables(): BABYLON.IAnimatable[];
  83305. getActiveTextures(): BABYLON.BaseTexture[];
  83306. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83307. dispose(forceDisposeEffect?: boolean): void;
  83308. clone(name: string): LavaMaterial;
  83309. serialize(): any;
  83310. getClassName(): string;
  83311. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83312. }
  83313. }
  83314. declare module BABYLON {
  83315. /** @hidden */
  83316. export var mixPixelShader: {
  83317. name: string;
  83318. shader: string;
  83319. };
  83320. }
  83321. declare module BABYLON {
  83322. /** @hidden */
  83323. export var mixVertexShader: {
  83324. name: string;
  83325. shader: string;
  83326. };
  83327. }
  83328. declare module BABYLON {
  83329. export class MixMaterial extends BABYLON.PushMaterial {
  83330. /**
  83331. * Mix textures
  83332. */
  83333. private _mixTexture1;
  83334. mixTexture1: BABYLON.BaseTexture;
  83335. private _mixTexture2;
  83336. mixTexture2: BABYLON.BaseTexture;
  83337. /**
  83338. * Diffuse textures
  83339. */
  83340. private _diffuseTexture1;
  83341. diffuseTexture1: BABYLON.Texture;
  83342. private _diffuseTexture2;
  83343. diffuseTexture2: BABYLON.Texture;
  83344. private _diffuseTexture3;
  83345. diffuseTexture3: BABYLON.Texture;
  83346. private _diffuseTexture4;
  83347. diffuseTexture4: BABYLON.Texture;
  83348. private _diffuseTexture5;
  83349. diffuseTexture5: BABYLON.Texture;
  83350. private _diffuseTexture6;
  83351. diffuseTexture6: BABYLON.Texture;
  83352. private _diffuseTexture7;
  83353. diffuseTexture7: BABYLON.Texture;
  83354. private _diffuseTexture8;
  83355. diffuseTexture8: BABYLON.Texture;
  83356. /**
  83357. * Uniforms
  83358. */
  83359. diffuseColor: BABYLON.Color3;
  83360. specularColor: BABYLON.Color3;
  83361. specularPower: number;
  83362. private _disableLighting;
  83363. disableLighting: boolean;
  83364. private _maxSimultaneousLights;
  83365. maxSimultaneousLights: number;
  83366. constructor(name: string, scene: BABYLON.Scene);
  83367. needAlphaBlending(): boolean;
  83368. needAlphaTesting(): boolean;
  83369. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83370. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83371. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83372. getAnimatables(): BABYLON.IAnimatable[];
  83373. getActiveTextures(): BABYLON.BaseTexture[];
  83374. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83375. dispose(forceDisposeEffect?: boolean): void;
  83376. clone(name: string): MixMaterial;
  83377. serialize(): any;
  83378. getClassName(): string;
  83379. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83380. }
  83381. }
  83382. declare module BABYLON {
  83383. /** @hidden */
  83384. export var normalPixelShader: {
  83385. name: string;
  83386. shader: string;
  83387. };
  83388. }
  83389. declare module BABYLON {
  83390. /** @hidden */
  83391. export var normalVertexShader: {
  83392. name: string;
  83393. shader: string;
  83394. };
  83395. }
  83396. declare module BABYLON {
  83397. export class NormalMaterial extends BABYLON.PushMaterial {
  83398. private _diffuseTexture;
  83399. diffuseTexture: BABYLON.BaseTexture;
  83400. diffuseColor: BABYLON.Color3;
  83401. private _disableLighting;
  83402. disableLighting: boolean;
  83403. private _maxSimultaneousLights;
  83404. maxSimultaneousLights: number;
  83405. constructor(name: string, scene: BABYLON.Scene);
  83406. needAlphaBlending(): boolean;
  83407. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83408. needAlphaTesting(): boolean;
  83409. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83410. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83411. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83412. getAnimatables(): BABYLON.IAnimatable[];
  83413. getActiveTextures(): BABYLON.BaseTexture[];
  83414. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83415. dispose(forceDisposeEffect?: boolean): void;
  83416. clone(name: string): NormalMaterial;
  83417. serialize(): any;
  83418. getClassName(): string;
  83419. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83420. }
  83421. }
  83422. declare module BABYLON {
  83423. /** @hidden */
  83424. export var shadowOnlyPixelShader: {
  83425. name: string;
  83426. shader: string;
  83427. };
  83428. }
  83429. declare module BABYLON {
  83430. /** @hidden */
  83431. export var shadowOnlyVertexShader: {
  83432. name: string;
  83433. shader: string;
  83434. };
  83435. }
  83436. declare module BABYLON {
  83437. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83438. private _activeLight;
  83439. private _needAlphaBlending;
  83440. constructor(name: string, scene: BABYLON.Scene);
  83441. shadowColor: BABYLON.Color3;
  83442. needAlphaBlending(): boolean;
  83443. needAlphaTesting(): boolean;
  83444. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83445. get activeLight(): BABYLON.IShadowLight;
  83446. set activeLight(light: BABYLON.IShadowLight);
  83447. private _getFirstShadowLightForMesh;
  83448. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83449. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83450. clone(name: string): ShadowOnlyMaterial;
  83451. serialize(): any;
  83452. getClassName(): string;
  83453. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83454. }
  83455. }
  83456. declare module BABYLON {
  83457. /** @hidden */
  83458. export var simplePixelShader: {
  83459. name: string;
  83460. shader: string;
  83461. };
  83462. }
  83463. declare module BABYLON {
  83464. /** @hidden */
  83465. export var simpleVertexShader: {
  83466. name: string;
  83467. shader: string;
  83468. };
  83469. }
  83470. declare module BABYLON {
  83471. export class SimpleMaterial extends BABYLON.PushMaterial {
  83472. private _diffuseTexture;
  83473. diffuseTexture: BABYLON.BaseTexture;
  83474. diffuseColor: BABYLON.Color3;
  83475. private _disableLighting;
  83476. disableLighting: boolean;
  83477. private _maxSimultaneousLights;
  83478. maxSimultaneousLights: number;
  83479. constructor(name: string, scene: BABYLON.Scene);
  83480. needAlphaBlending(): boolean;
  83481. needAlphaTesting(): boolean;
  83482. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83483. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83484. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83485. getAnimatables(): BABYLON.IAnimatable[];
  83486. getActiveTextures(): BABYLON.BaseTexture[];
  83487. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83488. dispose(forceDisposeEffect?: boolean): void;
  83489. clone(name: string): SimpleMaterial;
  83490. serialize(): any;
  83491. getClassName(): string;
  83492. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83493. }
  83494. }
  83495. declare module BABYLON {
  83496. /** @hidden */
  83497. export var skyPixelShader: {
  83498. name: string;
  83499. shader: string;
  83500. };
  83501. }
  83502. declare module BABYLON {
  83503. /** @hidden */
  83504. export var skyVertexShader: {
  83505. name: string;
  83506. shader: string;
  83507. };
  83508. }
  83509. declare module BABYLON {
  83510. /**
  83511. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83512. * @see https://doc.babylonjs.com/extensions/sky
  83513. */
  83514. export class SkyMaterial extends BABYLON.PushMaterial {
  83515. /**
  83516. * Defines the overall luminance of sky in interval ]0, 1[.
  83517. */
  83518. luminance: number;
  83519. /**
  83520. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83521. */
  83522. turbidity: number;
  83523. /**
  83524. * Defines the sky appearance (light intensity).
  83525. */
  83526. rayleigh: number;
  83527. /**
  83528. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83529. */
  83530. mieCoefficient: number;
  83531. /**
  83532. * Defines the amount of haze particles following the Mie scattering theory.
  83533. */
  83534. mieDirectionalG: number;
  83535. /**
  83536. * Defines the distance of the sun according to the active scene camera.
  83537. */
  83538. distance: number;
  83539. /**
  83540. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83541. * "inclined".
  83542. */
  83543. inclination: number;
  83544. /**
  83545. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83546. * an object direction and a reference direction.
  83547. */
  83548. azimuth: number;
  83549. /**
  83550. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83551. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83552. */
  83553. sunPosition: BABYLON.Vector3;
  83554. /**
  83555. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83556. * .sunPosition property.
  83557. */
  83558. useSunPosition: boolean;
  83559. /**
  83560. * Defines an offset vector used to get a horizon offset.
  83561. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83562. */
  83563. cameraOffset: BABYLON.Vector3;
  83564. private _cameraPosition;
  83565. /**
  83566. * Instantiates a new sky material.
  83567. * This material allows to create dynamic and texture free
  83568. * effects for skyboxes by taking care of the atmosphere state.
  83569. * @see https://doc.babylonjs.com/extensions/sky
  83570. * @param name Define the name of the material in the scene
  83571. * @param scene Define the scene the material belong to
  83572. */
  83573. constructor(name: string, scene: BABYLON.Scene);
  83574. /**
  83575. * Specifies if the material will require alpha blending
  83576. * @returns a boolean specifying if alpha blending is needed
  83577. */
  83578. needAlphaBlending(): boolean;
  83579. /**
  83580. * Specifies if this material should be rendered in alpha test mode
  83581. * @returns false as the sky material doesn't need alpha testing.
  83582. */
  83583. needAlphaTesting(): boolean;
  83584. /**
  83585. * Get the texture used for alpha test purpose.
  83586. * @returns null as the sky material has no texture.
  83587. */
  83588. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83589. /**
  83590. * Get if the submesh is ready to be used and all its information available.
  83591. * Child classes can use it to update shaders
  83592. * @param mesh defines the mesh to check
  83593. * @param subMesh defines which submesh to check
  83594. * @param useInstances specifies that instances should be used
  83595. * @returns a boolean indicating that the submesh is ready or not
  83596. */
  83597. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83598. /**
  83599. * Binds the submesh to this material by preparing the effect and shader to draw
  83600. * @param world defines the world transformation matrix
  83601. * @param mesh defines the mesh containing the submesh
  83602. * @param subMesh defines the submesh to bind the material to
  83603. */
  83604. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83605. /**
  83606. * Get the list of animatables in the material.
  83607. * @returns the list of animatables object used in the material
  83608. */
  83609. getAnimatables(): BABYLON.IAnimatable[];
  83610. /**
  83611. * Disposes the material
  83612. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83613. */
  83614. dispose(forceDisposeEffect?: boolean): void;
  83615. /**
  83616. * Makes a duplicate of the material, and gives it a new name
  83617. * @param name defines the new name for the duplicated material
  83618. * @returns the cloned material
  83619. */
  83620. clone(name: string): SkyMaterial;
  83621. /**
  83622. * Serializes this material in a JSON representation
  83623. * @returns the serialized material object
  83624. */
  83625. serialize(): any;
  83626. /**
  83627. * Gets the current class name of the material e.g. "SkyMaterial"
  83628. * Mainly use in serialization.
  83629. * @returns the class name
  83630. */
  83631. getClassName(): string;
  83632. /**
  83633. * Creates a sky material from parsed material data
  83634. * @param source defines the JSON representation of the material
  83635. * @param scene defines the hosting scene
  83636. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83637. * @returns a new sky material
  83638. */
  83639. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83640. }
  83641. }
  83642. declare module BABYLON {
  83643. /** @hidden */
  83644. export var terrainPixelShader: {
  83645. name: string;
  83646. shader: string;
  83647. };
  83648. }
  83649. declare module BABYLON {
  83650. /** @hidden */
  83651. export var terrainVertexShader: {
  83652. name: string;
  83653. shader: string;
  83654. };
  83655. }
  83656. declare module BABYLON {
  83657. export class TerrainMaterial extends BABYLON.PushMaterial {
  83658. private _mixTexture;
  83659. mixTexture: BABYLON.BaseTexture;
  83660. private _diffuseTexture1;
  83661. diffuseTexture1: BABYLON.Texture;
  83662. private _diffuseTexture2;
  83663. diffuseTexture2: BABYLON.Texture;
  83664. private _diffuseTexture3;
  83665. diffuseTexture3: BABYLON.Texture;
  83666. private _bumpTexture1;
  83667. bumpTexture1: BABYLON.Texture;
  83668. private _bumpTexture2;
  83669. bumpTexture2: BABYLON.Texture;
  83670. private _bumpTexture3;
  83671. bumpTexture3: BABYLON.Texture;
  83672. diffuseColor: BABYLON.Color3;
  83673. specularColor: BABYLON.Color3;
  83674. specularPower: number;
  83675. private _disableLighting;
  83676. disableLighting: boolean;
  83677. private _maxSimultaneousLights;
  83678. maxSimultaneousLights: number;
  83679. constructor(name: string, scene: BABYLON.Scene);
  83680. needAlphaBlending(): boolean;
  83681. needAlphaTesting(): boolean;
  83682. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83683. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83684. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83685. getAnimatables(): BABYLON.IAnimatable[];
  83686. getActiveTextures(): BABYLON.BaseTexture[];
  83687. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83688. dispose(forceDisposeEffect?: boolean): void;
  83689. clone(name: string): TerrainMaterial;
  83690. serialize(): any;
  83691. getClassName(): string;
  83692. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83693. }
  83694. }
  83695. declare module BABYLON {
  83696. /** @hidden */
  83697. export var triplanarPixelShader: {
  83698. name: string;
  83699. shader: string;
  83700. };
  83701. }
  83702. declare module BABYLON {
  83703. /** @hidden */
  83704. export var triplanarVertexShader: {
  83705. name: string;
  83706. shader: string;
  83707. };
  83708. }
  83709. declare module BABYLON {
  83710. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83711. mixTexture: BABYLON.BaseTexture;
  83712. private _diffuseTextureX;
  83713. diffuseTextureX: BABYLON.BaseTexture;
  83714. private _diffuseTextureY;
  83715. diffuseTextureY: BABYLON.BaseTexture;
  83716. private _diffuseTextureZ;
  83717. diffuseTextureZ: BABYLON.BaseTexture;
  83718. private _normalTextureX;
  83719. normalTextureX: BABYLON.BaseTexture;
  83720. private _normalTextureY;
  83721. normalTextureY: BABYLON.BaseTexture;
  83722. private _normalTextureZ;
  83723. normalTextureZ: BABYLON.BaseTexture;
  83724. tileSize: number;
  83725. diffuseColor: BABYLON.Color3;
  83726. specularColor: BABYLON.Color3;
  83727. specularPower: number;
  83728. private _disableLighting;
  83729. disableLighting: boolean;
  83730. private _maxSimultaneousLights;
  83731. maxSimultaneousLights: number;
  83732. constructor(name: string, scene: BABYLON.Scene);
  83733. needAlphaBlending(): boolean;
  83734. needAlphaTesting(): boolean;
  83735. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83736. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83737. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83738. getAnimatables(): BABYLON.IAnimatable[];
  83739. getActiveTextures(): BABYLON.BaseTexture[];
  83740. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83741. dispose(forceDisposeEffect?: boolean): void;
  83742. clone(name: string): TriPlanarMaterial;
  83743. serialize(): any;
  83744. getClassName(): string;
  83745. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83746. }
  83747. }
  83748. declare module BABYLON {
  83749. /** @hidden */
  83750. export var waterPixelShader: {
  83751. name: string;
  83752. shader: string;
  83753. };
  83754. }
  83755. declare module BABYLON {
  83756. /** @hidden */
  83757. export var waterVertexShader: {
  83758. name: string;
  83759. shader: string;
  83760. };
  83761. }
  83762. declare module BABYLON {
  83763. export class WaterMaterial extends BABYLON.PushMaterial {
  83764. renderTargetSize: BABYLON.Vector2;
  83765. private _bumpTexture;
  83766. bumpTexture: BABYLON.BaseTexture;
  83767. diffuseColor: BABYLON.Color3;
  83768. specularColor: BABYLON.Color3;
  83769. specularPower: number;
  83770. private _disableLighting;
  83771. disableLighting: boolean;
  83772. private _maxSimultaneousLights;
  83773. maxSimultaneousLights: number;
  83774. /**
  83775. * @param {number}: Represents the wind force
  83776. */
  83777. windForce: number;
  83778. /**
  83779. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83780. */
  83781. windDirection: BABYLON.Vector2;
  83782. /**
  83783. * @param {number}: Wave height, represents the height of the waves
  83784. */
  83785. waveHeight: number;
  83786. /**
  83787. * @param {number}: Bump height, represents the bump height related to the bump map
  83788. */
  83789. bumpHeight: number;
  83790. /**
  83791. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83792. */
  83793. private _bumpSuperimpose;
  83794. bumpSuperimpose: boolean;
  83795. /**
  83796. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83797. */
  83798. private _fresnelSeparate;
  83799. fresnelSeparate: boolean;
  83800. /**
  83801. * @param {boolean}: bump Waves modify the reflection.
  83802. */
  83803. private _bumpAffectsReflection;
  83804. bumpAffectsReflection: boolean;
  83805. /**
  83806. * @param {number}: The water color blended with the refraction (near)
  83807. */
  83808. waterColor: BABYLON.Color3;
  83809. /**
  83810. * @param {number}: The blend factor related to the water color
  83811. */
  83812. colorBlendFactor: number;
  83813. /**
  83814. * @param {number}: The water color blended with the reflection (far)
  83815. */
  83816. waterColor2: BABYLON.Color3;
  83817. /**
  83818. * @param {number}: The blend factor related to the water color (reflection, far)
  83819. */
  83820. colorBlendFactor2: number;
  83821. /**
  83822. * @param {number}: Represents the maximum length of a wave
  83823. */
  83824. waveLength: number;
  83825. /**
  83826. * @param {number}: Defines the waves speed
  83827. */
  83828. waveSpeed: number;
  83829. /**
  83830. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83831. * will avoid calculating useless pixels in the pixel shader of the water material.
  83832. */
  83833. disableClipPlane: boolean;
  83834. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83835. private _mesh;
  83836. private _refractionRTT;
  83837. private _reflectionRTT;
  83838. private _reflectionTransform;
  83839. private _lastTime;
  83840. private _lastDeltaTime;
  83841. private _useLogarithmicDepth;
  83842. private _waitingRenderList;
  83843. private _imageProcessingConfiguration;
  83844. private _imageProcessingObserver;
  83845. /**
  83846. * Gets a boolean indicating that current material needs to register RTT
  83847. */
  83848. get hasRenderTargetTextures(): boolean;
  83849. /**
  83850. * Constructor
  83851. */
  83852. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83853. get useLogarithmicDepth(): boolean;
  83854. set useLogarithmicDepth(value: boolean);
  83855. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83856. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83857. addToRenderList(node: any): void;
  83858. enableRenderTargets(enable: boolean): void;
  83859. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83860. get renderTargetsEnabled(): boolean;
  83861. needAlphaBlending(): boolean;
  83862. needAlphaTesting(): boolean;
  83863. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83864. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83865. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83866. private _createRenderTargets;
  83867. getAnimatables(): BABYLON.IAnimatable[];
  83868. getActiveTextures(): BABYLON.BaseTexture[];
  83869. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83870. dispose(forceDisposeEffect?: boolean): void;
  83871. clone(name: string): WaterMaterial;
  83872. serialize(): any;
  83873. getClassName(): string;
  83874. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83875. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83876. }
  83877. }
  83878. declare module BABYLON {
  83879. /** @hidden */
  83880. export var asciiartPixelShader: {
  83881. name: string;
  83882. shader: string;
  83883. };
  83884. }
  83885. declare module BABYLON {
  83886. /**
  83887. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83888. *
  83889. * It basically takes care rendering the font front the given font size to a texture.
  83890. * This is used later on in the postprocess.
  83891. */
  83892. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83893. private _font;
  83894. private _text;
  83895. private _charSize;
  83896. /**
  83897. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83898. */
  83899. get charSize(): number;
  83900. /**
  83901. * Create a new instance of the Ascii Art FontTexture class
  83902. * @param name the name of the texture
  83903. * @param font the font to use, use the W3C CSS notation
  83904. * @param text the caracter set to use in the rendering.
  83905. * @param scene the scene that owns the texture
  83906. */
  83907. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83908. /**
  83909. * Gets the max char width of a font.
  83910. * @param font the font to use, use the W3C CSS notation
  83911. * @return the max char width
  83912. */
  83913. private getFontWidth;
  83914. /**
  83915. * Gets the max char height of a font.
  83916. * @param font the font to use, use the W3C CSS notation
  83917. * @return the max char height
  83918. */
  83919. private getFontHeight;
  83920. /**
  83921. * Clones the current AsciiArtTexture.
  83922. * @return the clone of the texture.
  83923. */
  83924. clone(): AsciiArtFontTexture;
  83925. /**
  83926. * Parses a json object representing the texture and returns an instance of it.
  83927. * @param source the source JSON representation
  83928. * @param scene the scene to create the texture for
  83929. * @return the parsed texture
  83930. */
  83931. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83932. }
  83933. /**
  83934. * Option available in the Ascii Art Post Process.
  83935. */
  83936. export interface IAsciiArtPostProcessOptions {
  83937. /**
  83938. * The font to use following the w3c font definition.
  83939. */
  83940. font?: string;
  83941. /**
  83942. * The character set to use in the postprocess.
  83943. */
  83944. characterSet?: string;
  83945. /**
  83946. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83947. * This number is defined between 0 and 1;
  83948. */
  83949. mixToTile?: number;
  83950. /**
  83951. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83952. * This number is defined between 0 and 1;
  83953. */
  83954. mixToNormal?: number;
  83955. }
  83956. /**
  83957. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83958. *
  83959. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83960. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83961. */
  83962. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83963. /**
  83964. * The font texture used to render the char in the post process.
  83965. */
  83966. private _asciiArtFontTexture;
  83967. /**
  83968. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83969. * This number is defined between 0 and 1;
  83970. */
  83971. mixToTile: number;
  83972. /**
  83973. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83974. * This number is defined between 0 and 1;
  83975. */
  83976. mixToNormal: number;
  83977. /**
  83978. * Instantiates a new Ascii Art Post Process.
  83979. * @param name the name to give to the postprocess
  83980. * @camera the camera to apply the post process to.
  83981. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83982. */
  83983. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83984. }
  83985. }
  83986. declare module BABYLON {
  83987. /** @hidden */
  83988. export var digitalrainPixelShader: {
  83989. name: string;
  83990. shader: string;
  83991. };
  83992. }
  83993. declare module BABYLON {
  83994. /**
  83995. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83996. *
  83997. * It basically takes care rendering the font front the given font size to a texture.
  83998. * This is used later on in the postprocess.
  83999. */
  84000. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84001. private _font;
  84002. private _text;
  84003. private _charSize;
  84004. /**
  84005. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84006. */
  84007. get charSize(): number;
  84008. /**
  84009. * Create a new instance of the Digital Rain FontTexture class
  84010. * @param name the name of the texture
  84011. * @param font the font to use, use the W3C CSS notation
  84012. * @param text the caracter set to use in the rendering.
  84013. * @param scene the scene that owns the texture
  84014. */
  84015. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84016. /**
  84017. * Gets the max char width of a font.
  84018. * @param font the font to use, use the W3C CSS notation
  84019. * @return the max char width
  84020. */
  84021. private getFontWidth;
  84022. /**
  84023. * Gets the max char height of a font.
  84024. * @param font the font to use, use the W3C CSS notation
  84025. * @return the max char height
  84026. */
  84027. private getFontHeight;
  84028. /**
  84029. * Clones the current DigitalRainFontTexture.
  84030. * @return the clone of the texture.
  84031. */
  84032. clone(): DigitalRainFontTexture;
  84033. /**
  84034. * Parses a json object representing the texture and returns an instance of it.
  84035. * @param source the source JSON representation
  84036. * @param scene the scene to create the texture for
  84037. * @return the parsed texture
  84038. */
  84039. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84040. }
  84041. /**
  84042. * Option available in the Digital Rain Post Process.
  84043. */
  84044. export interface IDigitalRainPostProcessOptions {
  84045. /**
  84046. * The font to use following the w3c font definition.
  84047. */
  84048. font?: string;
  84049. /**
  84050. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84051. * This number is defined between 0 and 1;
  84052. */
  84053. mixToTile?: number;
  84054. /**
  84055. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84056. * This number is defined between 0 and 1;
  84057. */
  84058. mixToNormal?: number;
  84059. }
  84060. /**
  84061. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84062. *
  84063. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84064. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84065. */
  84066. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84067. /**
  84068. * The font texture used to render the char in the post process.
  84069. */
  84070. private _digitalRainFontTexture;
  84071. /**
  84072. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84073. * This number is defined between 0 and 1;
  84074. */
  84075. mixToTile: number;
  84076. /**
  84077. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84078. * This number is defined between 0 and 1;
  84079. */
  84080. mixToNormal: number;
  84081. /**
  84082. * Instantiates a new Digital Rain Post Process.
  84083. * @param name the name to give to the postprocess
  84084. * @camera the camera to apply the post process to.
  84085. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84086. */
  84087. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84088. }
  84089. }
  84090. declare module BABYLON {
  84091. /** @hidden */
  84092. export var brickProceduralTexturePixelShader: {
  84093. name: string;
  84094. shader: string;
  84095. };
  84096. }
  84097. declare module BABYLON {
  84098. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84099. private _numberOfBricksHeight;
  84100. private _numberOfBricksWidth;
  84101. private _jointColor;
  84102. private _brickColor;
  84103. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84104. updateShaderUniforms(): void;
  84105. get numberOfBricksHeight(): number;
  84106. set numberOfBricksHeight(value: number);
  84107. get numberOfBricksWidth(): number;
  84108. set numberOfBricksWidth(value: number);
  84109. get jointColor(): BABYLON.Color3;
  84110. set jointColor(value: BABYLON.Color3);
  84111. get brickColor(): BABYLON.Color3;
  84112. set brickColor(value: BABYLON.Color3);
  84113. /**
  84114. * Serializes this brick procedural texture
  84115. * @returns a serialized brick procedural texture object
  84116. */
  84117. serialize(): any;
  84118. /**
  84119. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84120. * @param parsedTexture defines parsed texture data
  84121. * @param scene defines the current scene
  84122. * @param rootUrl defines the root URL containing brick procedural texture information
  84123. * @returns a parsed Brick Procedural BABYLON.Texture
  84124. */
  84125. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84126. }
  84127. }
  84128. declare module BABYLON {
  84129. /** @hidden */
  84130. export var cloudProceduralTexturePixelShader: {
  84131. name: string;
  84132. shader: string;
  84133. };
  84134. }
  84135. declare module BABYLON {
  84136. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84137. private _skyColor;
  84138. private _cloudColor;
  84139. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84140. updateShaderUniforms(): void;
  84141. get skyColor(): BABYLON.Color4;
  84142. set skyColor(value: BABYLON.Color4);
  84143. get cloudColor(): BABYLON.Color4;
  84144. set cloudColor(value: BABYLON.Color4);
  84145. /**
  84146. * Serializes this cloud procedural texture
  84147. * @returns a serialized cloud procedural texture object
  84148. */
  84149. serialize(): any;
  84150. /**
  84151. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84152. * @param parsedTexture defines parsed texture data
  84153. * @param scene defines the current scene
  84154. * @param rootUrl defines the root URL containing cloud procedural texture information
  84155. * @returns a parsed Cloud Procedural BABYLON.Texture
  84156. */
  84157. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84158. }
  84159. }
  84160. declare module BABYLON {
  84161. /** @hidden */
  84162. export var fireProceduralTexturePixelShader: {
  84163. name: string;
  84164. shader: string;
  84165. };
  84166. }
  84167. declare module BABYLON {
  84168. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84169. private _time;
  84170. private _speed;
  84171. private _autoGenerateTime;
  84172. private _fireColors;
  84173. private _alphaThreshold;
  84174. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84175. updateShaderUniforms(): void;
  84176. render(useCameraPostProcess?: boolean): void;
  84177. static get PurpleFireColors(): BABYLON.Color3[];
  84178. static get GreenFireColors(): BABYLON.Color3[];
  84179. static get RedFireColors(): BABYLON.Color3[];
  84180. static get BlueFireColors(): BABYLON.Color3[];
  84181. get autoGenerateTime(): boolean;
  84182. set autoGenerateTime(value: boolean);
  84183. get fireColors(): BABYLON.Color3[];
  84184. set fireColors(value: BABYLON.Color3[]);
  84185. get time(): number;
  84186. set time(value: number);
  84187. get speed(): BABYLON.Vector2;
  84188. set speed(value: BABYLON.Vector2);
  84189. get alphaThreshold(): number;
  84190. set alphaThreshold(value: number);
  84191. /**
  84192. * Serializes this fire procedural texture
  84193. * @returns a serialized fire procedural texture object
  84194. */
  84195. serialize(): any;
  84196. /**
  84197. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84198. * @param parsedTexture defines parsed texture data
  84199. * @param scene defines the current scene
  84200. * @param rootUrl defines the root URL containing fire procedural texture information
  84201. * @returns a parsed Fire Procedural BABYLON.Texture
  84202. */
  84203. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84204. }
  84205. }
  84206. declare module BABYLON {
  84207. /** @hidden */
  84208. export var grassProceduralTexturePixelShader: {
  84209. name: string;
  84210. shader: string;
  84211. };
  84212. }
  84213. declare module BABYLON {
  84214. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84215. private _grassColors;
  84216. private _groundColor;
  84217. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84218. updateShaderUniforms(): void;
  84219. get grassColors(): BABYLON.Color3[];
  84220. set grassColors(value: BABYLON.Color3[]);
  84221. get groundColor(): BABYLON.Color3;
  84222. set groundColor(value: BABYLON.Color3);
  84223. /**
  84224. * Serializes this grass procedural texture
  84225. * @returns a serialized grass procedural texture object
  84226. */
  84227. serialize(): any;
  84228. /**
  84229. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84230. * @param parsedTexture defines parsed texture data
  84231. * @param scene defines the current scene
  84232. * @param rootUrl defines the root URL containing grass procedural texture information
  84233. * @returns a parsed Grass Procedural BABYLON.Texture
  84234. */
  84235. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84236. }
  84237. }
  84238. declare module BABYLON {
  84239. /** @hidden */
  84240. export var marbleProceduralTexturePixelShader: {
  84241. name: string;
  84242. shader: string;
  84243. };
  84244. }
  84245. declare module BABYLON {
  84246. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84247. private _numberOfTilesHeight;
  84248. private _numberOfTilesWidth;
  84249. private _amplitude;
  84250. private _jointColor;
  84251. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84252. updateShaderUniforms(): void;
  84253. get numberOfTilesHeight(): number;
  84254. set numberOfTilesHeight(value: number);
  84255. get amplitude(): number;
  84256. set amplitude(value: number);
  84257. get numberOfTilesWidth(): number;
  84258. set numberOfTilesWidth(value: number);
  84259. get jointColor(): BABYLON.Color3;
  84260. set jointColor(value: BABYLON.Color3);
  84261. /**
  84262. * Serializes this marble procedural texture
  84263. * @returns a serialized marble procedural texture object
  84264. */
  84265. serialize(): any;
  84266. /**
  84267. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84268. * @param parsedTexture defines parsed texture data
  84269. * @param scene defines the current scene
  84270. * @param rootUrl defines the root URL containing marble procedural texture information
  84271. * @returns a parsed Marble Procedural BABYLON.Texture
  84272. */
  84273. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84274. }
  84275. }
  84276. declare module BABYLON {
  84277. /** @hidden */
  84278. export var normalMapProceduralTexturePixelShader: {
  84279. name: string;
  84280. shader: string;
  84281. };
  84282. }
  84283. declare module BABYLON {
  84284. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84285. private _baseTexture;
  84286. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84287. updateShaderUniforms(): void;
  84288. render(useCameraPostProcess?: boolean): void;
  84289. resize(size: any, generateMipMaps: any): void;
  84290. get baseTexture(): BABYLON.Texture;
  84291. set baseTexture(texture: BABYLON.Texture);
  84292. /**
  84293. * Serializes this normal map procedural texture
  84294. * @returns a serialized normal map procedural texture object
  84295. */
  84296. serialize(): any;
  84297. /**
  84298. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84299. * @param parsedTexture defines parsed texture data
  84300. * @param scene defines the current scene
  84301. * @param rootUrl defines the root URL containing normal map procedural texture information
  84302. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84303. */
  84304. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84305. }
  84306. }
  84307. declare module BABYLON {
  84308. /** @hidden */
  84309. export var perlinNoiseProceduralTexturePixelShader: {
  84310. name: string;
  84311. shader: string;
  84312. };
  84313. }
  84314. declare module BABYLON {
  84315. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84316. time: number;
  84317. timeScale: number;
  84318. translationSpeed: number;
  84319. private _currentTranslation;
  84320. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84321. updateShaderUniforms(): void;
  84322. render(useCameraPostProcess?: boolean): void;
  84323. resize(size: any, generateMipMaps: any): void;
  84324. /**
  84325. * Serializes this perlin noise procedural texture
  84326. * @returns a serialized perlin noise procedural texture object
  84327. */
  84328. serialize(): any;
  84329. /**
  84330. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84331. * @param parsedTexture defines parsed texture data
  84332. * @param scene defines the current scene
  84333. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84334. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84335. */
  84336. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84337. }
  84338. }
  84339. declare module BABYLON {
  84340. /** @hidden */
  84341. export var roadProceduralTexturePixelShader: {
  84342. name: string;
  84343. shader: string;
  84344. };
  84345. }
  84346. declare module BABYLON {
  84347. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84348. private _roadColor;
  84349. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84350. updateShaderUniforms(): void;
  84351. get roadColor(): BABYLON.Color3;
  84352. set roadColor(value: BABYLON.Color3);
  84353. /**
  84354. * Serializes this road procedural texture
  84355. * @returns a serialized road procedural texture object
  84356. */
  84357. serialize(): any;
  84358. /**
  84359. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84360. * @param parsedTexture defines parsed texture data
  84361. * @param scene defines the current scene
  84362. * @param rootUrl defines the root URL containing road procedural texture information
  84363. * @returns a parsed Road Procedural BABYLON.Texture
  84364. */
  84365. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84366. }
  84367. }
  84368. declare module BABYLON {
  84369. /** @hidden */
  84370. export var starfieldProceduralTexturePixelShader: {
  84371. name: string;
  84372. shader: string;
  84373. };
  84374. }
  84375. declare module BABYLON {
  84376. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84377. private _time;
  84378. private _alpha;
  84379. private _beta;
  84380. private _zoom;
  84381. private _formuparam;
  84382. private _stepsize;
  84383. private _tile;
  84384. private _brightness;
  84385. private _darkmatter;
  84386. private _distfading;
  84387. private _saturation;
  84388. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84389. updateShaderUniforms(): void;
  84390. get time(): number;
  84391. set time(value: number);
  84392. get alpha(): number;
  84393. set alpha(value: number);
  84394. get beta(): number;
  84395. set beta(value: number);
  84396. get formuparam(): number;
  84397. set formuparam(value: number);
  84398. get stepsize(): number;
  84399. set stepsize(value: number);
  84400. get zoom(): number;
  84401. set zoom(value: number);
  84402. get tile(): number;
  84403. set tile(value: number);
  84404. get brightness(): number;
  84405. set brightness(value: number);
  84406. get darkmatter(): number;
  84407. set darkmatter(value: number);
  84408. get distfading(): number;
  84409. set distfading(value: number);
  84410. get saturation(): number;
  84411. set saturation(value: number);
  84412. /**
  84413. * Serializes this starfield procedural texture
  84414. * @returns a serialized starfield procedural texture object
  84415. */
  84416. serialize(): any;
  84417. /**
  84418. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84419. * @param parsedTexture defines parsed texture data
  84420. * @param scene defines the current scene
  84421. * @param rootUrl defines the root URL containing startfield procedural texture information
  84422. * @returns a parsed Starfield Procedural BABYLON.Texture
  84423. */
  84424. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84425. }
  84426. }
  84427. declare module BABYLON {
  84428. /** @hidden */
  84429. export var woodProceduralTexturePixelShader: {
  84430. name: string;
  84431. shader: string;
  84432. };
  84433. }
  84434. declare module BABYLON {
  84435. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84436. private _ampScale;
  84437. private _woodColor;
  84438. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84439. updateShaderUniforms(): void;
  84440. get ampScale(): number;
  84441. set ampScale(value: number);
  84442. get woodColor(): BABYLON.Color3;
  84443. set woodColor(value: BABYLON.Color3);
  84444. /**
  84445. * Serializes this wood procedural texture
  84446. * @returns a serialized wood procedural texture object
  84447. */
  84448. serialize(): any;
  84449. /**
  84450. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84451. * @param parsedTexture defines parsed texture data
  84452. * @param scene defines the current scene
  84453. * @param rootUrl defines the root URL containing wood procedural texture information
  84454. * @returns a parsed Wood Procedural BABYLON.Texture
  84455. */
  84456. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84457. }
  84458. }